From 324eecdd998d9527d83f98f32678bc3a8abc7047 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 22 Jun 2022 20:24:26 +0800 Subject: [PATCH] fix(query): prepare the buffer before assigning result. --- source/common/src/tdatablock.c | 4 +++- source/libs/scalar/src/scalar.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 5d6dde04ca..57d75770cf 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -299,7 +299,9 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p return numOfRows; } - ASSERT(pBlockInfo->capacity >= numOfRows); + if (pBlockInfo != NULL) { + ASSERT(pBlockInfo->capacity >= numOfRows); + } if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { memcpy(pColumnInfoData->varmeta.offset, pSource->varmeta.offset, sizeof(int32_t) * numOfRows); diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 9890cff6f2..75a9bc3809 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -982,7 +982,8 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { sclError("no valid res in hash, node:%p, type:%d", pNode, nodeType(pNode)); SCL_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + + colInfoDataEnsureCapacity(pDst->columnData, res->numOfRows); colDataAssign(pDst->columnData, res->columnData, res->numOfRows, NULL); pDst->numOfRows = res->numOfRows; taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES);