From 2d27248043d6b598cece1a1479ef3f4fc1c5e869 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 5 Jul 2022 18:02:38 +0800 Subject: [PATCH 1/2] fix(query): set number of rows before assign column data. --- source/libs/executor/src/scanoperator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 061b4ab3c5..4512ca1a78 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1748,8 +1748,8 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) { getPerfDbMeta(&pSysDbTableMeta, &size); p->info.rows = buildDbTableInfoBlock(p, pSysDbTableMeta, size, TSDB_PERFORMANCE_SCHEMA_DB); - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); pInfo->pRes->info.rows = p->info.rows; + relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); blockDataDestroy(p); return pInfo->pRes->info.rows; From 0f595e8be1f3909bc538e386740c1200490d60cd Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 5 Jul 2022 19:09:00 +0800 Subject: [PATCH 2/2] refactor: do some internal refactor. --- source/client/src/clientImpl.c | 1 - source/client/src/clientMain.c | 5 ++--- source/libs/command/src/command.c | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index ff0c2df25e..0fe4274091 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -279,7 +279,6 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { } pRequest->body.queryFp(pRequest->body.param, pRequest, code); - // pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows); } int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 136ee34950..a30d60a589 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -665,8 +665,6 @@ static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) { } void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { - tscDebug("enter meta callback, code %s", tstrerror(code)); - SqlParseWrapper *pWrapper = (SqlParseWrapper *)param; SQuery * pQuery = pWrapper->pQuery; SRequestObj * pRequest = pWrapper->pRequest; @@ -686,10 +684,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { TSWAP(pRequest->tableList, (pQuery)->pTableList); destorySqlParseWrapper(pWrapper); + + tscDebug("0x%"PRIx64" analysis semantics completed, start async query, reqId:0x%"PRIx64, pRequest->self, pRequest->requestId); launchAsyncQuery(pRequest, pQuery, pResultMeta); } else { destorySqlParseWrapper(pWrapper); - tscDebug("error happens, code:%d", code); if (NEED_CLIENT_HANDLE_ERROR(code)) { tscDebug("0x%" PRIx64 " client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self, code, tstrerror(code), pRequest->retry, pRequest->requestId); diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index cd454c075b..fc3e3cbc8a 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -548,19 +548,17 @@ static int32_t execShowLocalVariables(SRetrieveTableRsp** pRsp) { } static int32_t createSelectResultDataBlock(SNodeList* pProjects, SSDataBlock** pOutput) { - SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + SSDataBlock* pBlock = createDataBlock(); if (NULL == pBlock) { return TSDB_CODE_OUT_OF_MEMORY; } - pBlock->pDataBlock = taosArrayInit(LIST_LENGTH(pProjects), sizeof(SColumnInfoData)); - SNode* pProj = NULL; FOREACH(pProj, pProjects) { SColumnInfoData infoData = {0}; infoData.info.type = ((SExprNode*)pProj)->resType.type; infoData.info.bytes = ((SExprNode*)pProj)->resType.bytes; - taosArrayPush(pBlock->pDataBlock, &infoData); + blockDataAppendColInfo(pBlock, &infoData); } *pOutput = pBlock; return TSDB_CODE_SUCCESS;