未验证 提交 e15d78e2 编写于 作者: G Ganlin Zhao 提交者: GitHub

Merge pull request #11881 from taosdata/fix/TD-15132

fix(query): fix taosshell crash when arithmetic operation with NULL concstant
...@@ -86,8 +86,10 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) ...@@ -86,8 +86,10 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType)
p = getVectorDoubleValue_JSON; p = getVectorDoubleValue_JSON;
} else if (srcType == TSDB_DATA_TYPE_BOOL) { } else if (srcType == TSDB_DATA_TYPE_BOOL) {
p = getVectorDoubleValue_BOOL; p = getVectorDoubleValue_BOOL;
} else if (srcType == TSDB_DATA_TYPE_NULL) {
p = NULL;
} else { } else {
assert(0); ASSERT(0);
} }
return p; return p;
} }
......
...@@ -591,21 +591,25 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { ...@@ -591,21 +591,25 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
if (NULL == res) { if (NULL == res) {
sclError("make value node failed"); sclError("make value node failed");
sclFreeParam(&output); sclFreeParam(&output);
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
} }
res->node.resType = node->node.resType;
res->translate = true; res->translate = true;
int32_t type = output.columnData->info.type; if (colDataIsNull_s(output.columnData, 0)) {
if (IS_VAR_DATA_TYPE(type)) { // todo refactor res->node.resType.type = TSDB_DATA_TYPE_NULL;
res->datum.p = output.columnData->pData;
output.columnData->pData = NULL;
} else { } else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); res->node.resType = node->node.resType;
int32_t type = output.columnData->info.type;
if (IS_VAR_DATA_TYPE(type)) { // todo refactor
res->datum.p = output.columnData->pData;
output.columnData->pData = NULL;
} else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes);
}
} }
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
...@@ -628,7 +632,7 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { ...@@ -628,7 +632,7 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { if (QUERY_NODE_OPERATOR == nodeType(*pNode)) {
return sclRewriteOperator(pNode, ctx); return sclRewriteOperator(pNode, ctx);
} }
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
...@@ -636,7 +640,7 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { ...@@ -636,7 +640,7 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
SFunctionNode *node = (SFunctionNode *)pNode; SFunctionNode *node = (SFunctionNode *)pNode;
SScalarParam output = {0}; SScalarParam output = {0};
ctx->code = sclExecFunction(node, ctx, &output); ctx->code = sclExecFunction(node, ctx, &output);
if (ctx->code) { if (ctx->code) {
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
...@@ -653,7 +657,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { ...@@ -653,7 +657,7 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) {
EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) { EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) {
SLogicConditionNode *node = (SLogicConditionNode *)pNode; SLogicConditionNode *node = (SLogicConditionNode *)pNode;
SScalarParam output = {0}; SScalarParam output = {0};
ctx->code = sclExecLogic(node, ctx, &output); ctx->code = sclExecLogic(node, ctx, &output);
if (ctx->code) { if (ctx->code) {
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
......
...@@ -150,34 +150,36 @@ int64_t getVectorBigintValue_JSON(void *src, int32_t index){ ...@@ -150,34 +150,36 @@ int64_t getVectorBigintValue_JSON(void *src, int32_t index){
_getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
_getBigintValue_fn_t p = NULL; _getBigintValue_fn_t p = NULL;
if(srcType==TSDB_DATA_TYPE_TINYINT) { if (srcType==TSDB_DATA_TYPE_TINYINT) {
p = getVectorBigintValue_TINYINT; p = getVectorBigintValue_TINYINT;
}else if(srcType==TSDB_DATA_TYPE_UTINYINT) { } else if (srcType==TSDB_DATA_TYPE_UTINYINT) {
p = getVectorBigintValue_UTINYINT; p = getVectorBigintValue_UTINYINT;
}else if(srcType==TSDB_DATA_TYPE_SMALLINT) { } else if (srcType==TSDB_DATA_TYPE_SMALLINT) {
p = getVectorBigintValue_SMALLINT; p = getVectorBigintValue_SMALLINT;
}else if(srcType==TSDB_DATA_TYPE_USMALLINT) { } else if (srcType==TSDB_DATA_TYPE_USMALLINT) {
p = getVectorBigintValue_USMALLINT; p = getVectorBigintValue_USMALLINT;
}else if(srcType==TSDB_DATA_TYPE_INT) { } else if (srcType==TSDB_DATA_TYPE_INT) {
p = getVectorBigintValue_INT; p = getVectorBigintValue_INT;
}else if(srcType==TSDB_DATA_TYPE_UINT) { } else if (srcType==TSDB_DATA_TYPE_UINT) {
p = getVectorBigintValue_UINT; p = getVectorBigintValue_UINT;
}else if(srcType==TSDB_DATA_TYPE_BIGINT) { } else if (srcType==TSDB_DATA_TYPE_BIGINT) {
p = getVectorBigintValue_BIGINT; p = getVectorBigintValue_BIGINT;
}else if(srcType==TSDB_DATA_TYPE_UBIGINT) { } else if (srcType==TSDB_DATA_TYPE_UBIGINT) {
p = getVectorBigintValue_UBIGINT; p = getVectorBigintValue_UBIGINT;
}else if(srcType==TSDB_DATA_TYPE_FLOAT) { } else if (srcType==TSDB_DATA_TYPE_FLOAT) {
p = getVectorBigintValue_FLOAT; p = getVectorBigintValue_FLOAT;
}else if(srcType==TSDB_DATA_TYPE_DOUBLE) { } else if (srcType==TSDB_DATA_TYPE_DOUBLE) {
p = getVectorBigintValue_DOUBLE; p = getVectorBigintValue_DOUBLE;
}else if(srcType==TSDB_DATA_TYPE_TIMESTAMP) { } else if (srcType==TSDB_DATA_TYPE_TIMESTAMP) {
p = getVectorBigintValue_BIGINT; p = getVectorBigintValue_BIGINT;
}else if(srcType==TSDB_DATA_TYPE_BOOL) { } else if (srcType==TSDB_DATA_TYPE_BOOL) {
p = getVectorBigintValue_BOOL; p = getVectorBigintValue_BOOL;
}else if(srcType==TSDB_DATA_TYPE_JSON) { } else if (srcType==TSDB_DATA_TYPE_JSON) {
p = getVectorBigintValue_JSON; p = getVectorBigintValue_JSON;
}else { } else if (srcType==TSDB_DATA_TYPE_NULL){
assert(0); p = NULL;
} else {
ASSERT(0);
} }
return p; return p;
} }
...@@ -1594,7 +1596,7 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { ...@@ -1594,7 +1596,7 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
case OP_TYPE_JSON_CONTAINS: case OP_TYPE_JSON_CONTAINS:
return vectorJsonContains; return vectorJsonContains;
default: default:
assert(0); ASSERT(0);
return NULL; return NULL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册