1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Only continue an ORDER BY optimization into inner loops if the equality

constraints on the inner loop match terms of an outer ordered index that
are actually used by the ORDER BY clause.

FossilOrigin-Name: b0e7b4df6c2a8c479f8d210bde50c737eaa248f0
This commit is contained in:
drh
2012-10-02 14:11:29 +00:00
parent 3be57d2aba
commit 178eb61c6b
5 changed files with 60 additions and 19 deletions

View File

@@ -2736,10 +2736,13 @@ static int isOrderedColumn(WhereBestIdx *p, int iTab, int iCol, int *pbRev){
sortOrder = 0;
testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );
}else{
for(j=0; j<pIdx->nColumn; j++){
int n = pLevel->plan.nOBSat;
if( p->i>=2 ) n -= pLevel[-1].plan.nOBSat;
assert( n<=pIdx->nColumn );
for(j=0; j<n; j++){
if( iCol==pIdx->aiColumn[j] ) break;
}
if( j>=pIdx->nColumn ) return 0;
if( j>=n ) return 0;
sortOrder = pIdx->aSortOrder[j];
testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );
}