diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index a461ceef2a..082e824e5a 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -152,7 +152,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, * @return */ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, - int32_t* tversion, int32_t idx); + int32_t* tversion, int32_t idx, bool* tbGet); /** * The main task execution function, including query on both table and multiple tables, diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index c0d089e7c2..4aff0e69a3 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -479,12 +479,14 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI } int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion, - int32_t* tversion, int32_t idx) { + int32_t* tversion, int32_t idx, bool* tbGet) { + *tbGet = false; + ASSERT(tinfo != NULL && dbName != NULL && tableName != NULL); SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; if (taosArrayGetSize(pTaskInfo->schemaInfos) <= idx) { - return -1; + return TSDB_CODE_SUCCESS; } SSchemaInfo* pSchemaInfo = taosArrayGet(pTaskInfo->schemaInfos, idx); @@ -502,6 +504,8 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table tableName[0] = 0; } + *tbGet = true; + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index 619e2576cd..06559093a8 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -509,10 +509,12 @@ int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) { STbVerInfo tbInfo; int32_t i = 0; int32_t code = TSDB_CODE_SUCCESS; + bool tbGet = false; while (true) { - code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, tbName, &tbInfo.sversion, &tbInfo.tversion, i); - if (TSDB_CODE_SUCCESS != code) { + tbGet = false; + code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, tbName, &tbInfo.sversion, &tbInfo.tversion, i, &tbGet); + if (TSDB_CODE_SUCCESS != code || !tbGet) { break; }