Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30837
This commit is contained in:
commit
b3fb0837d3
File diff suppressed because it is too large
Load Diff
|
@ -68,7 +68,11 @@ SSdb *sdbInit(SSdbOpt *pOption) {
|
|||
void sdbCleanup(SSdb *pSdb) {
|
||||
mInfo("start to cleanup sdb");
|
||||
|
||||
(void)sdbWriteFile(pSdb, 0);
|
||||
int32_t code = 0;
|
||||
|
||||
if ((code = sdbWriteFile(pSdb, 0)) != 0) {
|
||||
mError("failed to write sdb file since %s", tstrerror(code));
|
||||
}
|
||||
|
||||
if (pSdb->currDir != NULL) {
|
||||
taosMemoryFreeClear(pSdb->currDir);
|
||||
|
|
|
@ -258,8 +258,11 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
if (code != 0) {
|
||||
mError("failed to read sdb file:%s head since %s", file, tstrerror(code));
|
||||
taosMemoryFree(pRaw);
|
||||
(void)taosCloseFile(&pFile);
|
||||
return -1;
|
||||
int32_t ret = 0;
|
||||
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||
mError("failed to close sdb file:%s since %s", file, tstrerror(ret));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int64_t tableVer[SDB_MAX] = {0};
|
||||
|
@ -361,7 +364,9 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
pSdb->commitTerm, pSdb->commitConfig);
|
||||
|
||||
_OVER:
|
||||
(void)taosCloseFile(&pFile);
|
||||
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||
mError("failed to close sdb file:%s since %s", file, tstrerror(ret));
|
||||
}
|
||||
sdbFreeRaw(pRaw);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
|
@ -404,8 +409,11 @@ static int32_t sdbWriteFileImp(SSdb *pSdb, int32_t skip_type) {
|
|||
code = sdbWriteFileHead(pSdb, pFile);
|
||||
if (code != 0) {
|
||||
mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code));
|
||||
(void)taosCloseFile(&pFile);
|
||||
return -1;
|
||||
int32_t ret = 0;
|
||||
if ((ret = taosCloseFile(&pFile)) != 0) {
|
||||
mError("failed to close sdb file:%s since %s", tmpfile, tstrerror(ret));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
|
||||
|
@ -613,12 +621,18 @@ static void sdbCloseIter(SSdbIter *pIter) {
|
|||
if (pIter == NULL) return;
|
||||
|
||||
if (pIter->file != NULL) {
|
||||
(void)taosCloseFile(&pIter->file);
|
||||
int32_t ret = 0;
|
||||
if ((ret = taosCloseFile(&pIter->file)) != 0) {
|
||||
mError("failed to close sdb file since %s", tstrerror(ret));
|
||||
}
|
||||
pIter->file = NULL;
|
||||
}
|
||||
|
||||
if (pIter->name != NULL) {
|
||||
(void)taosRemoveFile(pIter->name);
|
||||
int32_t ret = 0;
|
||||
if ((ret = taosRemoveFile(pIter->name)) != 0) {
|
||||
mError("failed to remove sdb file:%s since %s", pIter->name, tstrerror(ret));
|
||||
}
|
||||
taosMemoryFree(pIter->name);
|
||||
pIter->name = NULL;
|
||||
}
|
||||
|
|
|
@ -174,12 +174,12 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
|
|||
if (insertFp != NULL) {
|
||||
code = (*insertFp)(pSdb, pRow->pObj);
|
||||
if (code != 0) {
|
||||
if (terrno == 0) terrno = TSDB_CODE_MND_TRANS_UNKNOW_ERROR;
|
||||
code = terrno;
|
||||
(void)taosHashRemove(hash, pRow->pObj, keySize);
|
||||
if (taosHashRemove(hash, pRow->pObj, keySize) != 0) {
|
||||
mError("failed to remove row from hash");
|
||||
}
|
||||
sdbFreeRow(pSdb, pRow, false);
|
||||
terrno = code;
|
||||
sdbUnLock(pSdb, type);
|
||||
terrno = code;
|
||||
return terrno;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ int32_t sclConvertValueToSclParam(SValueNode *pValueNode, SScalarParam *out, int
|
|||
|
||||
code = colDataSetVal(in.columnData, 0, nodesGetValueFromNode(pValueNode), false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
goto _exit;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
code = colInfoDataEnsureCapacity(out->columnData, 1, true);
|
||||
|
@ -91,7 +91,7 @@ _exit:
|
|||
}
|
||||
|
||||
int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) {
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
||||
if (NULL == pb) {
|
||||
SCL_ERR_RET(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
@ -839,8 +839,8 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
|
|||
}
|
||||
|
||||
// 1=1 and tag_column = 1
|
||||
int32_t ind = (i >= params[m].numOfRows)? (params[m].numOfRows - 1):i;
|
||||
char* p = colDataGetData(params[m].columnData, ind);
|
||||
int32_t ind = (i >= params[m].numOfRows) ? (params[m].numOfRows - 1) : i;
|
||||
char *p = colDataGetData(params[m].columnData, ind);
|
||||
|
||||
GET_TYPED_DATA(value, bool, params[m].columnData->info.type, p);
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ _return:
|
|||
EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||
if (opType <= OP_TYPE_CALC_MAX) {
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -1041,7 +1041,7 @@ EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opTy
|
|||
*pNode = (SNode *)res;
|
||||
} else {
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
return DEAL_RES_ERROR;
|
||||
|
@ -1094,7 +1094,6 @@ static uint8_t sclGetOpValueNodeTsPrecision(SNode *pLeft, SNode *pRight) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t sclConvertOpValueNodeTs(SOperatorNode *node) {
|
||||
if (node->pLeft && SCL_IS_VAR_VALUE_NODE(node->pLeft)) {
|
||||
if (node->pRight && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pRight)->resType.type)) {
|
||||
|
@ -1105,13 +1104,12 @@ int32_t sclConvertOpValueNodeTs(SOperatorNode *node) {
|
|||
if (node->pLeft && (TSDB_DATA_TYPE_TIMESTAMP == ((SExprNode *)node->pLeft)->resType.type)) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(node->pRight)) {
|
||||
SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, node->pRight),
|
||||
(SValueNode *)node->pRight));
|
||||
(SValueNode *)node->pRight));
|
||||
} else if (QUERY_NODE_NODE_LIST == node->pRight->type) {
|
||||
SNode *pNode;
|
||||
FOREACH(pNode, ((SNodeListNode *)node->pRight)->pNodeList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(pNode)) {
|
||||
SCL_ERR_RET(
|
||||
sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode));
|
||||
SCL_ERR_RET(sclConvertToTsValueNode(sclGetOpValueNodeTsPrecision(node->pLeft, pNode), (SValueNode *)pNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1120,7 +1118,6 @@ int32_t sclConvertOpValueNodeTs(SOperatorNode *node) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node) {
|
||||
if (NULL == node->pCase) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -1140,7 +1137,7 @@ int32_t sclConvertCaseWhenValueNodeTs(SCaseWhenNode *node) {
|
|||
FOREACH(pNode, node->pWhenThenList) {
|
||||
if (SCL_IS_VAR_VALUE_NODE(((SWhenThenNode *)pNode)->pWhen)) {
|
||||
SCL_ERR_RET(sclConvertToTsValueNode(((SExprNode *)node->pCase)->resType.precision,
|
||||
(SValueNode *)((SWhenThenNode *)pNode)->pWhen));
|
||||
(SValueNode *)((SWhenThenNode *)pNode)->pWhen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1201,7 +1198,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
|
@ -1275,7 +1272,7 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
|
@ -1346,7 +1343,7 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
|
@ -1409,7 +1406,7 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
|||
}
|
||||
|
||||
SValueNode *res = NULL;
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&res);
|
||||
ctx->code = nodesMakeNode(QUERY_NODE_VALUE, (SNode **)&res);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
sclFreeParam(&output);
|
||||
|
@ -1426,7 +1423,8 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) {
|
|||
} else {
|
||||
int32_t type = output.columnData->info.type;
|
||||
if (IS_VAR_DATA_TYPE(type)) { // todo refactor
|
||||
res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1, sizeof(char)); // add \0 to the end for print json value
|
||||
res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1,
|
||||
sizeof(char)); // add \0 to the end for print json value
|
||||
if (NULL == res->datum.p) {
|
||||
sclError("calloc %d failed", (int)(varDataTLen(output.columnData->pData) + 1));
|
||||
sclFreeParam(&output);
|
||||
|
@ -1683,8 +1681,7 @@ static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) {
|
|||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
|
||||
if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) ||
|
||||
TSDB_DATA_TYPE_VARBINARY == ldt.type ||
|
||||
TSDB_DATA_TYPE_VARBINARY == rdt.type ||
|
||||
TSDB_DATA_TYPE_VARBINARY == ldt.type || TSDB_DATA_TYPE_VARBINARY == rdt.type ||
|
||||
(TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) ||
|
||||
(TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
@ -1720,13 +1717,14 @@ static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) {
|
|||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
if (ldt.type == TSDB_DATA_TYPE_VARBINARY || !IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
||||
if (ldt.type == TSDB_DATA_TYPE_VARBINARY || !IS_VAR_DATA_TYPE(ldt.type) ||
|
||||
QUERY_NODE_VALUE != nodeType(pOp->pRight) ||
|
||||
(!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
if (nodesIsMatchRegularOp(pOp)) {
|
||||
SValueNode* node = (SValueNode*)(pOp->pRight);
|
||||
if(checkRegexPattern(node->literal) != TSDB_CODE_SUCCESS){
|
||||
SValueNode *node = (SValueNode *)(pOp->pRight);
|
||||
if (!node->placeholderNo && nodesIsMatchRegularOp(pOp)) {
|
||||
if (checkRegexPattern(node->literal) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -1762,7 +1760,7 @@ static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) {
|
|||
}
|
||||
SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType;
|
||||
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
|
||||
if(TSDB_DATA_TYPE_VARBINARY == ldt.type || TSDB_DATA_TYPE_VARBINARY == rdt.type){
|
||||
if (TSDB_DATA_TYPE_VARBINARY == ldt.type || TSDB_DATA_TYPE_VARBINARY == rdt.type) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT;
|
||||
|
|
Loading…
Reference in New Issue