From eb7f510ccbfcbe3e92ca90c70a2c91e004642c4a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 17 Apr 2023 10:59:24 +0800 Subject: [PATCH] fix(query): return correct suid to delete sink. --- include/libs/executor/dataSinkMgt.h | 1 - source/libs/executor/src/executil.c | 18 +++++++++++++----- source/libs/executor/src/executor.c | 9 ++++----- source/libs/executor/src/scanoperator.c | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index ed7cbc8125..ce7d038d42 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -29,7 +29,6 @@ extern "C" { #define DS_BUF_FULL 2 #define DS_BUF_EMPTY 3 -struct SDataSink; struct SSDataBlock; typedef struct SDeleterRes { diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 33698522cd..af68cd5990 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -35,8 +35,11 @@ struct STableListInfo { int32_t* groupOffset; // keep the offset value for each group in the tableList SArray* pTableList; SHashObj* map; // speedup acquire the tableQueryInfo by table uid - uint64_t suid; - int32_t tableType; // queried table type + union { + uint64_t suid; + uint64_t uid; + }; // this maybe the super table or ordinary table + int32_t tableType; // queried table type }; typedef struct tagFilterAssist { @@ -1033,8 +1036,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SIdxFltStatus status = SFLT_NOT_INDEX; if (pScanNode->tableType != TSDB_SUPER_TABLE) { - pListInfo->suid = pScanNode->uid; - + pListInfo->uid = pScanNode->uid; if (metaIsTableExist(metaHandle, pScanNode->uid)) { taosArrayPush(pUidList, &pScanNode->uid); } @@ -1798,7 +1800,13 @@ uint64_t tableListGetSize(const STableListInfo* pTableList) { return taosArrayGetSize(pTableList->pTableList); } -uint64_t tableListGetSuid(const STableListInfo* pTableList) { return pTableList->suid; } +uint64_t tableListGetSuid(const STableListInfo* pTableList) { + if (pTableList->tableType == TSDB_SUPER_TABLE) { + return pTableList->suid; + } else { // query normal table, no suid exists. + return 0; + } +} STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index) { if (taosArrayGetSize(pTableList->pTableList) == 0) { diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 6b6ee931ba..33697a4033 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -330,10 +330,9 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S STableScanInfo* pTableScanInfo = pScanInfo->pTableScanOp->info; - uint64_t suid = 0; + uint64_t uid = 0; int32_t type = 0; - tableListGetSourceTableInfo(pTableScanInfo->base.pTableListInfo, &suid, &type); - int32_t numOfExisted = tableListGetSize(pTableScanInfo->base.pTableListInfo); + tableListGetSourceTableInfo(pTableScanInfo->base.pTableListInfo, &uid, &type); // let's discard the tables those are not created according to the queried super table. SMetaReader mr = {0}; @@ -354,13 +353,13 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S } else { if (type == TSDB_SUPER_TABLE) { // this new created child table does not belong to the scanned super table. - if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != suid) { + if (mr.me.type != TSDB_CHILD_TABLE || mr.me.ctbEntry.suid != uid) { continue; } } else { // ordinary table // In case that the scanned target table is an ordinary table. When replay the WAL during restore the vnode, we // should check all newly created ordinary table to make sure that this table isn't the destination table. - if (mr.me.uid != suid) { + if (mr.me.uid != uid) { continue; } } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 52c04aecd8..2389c7252e 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -690,7 +690,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { } uint32_t status = 0; - int32_t code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); + code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); }