Merge branch 'main' into enh/rocksdbSstate
This commit is contained in:
commit
fa46165227
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG ffc2e6f
|
GIT_TAG 4378702
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -106,6 +106,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
||||||
goto LABEL; \
|
goto LABEL; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -132,11 +132,15 @@ int32_t dmRunDnode(SDnode *pDnode) {
|
||||||
int32_t count = 0;
|
int32_t count = 0;
|
||||||
if (dmOpenNodes(pDnode) != 0) {
|
if (dmOpenNodes(pDnode) != 0) {
|
||||||
dError("failed to open nodes since %s", terrstr());
|
dError("failed to open nodes since %s", terrstr());
|
||||||
|
dmCloseNodes(pDnode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dmStartNodes(pDnode) != 0) {
|
if (dmStartNodes(pDnode) != 0) {
|
||||||
dError("failed to start nodes since %s", terrstr());
|
dError("failed to start nodes since %s", terrstr());
|
||||||
|
dmSetStatus(pDnode, DND_STAT_STOPPED);
|
||||||
|
dmStopNodes(pDnode);
|
||||||
|
dmCloseNodes(pDnode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,23 +187,24 @@ _err:
|
||||||
|
|
||||||
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
SMeta* pMeta = pWriter->pMeta;
|
SMeta* pMeta = pWriter->pMeta;
|
||||||
SMetaEntry metaEntry = {0};
|
SMetaEntry metaEntry = {0};
|
||||||
SDecoder* pDecoder = &(SDecoder){0};
|
SDecoder* pDecoder = &(SDecoder){0};
|
||||||
|
|
||||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
code = metaDecodeEntry(pDecoder, &metaEntry);
|
code = metaDecodeEntry(pDecoder, &metaEntry);
|
||||||
if (code) goto _err;
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
code = metaHandleEntry(pMeta, &metaEntry);
|
code = metaHandleEntry(pMeta, &metaEntry);
|
||||||
if (code) goto _err;
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
tDecoderClear(pDecoder);
|
tDecoderClear(pDecoder);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(pDecoder);
|
tDecoderClear(pDecoder);
|
||||||
metaError("vgId:%d, vnode snapshot meta write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
metaError("vgId:%d, vnode snapshot meta write failed since %s at line:%d", TD_VID(pMeta->pVnode), terrstr(), line);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1029,7 +1029,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
metaTrace("vgId:%d, start to save version:%" PRId64 " uid:%" PRId64 " ctime:%" PRId64, TD_VID(pMeta->pVnode),
|
metaTrace("vgId:%d, start to save version:%" PRId64 " uid:%" PRId64 " ctime:%" PRId64, TD_VID(pMeta->pVnode),
|
||||||
pME->version, pME->uid, ctimeKey.ctime);
|
pME->version, pME->uid, ctimeKey.ctime);
|
||||||
|
|
||||||
return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
return tdbTbUpsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
@ -1044,7 +1044,7 @@ int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
if (metaBuildNColIdxKey(&ncolKey, pME) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, pMeta->txn);
|
return tdbTbUpsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
@ -1878,24 +1878,24 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, pMeta->txn);
|
return tdbTbUpsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
return tdbTbUpsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
STtlIdxKey ttlKey = {0};
|
STtlIdxKey ttlKey = {0};
|
||||||
metaBuildTtlIdxKey(&ttlKey, pME);
|
metaBuildTtlIdxKey(&ttlKey, pME);
|
||||||
if (ttlKey.dtime == 0) return 0;
|
if (ttlKey.dtime == 0) return 0;
|
||||||
return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, pMeta->txn);
|
return tdbTbUpsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid};
|
||||||
|
|
||||||
return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags,
|
return tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags,
|
||||||
((STag *)(pME->ctbEntry.pTags))->len, pMeta->txn);
|
((STag *)(pME->ctbEntry.pTags))->len, pMeta->txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2065,49 +2065,66 @@ _exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t line = 0;
|
||||||
metaWLock(pMeta);
|
metaWLock(pMeta);
|
||||||
|
|
||||||
// save to table.db
|
// save to table.db
|
||||||
if (metaSaveToTbDb(pMeta, pME) < 0) goto _err;
|
code = metaSaveToTbDb(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
// update uid.idx
|
// update uid.idx
|
||||||
if (metaUpdateUidIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateUidIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
// update name.idx
|
// update name.idx
|
||||||
if (metaUpdateNameIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateNameIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
if (pME->type == TSDB_CHILD_TABLE) {
|
if (pME->type == TSDB_CHILD_TABLE) {
|
||||||
// update ctb.idx
|
// update ctb.idx
|
||||||
if (metaUpdateCtbIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateCtbIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
// update tag.idx
|
// update tag.idx
|
||||||
if (metaUpdateTagIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateTagIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
} else {
|
} else {
|
||||||
// update schema.db
|
// update schema.db
|
||||||
if (metaSaveToSkmDb(pMeta, pME) < 0) goto _err;
|
code = metaSaveToSkmDb(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
if (pME->type == TSDB_SUPER_TABLE) {
|
if (pME->type == TSDB_SUPER_TABLE) {
|
||||||
if (metaUpdateSuidIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateSuidIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaUpdateCtimeIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateCtimeIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
|
|
||||||
if (pME->type == TSDB_NORMAL_TABLE) {
|
if (pME->type == TSDB_NORMAL_TABLE) {
|
||||||
if (metaUpdateNcolIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateNcolIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pME->type != TSDB_SUPER_TABLE) {
|
if (pME->type != TSDB_SUPER_TABLE) {
|
||||||
if (metaUpdateTtlIdx(pMeta, pME) < 0) goto _err;
|
code = metaUpdateTtlIdx(pMeta, pME);
|
||||||
|
VND_CHECK_CODE(code, line, _err);
|
||||||
}
|
}
|
||||||
|
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
metaDebug("vgId:%d, handle meta entry, ver:%" PRId64 ", uid:%" PRId64 ", name:%s", TD_VID(pMeta->pVnode),
|
||||||
|
pME->version, pME->uid, pME->name);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
metaULock(pMeta);
|
metaULock(pMeta);
|
||||||
|
metaError("vgId:%d, failed to handle meta entry since %s at line:%d, ver:%" PRId64 ", uid:%" PRId64 ", name:%s",
|
||||||
|
TD_VID(pMeta->pVnode), terrstr(), line, pME->version, pME->uid, pME->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// refactor later
|
// refactor later
|
||||||
void *metaGetIdx(SMeta *pMeta) { return pMeta->pTagIdx; }
|
void *metaGetIdx(SMeta *pMeta) { return pMeta->pTagIdx; }
|
||||||
void *metaGetIvtIdx(SMeta *pMeta) { return pMeta->pTagIvtIdx; }
|
void *metaGetIvtIdx(SMeta *pMeta) { return pMeta->pTagIvtIdx; }
|
||||||
|
|
|
@ -1358,6 +1358,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
terrno = 0;
|
||||||
pSubmitTbData->uid = pSubmitTbData->pCreateTbReq->uid; // update uid if table exist for using below
|
pSubmitTbData->uid = pSubmitTbData->pCreateTbReq->uid; // update uid if table exist for using below
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,71 @@ static FORCE_INLINE int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCt
|
||||||
param->status = SFLT_COARSE_INDEX;
|
param->status = SFLT_COARSE_INDEX;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int32_t sifNeedConvertCond(SNode *l, SNode *r) {
|
||||||
|
if (nodeType(l) != QUERY_NODE_COLUMN || nodeType(r) != QUERY_NODE_VALUE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SColumnNode *c = (SColumnNode *)l;
|
||||||
|
SValueNode *v = (SValueNode *)r;
|
||||||
|
int32_t ctype = c->node.resType.type;
|
||||||
|
int32_t vtype = v->node.resType.type;
|
||||||
|
if (!IS_VAR_DATA_TYPE(ctype) && IS_VAR_DATA_TYPE(vtype)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int32_t sifInitParamValByCol(SNode *r, SNode *l, SIFParam *param, SIFCtx *ctx) {
|
||||||
|
param->status = SFLT_COARSE_INDEX;
|
||||||
|
SColumnNode *cn = (SColumnNode *)r;
|
||||||
|
SValueNode *vn = (SValueNode *)l;
|
||||||
|
if (vn->typeData == TSDB_DATA_TYPE_NULL && (vn->literal == NULL || strlen(vn->literal) == 0)) {
|
||||||
|
param->status = SFLT_NOT_INDEX;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SDataType *pType = &cn->node.resType;
|
||||||
|
int32_t type = pType->type;
|
||||||
|
|
||||||
|
SDataType *pVType = &vn->node.resType;
|
||||||
|
int32_t vtype = pVType->type;
|
||||||
|
char *pData = nodesGetValueFromNode(vn);
|
||||||
|
int32_t valLen = 0;
|
||||||
|
char **value = ¶m->condValue;
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
int32_t dataLen = varDataTLen(pData);
|
||||||
|
if (type == TSDB_DATA_TYPE_JSON) {
|
||||||
|
if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||||
|
dataLen = 0;
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
dataLen = varDataTLen(pData);
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
dataLen = LONG_BYTES;
|
||||||
|
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
dataLen = CHAR_BYTES;
|
||||||
|
}
|
||||||
|
dataLen += CHAR_BYTES;
|
||||||
|
}
|
||||||
|
valLen = dataLen;
|
||||||
|
} else {
|
||||||
|
valLen = pType->bytes;
|
||||||
|
}
|
||||||
|
char *tv = taosMemoryCalloc(1, valLen + 1);
|
||||||
|
if (tv == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(tv, pData, valLen);
|
||||||
|
*value = tv;
|
||||||
|
|
||||||
|
param->colId = -1;
|
||||||
|
param->colValType = (uint8_t)(vn->node.resType.type);
|
||||||
|
if (vn->literal != NULL && strlen(vn->literal) <= sizeof(param->colName)) {
|
||||||
|
memcpy(param->colName, vn->literal, strlen(vn->literal));
|
||||||
|
} else {
|
||||||
|
param->status = SFLT_NOT_INDEX;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
param->status = SFLT_COARSE_INDEX;
|
param->status = SFLT_COARSE_INDEX;
|
||||||
switch (nodeType(node)) {
|
switch (nodeType(node)) {
|
||||||
|
@ -317,8 +382,13 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
SIF_ERR_JRET(sifInitParam(node->pLeft, ¶mList[0], ctx));
|
||||||
|
|
||||||
if (nParam > 1) {
|
if (nParam > 1) {
|
||||||
|
// if (sifNeedConvertCond(node->pLeft, node->pRight)) {
|
||||||
|
// SIF_ERR_JRET(sifInitParamValByCol(node->pLeft, node->pRight, ¶mList[1], ctx));
|
||||||
|
// } else {
|
||||||
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx));
|
||||||
|
// }
|
||||||
// if (paramList[0].colValType == TSDB_DATA_TYPE_JSON &&
|
// if (paramList[0].colValType == TSDB_DATA_TYPE_JSON &&
|
||||||
// ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) {
|
// ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) {
|
||||||
// return TSDB_CODE_OUT_OF_MEMORY;
|
// return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -404,60 +474,149 @@ static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reve
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
int32_t sifStr2Num(char *buf, int32_t len, int8_t type, void *val) {
|
||||||
|
// signed/unsigned/float
|
||||||
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
int64_t v = 0;
|
||||||
|
if (0 != toInteger(buf, len, 10, &v)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (type == TSDB_DATA_TYPE_BIGINT) {
|
||||||
|
*(int64_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_INT) {
|
||||||
|
*(int32_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_TINYINT) {
|
||||||
|
*(int8_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
|
*(int16_t *)val = v;
|
||||||
|
}
|
||||||
|
} else if (IS_FLOAT_TYPE(type)) {
|
||||||
|
if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
*(float *)val = taosStr2Float(buf, NULL);
|
||||||
|
} else {
|
||||||
|
*(double *)val = taosStr2Double(buf, NULL);
|
||||||
|
}
|
||||||
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
uint64_t v = 0;
|
||||||
|
if (0 != toUInteger(buf, len, 10, &v)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (type == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
|
*(uint64_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_UINT) {
|
||||||
|
*(uint32_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_UTINYINT) {
|
||||||
|
*(uint8_t *)val = v;
|
||||||
|
} else if (type == TSDB_DATA_TYPE_USMALLINT) {
|
||||||
|
*(uint16_t *)val = v;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void sifSetFltParam(SIFParam *left, SIFParam *right, SDataTypeBuf *typedata, SMetaFltParam *param) {
|
static int32_t sifSetFltParam(SIFParam *left, SIFParam *right, SDataTypeBuf *typedata, SMetaFltParam *param) {
|
||||||
|
int32_t code = 0;
|
||||||
int8_t ltype = left->colValType, rtype = right->colValType;
|
int8_t ltype = left->colValType, rtype = right->colValType;
|
||||||
|
if (!IS_NUMERIC_TYPE(ltype) || !((IS_NUMERIC_TYPE(rtype)) || rtype == TSDB_DATA_TYPE_VARCHAR)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (ltype == TSDB_DATA_TYPE_FLOAT) {
|
if (ltype == TSDB_DATA_TYPE_FLOAT) {
|
||||||
float f = 0;
|
float f = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, f);
|
SIF_DATA_CONVERT(rtype, right->condValue, f);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_FLOAT, &f));
|
||||||
|
}
|
||||||
typedata->f = f;
|
typedata->f = f;
|
||||||
param->val = &typedata->f;
|
param->val = &typedata->f;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (ltype == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, d);
|
SIF_DATA_CONVERT(rtype, right->condValue, d);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_DOUBLE, &d));
|
||||||
|
}
|
||||||
typedata->d = d;
|
typedata->d = d;
|
||||||
param->val = &typedata->d;
|
param->val = &typedata->d;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_BIGINT) {
|
} else if (ltype == TSDB_DATA_TYPE_BIGINT) {
|
||||||
int64_t i64 = 0;
|
int64_t i64 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, i64);
|
SIF_DATA_CONVERT(rtype, right->condValue, i64);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_BIGINT, &i64));
|
||||||
|
}
|
||||||
typedata->i64 = i64;
|
typedata->i64 = i64;
|
||||||
param->val = &typedata->i64;
|
param->val = &typedata->i64;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_INT) {
|
} else if (ltype == TSDB_DATA_TYPE_INT) {
|
||||||
int32_t i32 = 0;
|
int32_t i32 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, i32);
|
SIF_DATA_CONVERT(rtype, right->condValue, i32);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_INT, &i32));
|
||||||
|
}
|
||||||
typedata->i32 = i32;
|
typedata->i32 = i32;
|
||||||
param->val = &typedata->i32;
|
param->val = &typedata->i32;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_SMALLINT) {
|
} else if (ltype == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
int16_t i16 = 0;
|
int16_t i16 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, i16);
|
SIF_DATA_CONVERT(rtype, right->condValue, i16);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(
|
||||||
|
sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_SMALLINT, &i16));
|
||||||
|
}
|
||||||
|
|
||||||
typedata->i16 = i16;
|
typedata->i16 = i16;
|
||||||
param->val = &typedata->i16;
|
param->val = &typedata->i16;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_TINYINT) {
|
} else if (ltype == TSDB_DATA_TYPE_TINYINT) {
|
||||||
int8_t i8 = 0;
|
int8_t i8 = 0;
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, i8)
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
|
SIF_DATA_CONVERT(rtype, right->condValue, i8);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_TINYINT, &i8));
|
||||||
|
}
|
||||||
typedata->i8 = i8;
|
typedata->i8 = i8;
|
||||||
param->val = &typedata->i8;
|
param->val = &typedata->i8;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_UBIGINT) {
|
} else if (ltype == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
uint64_t u64 = 0;
|
uint64_t u64 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, u64);
|
SIF_DATA_CONVERT(rtype, right->condValue, u64);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_UBIGINT, &u64));
|
||||||
|
}
|
||||||
typedata->u64 = u64;
|
typedata->u64 = u64;
|
||||||
param->val = &typedata->u64;
|
param->val = &typedata->u64;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_UINT) {
|
} else if (ltype == TSDB_DATA_TYPE_UINT) {
|
||||||
uint32_t u32 = 0;
|
uint32_t u32 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, u32);
|
SIF_DATA_CONVERT(rtype, right->condValue, u32);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_UINT, &u32));
|
||||||
|
}
|
||||||
typedata->u32 = u32;
|
typedata->u32 = u32;
|
||||||
param->val = &typedata->u32;
|
param->val = &typedata->u32;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_USMALLINT) {
|
} else if (ltype == TSDB_DATA_TYPE_USMALLINT) {
|
||||||
uint16_t u16 = 0;
|
uint16_t u16 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, u16);
|
SIF_DATA_CONVERT(rtype, right->condValue, u16);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(
|
||||||
|
sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_USMALLINT, &u16));
|
||||||
|
}
|
||||||
typedata->u16 = u16;
|
typedata->u16 = u16;
|
||||||
param->val = &typedata->u16;
|
param->val = &typedata->u16;
|
||||||
} else if (ltype == TSDB_DATA_TYPE_UTINYINT) {
|
} else if (ltype == TSDB_DATA_TYPE_UTINYINT) {
|
||||||
uint8_t u8 = 0;
|
uint8_t u8 = 0;
|
||||||
|
if (IS_NUMERIC_TYPE(rtype)) {
|
||||||
SIF_DATA_CONVERT(rtype, right->condValue, u8);
|
SIF_DATA_CONVERT(rtype, right->condValue, u8);
|
||||||
|
} else {
|
||||||
|
SIF_ERR_RET(sifStr2Num(varDataVal(right->condValue), varDataLen(right->condValue), TSDB_DATA_TYPE_UTINYINT, &u8));
|
||||||
|
}
|
||||||
typedata->u8 = u8;
|
typedata->u8 = u8;
|
||||||
param->val = &typedata->u8;
|
param->val = &typedata->u8;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -498,7 +657,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
|
||||||
param.val = buf;
|
param.val = buf;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sifSetFltParam(left, right, &typedata, ¶m);
|
if (sifSetFltParam(left, right, &typedata, ¶m) != 0) return -1;
|
||||||
}
|
}
|
||||||
ret = metaFilterTableIds(arg->metaEx, ¶m, output->result);
|
ret = metaFilterTableIds(arg->metaEx, ¶m, output->result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ void taosGetSystemLocale(char *outLocale, char *outCharset) {
|
||||||
strcpy(outLocale, "en_US.UTF-8");
|
strcpy(outLocale, "en_US.UTF-8");
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(outLocale, locale, TD_LOCALE_LEN);
|
tstrncpy(outLocale, locale, TD_LOCALE_LEN);
|
||||||
// printf("locale not configured, set to system default:%s", outLocale);
|
printf("locale not configured, set to system default:%s\n", outLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if user does not specify the charset, extract it from locale
|
// if user does not specify the charset, extract it from locale
|
||||||
|
|
|
@ -123,6 +123,17 @@ sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '1'
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "1"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -123,6 +123,15 @@ sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '1';
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql select * from $mt where tgcol = "1.0"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "1.0"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "1"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -123,6 +123,16 @@ sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '1'
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "1";
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -85,10 +85,22 @@ sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select * from $mt where tgcol = 1
|
sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '1'
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "1"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -115,14 +115,36 @@ sql select * from $mt where tgcol = 0
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '0'
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = "0"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
sql select * from $mt where tgcol <> 0
|
sql select * from $mt where tgcol <> 0
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql select * from $mt where tgcol = 1
|
sql select * from $mt where tgcol = 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
sql select * from $mt where tgcol = "1"
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql select * from $mt where tgcol = '1'
|
||||||
|
if $rows != 100 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
|
||||||
sql select * from $mt where tgcol <> 1
|
sql select * from $mt where tgcol <> 1
|
||||||
if $rows != 100 then
|
if $rows != 100 then
|
||||||
return -1
|
return -1
|
||||||
|
|
Loading…
Reference in New Issue