From bf077578e80f3b841dcec631c4918dfd67f5851b Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 18 Feb 2021 10:13:41 +0800 Subject: [PATCH 1/3] fix bug --- src/query/src/qAggMain.c | 2 +- src/query/src/qExecutor.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index fb8b2394f2..fe0fc666d7 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2488,7 +2488,7 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) { static bool top_bottom_function_setup(SQLFunctionCtx *pCtx) { if (!function_setup(pCtx)) { - return false; + //return false; } STopBotInfo *pInfo = getTopBotOutputInfo(pCtx); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 72ae0d566c..7d4f60d4ef 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3786,7 +3786,7 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].pOutput; } - if (!pCtx->resultInfo->initialized) { + if (!pCtx->resultInfo->initialized || functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { aAggs[functionId].init(pCtx); } } From ec041953a3c209831fb73143cbc861177130cfbc Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 18 Feb 2021 10:35:56 +0800 Subject: [PATCH 2/3] fix bug --- src/query/src/qAggMain.c | 11 ++++++++++- src/query/src/qExecutor.c | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index fe0fc666d7..cc4b8d285c 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2488,7 +2488,7 @@ static void buildTopBotStruct(STopBotInfo *pTopBotInfo, SQLFunctionCtx *pCtx) { static bool top_bottom_function_setup(SQLFunctionCtx *pCtx) { if (!function_setup(pCtx)) { - //return false; + return false; } STopBotInfo *pInfo = getTopBotOutputInfo(pCtx); @@ -2573,6 +2573,10 @@ static void bottom_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; STopBotInfo *pRes = getTopBotOutputInfo(pCtx); + + if (pRes->res[0] != ((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { + buildTopBotStruct(pRes, pCtx); + } for (int32_t i = 0; i < pCtx->size; ++i) { char *data = GET_INPUT_DATA(pCtx, i); @@ -2608,6 +2612,11 @@ static void bottom_function_f(SQLFunctionCtx *pCtx, int32_t index) { } STopBotInfo *pRes = getTopBotOutputInfo(pCtx); + + if (pRes->res[0] != ((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { + buildTopBotStruct(pRes, pCtx); + } + SET_VAL(pCtx, 1, 1); do_bottom_function_add(pRes, (int32_t)pCtx->param[0].i64, pData, ts, pCtx->inputType, &pCtx->tagInfo, NULL, 0); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 7d4f60d4ef..ec1c2fdb6e 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -3785,8 +3785,8 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) { pCtx->ptsOutputBuf = pRuntimeEnv->pCtx[0].pOutput; } - - if (!pCtx->resultInfo->initialized || functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM) { + + if (!pCtx->resultInfo->initialized) { aAggs[functionId].init(pCtx); } } From 768cfd45873a3127134975c571fea53bb13e159b Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Thu, 18 Feb 2021 10:46:11 +0800 Subject: [PATCH 3/3] fix bug --- src/query/src/qAggMain.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index cc4b8d285c..f7c7f9ddc0 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2573,8 +2573,8 @@ static void bottom_function(SQLFunctionCtx *pCtx) { int32_t notNullElems = 0; STopBotInfo *pRes = getTopBotOutputInfo(pCtx); - - if (pRes->res[0] != ((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { + + if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { buildTopBotStruct(pRes, pCtx); } @@ -2583,7 +2583,7 @@ static void bottom_function(SQLFunctionCtx *pCtx) { TSKEY ts = GET_TS_DATA(pCtx, i); if (pCtx->hasNull && isNull(data, pCtx->inputType)) { - continue; + continue; } notNullElems++; @@ -2613,7 +2613,7 @@ static void bottom_function_f(SQLFunctionCtx *pCtx, int32_t index) { STopBotInfo *pRes = getTopBotOutputInfo(pCtx); - if (pRes->res[0] != ((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { + if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotInfo) + POINTER_BYTES * pCtx->param[0].i64)) { buildTopBotStruct(pRes, pCtx); }