Merge pull request #4685 from taosdata/bugfix/td-2538

[TD-2538]<fix>: crash when sql has limit & offset
This commit is contained in:
haojun Liao 2020-12-24 10:45:42 +08:00 committed by GitHub
commit 87b3f29206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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; pRes->numOfRowsGroup += pRes->numOfRows;
// impose the limitation of output rows on the final result // impose the limitation of output rows on the final result