mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
More lenient handling of ORDER BY optimization in joins with mixed ASC/DESC.
This is a better and less restrictive fix for the problem addressed by the previous check-in. FossilOrigin-Name: abcf6a5d054559ee5a093ba39180c47b4958d9cd
This commit is contained in:
@@ -2736,9 +2736,7 @@ static int isOrderedColumn(WhereBestIdx *p, int iTab, int iCol, int *pbRev){
|
||||
sortOrder = 0;
|
||||
testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );
|
||||
}else{
|
||||
int n = pLevel->plan.nOBSat;
|
||||
if( p->i>=2 ) n -= pLevel[-1].plan.nOBSat;
|
||||
assert( n<=pIdx->nColumn );
|
||||
int n = pIdx->nColumn;
|
||||
for(j=0; j<n; j++){
|
||||
if( iCol==pIdx->aiColumn[j] ) break;
|
||||
}
|
||||
@@ -2840,7 +2838,7 @@ static int isSortingIndex(
|
||||
}else{
|
||||
if( nEqCol==0 ) return nPriorSat;
|
||||
sortOrder = bOuterRev;
|
||||
nEqOneRow = 0;
|
||||
nEqOneRow = -1;
|
||||
}
|
||||
pOrderBy = p->pOrderBy;
|
||||
assert( pOrderBy!=0 );
|
||||
@@ -2917,7 +2915,7 @@ static int isSortingIndex(
|
||||
if( i>nEqOneRow ){
|
||||
if( termSortOrder!=sortOrder ){
|
||||
/* Indices can only be used if all ORDER BY terms past the
|
||||
** equality constraints are all either DESC or ASC. */
|
||||
** equality constraints have the correct DESC or ASC. */
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user