From b75adfcd9fc6ff046265b50c6059485c1ba2b581 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 5 Sep 2024 14:18:13 +0800 Subject: [PATCH] fix: only query issue --- include/libs/parser/parser.h | 3 +++ source/client/inc/clientInt.h | 1 + source/client/src/clientImpl.c | 14 ++++++++++++-- source/libs/parser/src/parTranslater.c | 8 ++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index cefce8a9c0..a808fccc4a 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -65,6 +65,8 @@ typedef struct SParseCsvCxt { const char* pLastSqlPos; // the location of the last parsed sql } SParseCsvCxt; +typedef void(*setQueryFn)(int64_t); + typedef struct SParseContext { uint64_t requestId; int64_t requestRid; @@ -98,6 +100,7 @@ typedef struct SParseContext { void* parseSqlParam; int8_t biMode; SArray* pSubMetaList; + setQueryFn setQueryFp; } SParseContext; int32_t qParseSql(SParseContext* pCxt, SQuery** pQuery); diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0df1a7428d..cf62ad73b4 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -284,6 +284,7 @@ typedef struct SRequestObj { bool isSubReq; bool inCallback; bool isStmtBind; // is statement bind parameter + bool isQuery; uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog uint32_t retry; int64_t allocatorRefId; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 332191a938..e2f6eb5ff4 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -31,6 +31,15 @@ static int32_t initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet); static int32_t buildConnectMsg(SRequestObj* pRequest, SMsgSendInfo** pMsgSendInfo); +void setQueryRequest(int64_t rId) { + SRequestObj* pReq = acquireRequest(rId); + if (pReq != NULL) { + pReq->isQuery = true; + (void)releaseRequest(rId); + } + +} + static bool stringLengthCheck(const char* str, size_t maxsize) { if (str == NULL) { return false; @@ -286,7 +295,8 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC .enableSysInfo = pTscObj->sysInfo, .svrVer = pTscObj->sVer, .nodeOffline = (pTscObj->pAppInfo->onlineDnodes < pTscObj->pAppInfo->totalDnodes), - .isStmtBind = pRequest->isStmtBind}; + .isStmtBind = pRequest->isStmtBind, + .setQueryFp = setQueryRequest}; cxt.mgmtEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); int32_t code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &cxt.pCatalog); @@ -2953,7 +2963,7 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param void doRequestCallback(SRequestObj* pRequest, int32_t code) { pRequest->inCallback = true; int64_t this = pRequest->self; - if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { + if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { code = TSDB_CODE_SUCCESS; pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index e864a2b1eb..62943cb6d5 100755 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -6784,6 +6784,10 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect } static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) { + (*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid); + } + if (NULL == pSelect->pFromTable) { return translateSelectWithoutFrom(pCxt, pSelect); } else { @@ -6908,6 +6912,10 @@ static int32_t checkSetOperLimit(STranslateContext* pCxt, SLimitNode* pLimit) { } static int32_t translateSetOperator(STranslateContext* pCxt, SSetOperator* pSetOperator) { + if (pCxt->pParseCxt && pCxt->pParseCxt->setQueryFp) { + (*pCxt->pParseCxt->setQueryFp)(pCxt->pParseCxt->requestRid); + } + int32_t code = translateQuery(pCxt, pSetOperator->pLeft); if (TSDB_CODE_SUCCESS == code) { code = resetHighLevelTranslateNamespace(pCxt);