From 8e42bf85e899400cecfd2ad4c1a1fe53a5c0c10e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 21 Jul 2022 15:47:22 +0800 Subject: [PATCH] fix(query): fix border check. --- source/common/src/tdatablock.c | 4 ++++ source/dnode/vnode/src/tsdb/tsdbRead.c | 3 +-- source/libs/executor/src/executorMain.c | 4 ++++ source/libs/executor/src/executorimpl.c | 29 +++++++++++++++---------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index c674728fe6..136d86dac4 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1163,9 +1163,13 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) { if (IS_VAR_DATA_TYPE(pColumn->info.type)) { pColumn->varmeta.length = 0; + if (pColumn->varmeta.offset > 0) { + memset(pColumn->varmeta.offset, 0, sizeof(int32_t) * numOfRows); + } } else { if (pColumn->nullbitmap != NULL) { memset(pColumn->nullbitmap, 0, BitmapLen(numOfRows)); + memset(pColumn->pData, 0, pColumn->info.bytes * numOfRows); } } } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 0e557d9fa0..bad1037123 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2539,8 +2539,7 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn pDumpInfo->rowIndex = doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->verRange, step); - - if (pDumpInfo->rowIndex >= pBlock->nRow) { + if (pDumpInfo->rowIndex >= pDumpInfo->totalRows) { *state = CHECK_FILEBLOCK_CONT; } } diff --git a/source/libs/executor/src/executorMain.c b/source/libs/executor/src/executorMain.c index c3efbf9336..e0020a496e 100644 --- a/source/libs/executor/src/executorMain.c +++ b/source/libs/executor/src/executorMain.c @@ -199,6 +199,10 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) { void qDestroyTask(qTaskInfo_t qTaskHandle) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qTaskHandle; + if (pTaskInfo == NULL) { + return; + } + qDebug("%s execTask completed, numOfRows:%" PRId64, GET_TASKID(pTaskInfo), pTaskInfo->pRoot->resultInfo.totalRows); queryCostStatis(pTaskInfo); // print the query cost summary diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 1924275be3..08f63a17db 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4145,11 +4145,16 @@ static STsdbReader* doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRea static SArray* extractColumnInfo(SNodeList* pNodeList); +SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); + int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) { SMetaReader mr = {0}; metaReaderInit(&mr, pHandle->meta, 0); int32_t code = metaGetTableEntryByUid(&mr, pScanNode->uid); if (code != TSDB_CODE_SUCCESS) { + qError("failed to get the table meta, uid:0x%"PRIx64", suid:0x%"PRIx64 ", %s", pScanNode->uid, pScanNode->suid, + GET_TASKID(pTaskInfo)); + metaReaderClear(&mr); return terrno; } @@ -4173,25 +4178,27 @@ int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, metaReaderClear(&mr); + pSchemaInfo->qsw = extractQueriedColumnSchema(pScanNode); + return TSDB_CODE_SUCCESS; +} + +SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode) { int32_t numOfCols = LIST_LENGTH(pScanNode->pScanCols); SSchemaWrapper* pqSw = taosMemoryCalloc(1, sizeof(SSchemaWrapper)); pqSw->pSchema = taosMemoryCalloc(numOfCols, sizeof(SSchema)); - pqSw->version = pSchemaInfo->sw->version; for(int32_t i = 0; i < numOfCols; ++i) { - STargetNode* pNode = (STargetNode*) nodesListGetNode(pScanNode->pScanCols, i); + STargetNode* pNode = (STargetNode*)nodesListGetNode(pScanNode->pScanCols, i); SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; - for(int32_t j = 0; j < pSchemaInfo->sw->nCols; ++j) { - if (pColNode->colId == pSchemaInfo->sw->pSchema[j].colId) { - pqSw->pSchema[pqSw->nCols++] = pSchemaInfo->sw->pSchema[j]; - break; - } - } + SSchema* pSchema = &pqSw->pSchema[pqSw->nCols++]; + pSchema->colId = pColNode->colId; + pSchema->type = pColNode->node.resType.type; + pSchema->type = pColNode->node.resType.bytes; + strncpy(pSchema->name, pColNode->colName, tListLen(pSchema->name)); } - pSchemaInfo->qsw = pqSw; - return TSDB_CODE_SUCCESS; + return pqSw; } static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) { @@ -4449,7 +4456,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } } - extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); + pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); SOperatorInfo* pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); return pOperator;