提交 2d82d156 编写于 作者: S shenglian zhou

fix row tags pointer error

上级 8a7d384b
...@@ -4691,10 +4691,12 @@ static void assignResultSample(SQLFunctionCtx *pCtx, SSampleFuncInfo *pInfo, int ...@@ -4691,10 +4691,12 @@ static void assignResultSample(SQLFunctionCtx *pCtx, SSampleFuncInfo *pInfo, int
SExtTagsInfo* pTagInfo = &pCtx->tagInfo; SExtTagsInfo* pTagInfo = &pCtx->tagInfo;
int32_t posTag = 0; int32_t posTag = 0;
char* tags = pInfo->taglists + pTagInfo->tagsLen; char* tags = pInfo->taglists + index*pTagInfo->tagsLen;
if (pCtx->currentStage == MERGE_STAGE) { if (pCtx->currentStage == MERGE_STAGE) {
assert(inputTags != NULL);
memcpy(tags, inputTags, (size_t)pTagInfo->tagsLen); memcpy(tags, inputTags, (size_t)pTagInfo->tagsLen);
} else { } else {
assert(inputTags == NULL);
for (int32_t i = 0; i < pTagInfo->numOfTagCols; ++i) { for (int32_t i = 0; i < pTagInfo->numOfTagCols; ++i) {
SQLFunctionCtx* ctx = pTagInfo->pTagCtxList[i]; SQLFunctionCtx* ctx = pTagInfo->pTagCtxList[i];
if (ctx->functionId == TSDB_FUNC_TS_DUMMY) { if (ctx->functionId == TSDB_FUNC_TS_DUMMY) {
...@@ -4734,21 +4736,21 @@ static void copySampleFuncRes(SQLFunctionCtx *pCtx, int32_t type) { ...@@ -4734,21 +4736,21 @@ static void copySampleFuncRes(SQLFunctionCtx *pCtx, int32_t type) {
pTimestamp++; pTimestamp++;
} }
char **pData = calloc(pCtx->tagInfo.numOfTagCols, POINTER_BYTES); char **tagOutputs = calloc(pCtx->tagInfo.numOfTagCols, POINTER_BYTES);
for (int32_t i = 0; i < pCtx->tagInfo.numOfTagCols; ++i) { for (int32_t i = 0; i < pCtx->tagInfo.numOfTagCols; ++i) {
pData[i] = pCtx->tagInfo.pTagCtxList[i]->pOutput; tagOutputs[i] = pCtx->tagInfo.pTagCtxList[i]->pOutput;
} }
for (int32_t i = 0; i < pRes->numSampled; ++i) { for (int32_t i = 0; i < pRes->numSampled; ++i) {
int16_t tagOffset = 0; int16_t tagOffset = 0;
for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) { for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) {
memcpy(pData[j], pRes->taglists + i*pCtx->tagInfo.tagsLen + tagOffset, (size_t)pCtx->tagInfo.pTagCtxList[j]->outputBytes); memcpy(tagOutputs[j], pRes->taglists + i*pCtx->tagInfo.tagsLen + tagOffset, (size_t)pCtx->tagInfo.pTagCtxList[j]->outputBytes);
tagOffset += pCtx->tagInfo.pTagCtxList[j]->outputBytes; tagOffset += pCtx->tagInfo.pTagCtxList[j]->outputBytes;
pData[j] += pCtx->tagInfo.pTagCtxList[j]->outputBytes; tagOutputs[j] += pCtx->tagInfo.pTagCtxList[j]->outputBytes;
} }
} }
tfree(pData); tfree(tagOutputs);
} }
static bool sample_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResInfo) { static bool sample_function_setup(SQLFunctionCtx *pCtx, SResultRowCellInfo* pResInfo) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册