From 1c08688da20f62594ee145ae0643607b3d6935f2 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 27 Apr 2022 18:12:26 +0800 Subject: [PATCH] fix(query): return object instead of free it when error happens. --- source/client/src/clientImpl.c | 7 +++---- source/libs/executor/src/executorimpl.c | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c41400f439..c3868ee6d5 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -365,9 +365,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) { code = parseSql(pRequest, false, &pQuery, NULL); if (code != TSDB_CODE_SUCCESS) { - destroyRequest(pRequest); - terrno = code; - return NULL; + pRequest->code = code; + return pRequest; } return launchQueryImpl(pRequest, pQuery, code, false); @@ -418,7 +417,7 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) { while (retryNum++ < REQUEST_MAX_TRY_TIMES) { pRequest = launchQuery(pTscObj, sql, sqlLen); - if (TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) { + if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) { break; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 85dfa4c866..76d06accf4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4997,6 +4997,7 @@ static int32_t handleLimitOffset(SOperatorInfo* pOperator, SSDataBlock* pBlock) // check for the limitation in each group if (pProjectInfo->limit.limit > 0 && pProjectInfo->curOutput + pRes->info.rows >= pProjectInfo->limit.limit) { pRes->info.rows = (int32_t)(pProjectInfo->limit.limit - pProjectInfo->curOutput); + return PROJECT_RETRIEVE_DONE; } if (pRes->info.rows >= pOperator->resultInfo.threshold) {