mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
An index might be useful for ORDER BY if any indexed column is in the
ORDER BY clause, not just the first indexed column. FossilOrigin-Name: ade473b5ae3fe2162b0ec29731d8e864a9301e07
This commit is contained in:
@@ -4370,18 +4370,17 @@ static int indexMightHelpWithOrderBy(
|
||||
int iCursor
|
||||
){
|
||||
ExprList *pOB;
|
||||
int iCol;
|
||||
int ii;
|
||||
int ii, jj;
|
||||
|
||||
if( pIndex->bUnordered ) return 0;
|
||||
if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;
|
||||
iCol = pIndex->aiColumn[0];
|
||||
for(ii=0; ii<pOB->nExpr; ii++){
|
||||
Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
|
||||
if( pExpr->op!=TK_COLUMN ) return 0;
|
||||
if( pExpr->iTable==iCursor ){
|
||||
if( pExpr->iColumn==iCol ) return 1;
|
||||
return 0;
|
||||
for(jj=0; jj<pIndex->nColumn; jj++){
|
||||
if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user