From 45c34553db93a4c4bbe1ad6b9051ac342cb57920 Mon Sep 17 00:00:00 2001 From: Alexey Antipovsky Date: Wed, 16 Dec 2020 18:50:21 +0300 Subject: [PATCH] MCOL-4453 Fix `SELECT ... LIMIT 0`, now it returns an empty set as expected --- dbcon/joblist/tupleannexstep.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/dbcon/joblist/tupleannexstep.cpp b/dbcon/joblist/tupleannexstep.cpp index 37994ff00..6861681a5 100644 --- a/dbcon/joblist/tupleannexstep.cpp +++ b/dbcon/joblist/tupleannexstep.cpp @@ -429,6 +429,13 @@ void TupleAnnexStep::executeNoOrderBy() continue; } + if (UNLIKELY(fRowsReturned >= fLimitCount)) + { + fLimitHit = true; + fJobList->abortOnLimit((JobStep*) this); + continue; + } + if (fConstant) fConstant->fillInConstants(fRowIn, fRowOut); else @@ -441,11 +448,6 @@ void TupleAnnexStep::executeNoOrderBy() fRowOut.nextRow(); fRowIn.nextRow(); } - else - { - fLimitHit = true; - fJobList->abortOnLimit((JobStep*) this); - } } if (fRowGroupOut.getRowCount() > 0) @@ -523,15 +525,17 @@ void TupleAnnexStep::executeNoOrderByWithDistinct() if (inserted.second) { - fRowGroupOut.incRowCount(); - fRowOut.nextRow(); - - if (UNLIKELY(++fRowsReturned >= fLimitCount)) + if (UNLIKELY(fRowsReturned >= fLimitCount)) { fLimitHit = true; fJobList->abortOnLimit((JobStep*) this); + continue; } + ++fRowsReturned; + fRowGroupOut.incRowCount(); + fRowOut.nextRow(); + if (UNLIKELY(fRowGroupOut.getRowCount() >= rowgroup::rgCommonSize)) { dataVec.push_back(rgDataOut);