diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 38f46b9b11..77138c9a5f 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -320,7 +320,9 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p memcpy(pColumnInfoData->pData, pSource->pData, pSource->varmeta.length); } else { memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows)); - memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows); + if (pSource->pData) { + memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows); + } } pColumnInfoData->hasNull = pSource->hasNull; diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index dd55894266..e610fcb62e 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -729,6 +729,7 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { if (colDataIsNull_s(output.columnData, 0)) { res->node.resType.type = TSDB_DATA_TYPE_NULL; + res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; } else { res->node.resType.type = output.columnData->info.type; res->node.resType.bytes = output.columnData->info.bytes; @@ -819,6 +820,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { if (colDataIsNull_s(output.columnData, 0)) { if(node->node.resType.type != TSDB_DATA_TYPE_JSON){ res->node.resType.type = TSDB_DATA_TYPE_NULL; + res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes; }else{ res->node.resType = node->node.resType; res->isNull = true; diff --git a/tests/script/tsim/query/scalarNull.sim b/tests/script/tsim/query/scalarNull.sim index 07bd5e57cd..ae4b2a9624 100644 --- a/tests/script/tsim/query/scalarNull.sim +++ b/tests/script/tsim/query/scalarNull.sim @@ -89,5 +89,10 @@ endi #TODO: MOVE IT TO NORMAL CASE sql_error select * from tb1 where not (null); +sql select sum(1/0) from tb1; +if $rows != 1 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT