From 566680c78e8759872054e4f7afd64ff78c4f6aa1 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Wed, 23 Dec 2020 08:15:22 +0000 Subject: [PATCH] [TD-2538]: crash when sql has limit & offset --- src/client/src/tscLocalMerge.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/src/tscLocalMerge.c b/src/client/src/tscLocalMerge.c index a99918975e..da763b9b0c 100644 --- a/src/client/src/tscLocalMerge.c +++ b/src/client/src/tscLocalMerge.c @@ -911,6 +911,13 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, } } + if (pRes->numOfRowsGroup >= pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) { + pRes->numOfRows = 0; + pBeforeFillData->num = 0; + pLocalReducer->discard = true; + return; + } + pRes->numOfRowsGroup += pRes->numOfRows; // impose the limitation of output rows on the final result -- GitLab