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

fix(query): fix taosshell crash when arithmetic operation with NULL concstant
This commit is contained in:
Ganlin Zhao 2022-04-26 15:48:21 +08:00 committed by GitHub
commit e15d78e2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 41 deletions

View File

@ -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;
} }

View File

@ -597,9 +597,12 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
return DEAL_RES_ERROR; return DEAL_RES_ERROR;
} }
res->node.resType = node->node.resType;
res->translate = true; res->translate = true;
if (colDataIsNull_s(output.columnData, 0)) {
res->node.resType.type = TSDB_DATA_TYPE_NULL;
} else {
res->node.resType = node->node.resType;
int32_t type = output.columnData->info.type; int32_t type = output.columnData->info.type;
if (IS_VAR_DATA_TYPE(type)) { // todo refactor if (IS_VAR_DATA_TYPE(type)) { // todo refactor
res->datum.p = output.columnData->pData; res->datum.p = output.columnData->pData;
@ -607,6 +610,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
} else { } else {
memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes); memcpy(nodesGetValueFromNode(res), output.columnData->pData, tDataTypes[type].bytes);
} }
}
nodesDestroyNode(*pNode); nodesDestroyNode(*pNode);
*pNode = (SNode*)res; *pNode = (SNode*)res;

View File

@ -176,8 +176,10 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
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 if (srcType==TSDB_DATA_TYPE_NULL){
p = NULL;
} else { } else {
assert(0); ASSERT(0);
} }
return p; return p;
} }
@ -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;
} }
} }