fix return error
This commit is contained in:
parent
7bde46e6d3
commit
61e2f68542
|
@ -1234,6 +1234,9 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
SIdxCursor *pCursor = NULL;
|
SIdxCursor *pCursor = NULL;
|
||||||
pCursor = (SIdxCursor *)taosMemoryCalloc(1, sizeof(SIdxCursor));
|
pCursor = (SIdxCursor *)taosMemoryCalloc(1, sizeof(SIdxCursor));
|
||||||
|
if (pCursor == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
pCursor->pMeta = pMeta;
|
pCursor->pMeta = pMeta;
|
||||||
pCursor->suid = param->suid;
|
pCursor->suid = param->suid;
|
||||||
pCursor->cid = param->cid;
|
pCursor->cid = param->cid;
|
||||||
|
@ -1241,21 +1244,29 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
metaRLock(pMeta);
|
metaRLock(pMeta);
|
||||||
|
|
||||||
if (tdbTbGet(pMeta->pUidIdx, ¶m->suid, sizeof(tb_uid_t), &pData, &nData) != 0) {
|
if ((ret = tdbTbGet(pMeta->pUidIdx, ¶m->suid, sizeof(tb_uid_t), &pData, &nData)) != 0) {
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
tbDbKey.uid = param->suid;
|
tbDbKey.uid = param->suid;
|
||||||
tbDbKey.version = ((SUidIdxVal *)pData)[0].version;
|
tbDbKey.version = ((SUidIdxVal *)pData)[0].version;
|
||||||
(void)tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData);
|
|
||||||
|
if((ret = tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData)) != 0) {
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tDecoderInit(&dc, pData, nData);
|
tDecoderInit(&dc, pData, nData);
|
||||||
ret = metaDecodeEntry(&dc, &oStbEntry);
|
ret = metaDecodeEntry(&dc, &oStbEntry);
|
||||||
|
if (ret != 0) {
|
||||||
if (oStbEntry.stbEntry.schemaTag.pSchema == NULL || oStbEntry.stbEntry.schemaTag.pSchema == NULL) {
|
|
||||||
ret = -1;
|
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
ret = -1;
|
|
||||||
|
if (oStbEntry.stbEntry.schemaTag.pSchema == NULL || oStbEntry.stbEntry.schemaTag.pSchema == NULL) {
|
||||||
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
ret = TSDB_CODE_INVALID_PARA;
|
||||||
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
|
for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) {
|
||||||
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
|
SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i;
|
||||||
if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema))) {
|
if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema))) {
|
||||||
|
@ -1277,7 +1288,6 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
if (param->val == NULL) {
|
if (param->val == NULL) {
|
||||||
metaError("vgId:%d, failed to filter NULL data", TD_VID(pMeta->pVnode));
|
metaError("vgId:%d, failed to filter NULL data", TD_VID(pMeta->pVnode));
|
||||||
ret = -1;
|
|
||||||
goto END;
|
goto END;
|
||||||
} else {
|
} else {
|
||||||
if (IS_VAR_DATA_TYPE(param->type)) {
|
if (IS_VAR_DATA_TYPE(param->type)) {
|
||||||
|
@ -1287,8 +1297,13 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
if (param->type == TSDB_DATA_TYPE_NCHAR) {
|
if (param->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
maxSize = 4 * nTagData + 1;
|
maxSize = 4 * nTagData + 1;
|
||||||
buf = taosMemoryCalloc(1, maxSize);
|
buf = taosMemoryCalloc(1, maxSize);
|
||||||
|
if (buf == NULL) {
|
||||||
|
ret = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
if (false == taosMbsToUcs4(tagData, nTagData, (TdUcs4 *)buf, maxSize, &maxSize)) {
|
if (false == taosMbsToUcs4(tagData, nTagData, (TdUcs4 *)buf, maxSize, &maxSize)) {
|
||||||
ret = -1;
|
ret = terrno;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,7 +1343,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
|
|
||||||
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
valid = tdbTbcGet(pCursor->pCur, (const void **)&entryKey, &nEntryKey, (const void **)&entryVal, &nEntryVal);
|
||||||
if (valid < 0) {
|
if (valid < 0) {
|
||||||
break;
|
ret = valid;
|
||||||
}
|
}
|
||||||
if (count > TRY_ERROR_LIMIT) {
|
if (count > TRY_ERROR_LIMIT) {
|
||||||
break;
|
break;
|
||||||
|
@ -1344,6 +1359,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
count++;
|
count++;
|
||||||
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||||
if (valid < 0) {
|
if (valid < 0) {
|
||||||
|
ret = valid;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1372,6 +1388,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
|
||||||
}
|
}
|
||||||
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);
|
||||||
if (valid < 0) {
|
if (valid < 0) {
|
||||||
|
ret = valid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
|
@ -904,10 +904,13 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
||||||
|
SIFCtx *ctx = context;
|
||||||
SFunctionNode *node = (SFunctionNode *)pNode;
|
SFunctionNode *node = (SFunctionNode *)pNode;
|
||||||
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
||||||
|
if (output.result == NULL) {
|
||||||
SIFCtx *ctx = context;
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
ctx->code = sifExecFunction(node, ctx, &output);
|
ctx->code = sifExecFunction(node, ctx, &output);
|
||||||
if (ctx->code != TSDB_CODE_SUCCESS) {
|
if (ctx->code != TSDB_CODE_SUCCESS) {
|
||||||
sifFreeParam(&output);
|
sifFreeParam(&output);
|
||||||
|
@ -921,11 +924,15 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
static EDealRes sifWalkLogic(SNode *pNode, void *context) {
|
static EDealRes sifWalkLogic(SNode *pNode, void *context) {
|
||||||
|
SIFCtx *ctx = context;
|
||||||
SLogicConditionNode *node = (SLogicConditionNode *)pNode;
|
SLogicConditionNode *node = (SLogicConditionNode *)pNode;
|
||||||
|
|
||||||
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
||||||
|
if (output.result == NULL) {
|
||||||
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SIFCtx *ctx = context;
|
|
||||||
ctx->code = sifExecLogic(node, ctx, &output);
|
ctx->code = sifExecLogic(node, ctx, &output);
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
sifFreeParam(&output);
|
sifFreeParam(&output);
|
||||||
|
@ -939,10 +946,14 @@ static EDealRes sifWalkLogic(SNode *pNode, void *context) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
static EDealRes sifWalkOper(SNode *pNode, void *context) {
|
||||||
|
SIFCtx *ctx = context;
|
||||||
SOperatorNode *node = (SOperatorNode *)pNode;
|
SOperatorNode *node = (SOperatorNode *)pNode;
|
||||||
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX};
|
||||||
|
if (output.result == NULL) {
|
||||||
|
ctx->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
SIFCtx *ctx = context;
|
|
||||||
ctx->code = sifExecOper(node, ctx, &output);
|
ctx->code = sifExecOper(node, ctx, &output);
|
||||||
if (ctx->code) {
|
if (ctx->code) {
|
||||||
sifFreeParam(&output);
|
sifFreeParam(&output);
|
||||||
|
@ -1018,7 +1029,9 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
|
||||||
SIF_ERR_RET(TSDB_CODE_APP_ERROR);
|
SIF_ERR_RET(TSDB_CODE_APP_ERROR);
|
||||||
}
|
}
|
||||||
if (res->result != NULL) {
|
if (res->result != NULL) {
|
||||||
(void)taosArrayAddAll(pDst->result, res->result);
|
if (taosArrayAddAll(pDst->result, res->result) == NULL) {
|
||||||
|
SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pDst->status = res->status;
|
pDst->status = res->status;
|
||||||
|
|
||||||
|
@ -1078,6 +1091,10 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result,
|
||||||
SFilterInfo *filter = NULL;
|
SFilterInfo *filter = NULL;
|
||||||
|
|
||||||
SArray *output = taosArrayInit(8, sizeof(uint64_t));
|
SArray *output = taosArrayInit(8, sizeof(uint64_t));
|
||||||
|
if (output == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
SIFParam param = {.arg = *metaArg, .result = output, .status = SFLT_NOT_INDEX, .api = *pAPI};
|
SIFParam param = {.arg = *metaArg, .result = output, .status = SFLT_NOT_INDEX, .api = *pAPI};
|
||||||
int32_t code = sifCalculate((SNode *)pFilterNode, ¶m);
|
int32_t code = sifCalculate((SNode *)pFilterNode, ¶m);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
|
@ -1090,8 +1107,11 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result,
|
||||||
*status = st;
|
*status = st;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosArrayAddAll(result, param.result);
|
|
||||||
sifFreeParam(¶m);
|
sifFreeParam(¶m);
|
||||||
|
|
||||||
|
if(taosArrayAddAll(result, param.result) == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue