From 86f935d4b09da6614e03f1cf1f67dd6b2aef2818 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 22 Jun 2021 14:48:21 +0800 Subject: [PATCH] [td-225] --- src/query/src/qAggMain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 85b4cb5e8f..8efc4aad4c 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -2675,6 +2675,8 @@ static void col_project_function(SQLFunctionCtx *pCtx) { if (pCtx->numOfParams == 2) { return; } + + // only one row is required. if (pCtx->param[0].i64 == 1) { SET_VAL(pCtx, pCtx->size, 1); } else { @@ -2683,7 +2685,8 @@ static void col_project_function(SQLFunctionCtx *pCtx) { char *pData = GET_INPUT_DATA_LIST(pCtx); if (pCtx->order == TSDB_ORDER_ASC) { - memcpy(pCtx->pOutput, pData, (size_t) pCtx->size * pCtx->inputBytes); + int32_t numOfRows = (pCtx->param[0].i64 == 1)? 1:pCtx->size; + memcpy(pCtx->pOutput, pData, (size_t) numOfRows * pCtx->inputBytes); } else { for(int32_t i = 0; i < pCtx->size; ++i) { memcpy(pCtx->pOutput + (pCtx->size - 1 - i) * pCtx->inputBytes, pData + i * pCtx->inputBytes, -- GitLab