Merge pull request #27694 from taosdata/fix/TD-31931
fix(stmt/scalar): no regex checking for stmt placeholder
This commit is contained in:
commit
f1a051a83e
|
@ -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