From a680183244d2ffcf2ec0f95f846558b0af30b494 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Wed, 9 Feb 2022 14:23:27 +0800 Subject: [PATCH] [TS-1132](query): V24->windows client query slowest fixed1 --- src/query/src/qExecutor.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index c4228c67ad..66ec044cc0 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3682,6 +3682,37 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *pInfo, i initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols); } +bool extendColCapacity(SColumnInfoData* pColInfo, int32_t newSize, SQLFunctionCtx* pCtx, int32_t *bufCapacity, bool extendLarge) { + char* p = NULL; + int32_t newCapacity = 0; + if (extendLarge) { + // doulbe newSize + newCapacity = newSize * 2; + p = realloc(pColInfo->pData, (size_t)newCapacity * pColInfo->info.bytes); + } + + if (p == NULL) { + // failed then newSize + newCapacity = newSize; + p = realloc(pColInfo->pData, (size_t)newCapacity * pColInfo->info.bytes); + if(p == NULL) { + taosMsleep(1000); + p = realloc(pColInfo->pData, (size_t)newCapacity * pColInfo->info.bytes); + qInfo("MEM realloc memory size %d failed, sleep 1s to try, p=%p", newSize * pColInfo->info.bytes, p); + } + } + + if (p != NULL) { + // save new pointer + pColInfo->pData = p; + pCtx->pOutput = p; + (*bufCapacity) = newCapacity; + return true; + } + + return false; +} + void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t *bufCapacity, int32_t numOfInputRows, SQueryRuntimeEnv* runtimeEnv, bool extendLarge) { SSDataBlock* pDataBlock = pBInfo->pRes; -- GitLab