mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Fix long-standing bugs with the handling of LIMIT clausing in
compound SELECT statements with FROM clause subqueries. Ticket [38cb5df375078d3f9]. FossilOrigin-Name: b0450120eabfe5455cea1ed04cec587a5540b6b7
This commit is contained in:
14
src/select.c
14
src/select.c
@@ -442,7 +442,6 @@ static void pushOntoSorter(
|
||||
sqlite3VdbeAddOp1(v, OP_Last, pOrderBy->iECursor);
|
||||
sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy->iECursor);
|
||||
sqlite3VdbeJumpHere(v, addr2);
|
||||
pSelect->iLimit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,11 +720,11 @@ static void selectInnerLoop(
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Jump to the end of the loop if the LIMIT is reached.
|
||||
/* Jump to the end of the loop if the LIMIT is reached. Except, if
|
||||
** there is a sorter, in which case the sorter has already limited
|
||||
** the output for us.
|
||||
*/
|
||||
if( p->iLimit ){
|
||||
assert( pOrderBy==0 ); /* If there is an ORDER BY, the call to
|
||||
** pushOntoSorter() would have cleared p->iLimit */
|
||||
if( pOrderBy==0 && p->iLimit ){
|
||||
sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);
|
||||
}
|
||||
}
|
||||
@@ -860,10 +859,6 @@ static void generateSortTail(
|
||||
sqlite3ReleaseTempReg(pParse, regRow);
|
||||
sqlite3ReleaseTempReg(pParse, regRowid);
|
||||
|
||||
/* LIMIT has been implemented by the pushOntoSorter() routine.
|
||||
*/
|
||||
assert( p->iLimit==0 );
|
||||
|
||||
/* The bottom of the loop
|
||||
*/
|
||||
sqlite3VdbeResolveLabel(v, addrContinue);
|
||||
@@ -2181,7 +2176,6 @@ static int multiSelectOrderBy(
|
||||
/* Separate the left and the right query from one another
|
||||
*/
|
||||
p->pPrior = 0;
|
||||
pPrior->pRightmost = 0;
|
||||
sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER");
|
||||
if( pPrior->pPrior==0 ){
|
||||
sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
|
||||
|
||||
Reference in New Issue
Block a user