1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Make sure the ORDER BY LIMIT optimization is not applied if the inner-most

loop can only have a single iteration and is hence not really a loop.

FossilOrigin-Name: 13e3bd3de6b434b6182ef36be108d7ee0be8ca53
This commit is contained in:
drh
2016-08-04 09:09:44 +00:00
parent c0d269e96c
commit dd545d3bf2
4 changed files with 31 additions and 9 deletions

View File

@@ -3971,7 +3971,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
pWInfo->revMask = pFrom->revLoop;
if( pWInfo->nOBSat<=0 ){
pWInfo->nOBSat = 0;
if( nLoop>0 ){
if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){
Bitmask m = 0;
int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,
WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);