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

Allow an index to be used for sorting even if prior terms of the index

are constrained by IN operators.

FossilOrigin-Name: 98bf668ab1a8683b46ee8c94cb60f8215aabc517
This commit is contained in:
drh
2013-02-07 21:15:14 +00:00
parent 928d9c6209
commit 1b8fc65b92
5 changed files with 82 additions and 19 deletions

View File

@@ -3010,10 +3010,15 @@ static int isSortingIndex(
if( pConstraint==0 ){
isEq = 0;
}else if( (pConstraint->eOperator & WO_IN)!=0 ){
#if 0
/* Constraints of the form: "X IN ..." cannot be used with an ORDER BY
** because we do not know in what order the values on the RHS of the IN
** operator will occur. */
break;
#else
if( termSortOrder ) break;
isEq = 0;
#endif
}else if( (pConstraint->eOperator & WO_ISNULL)!=0 ){
uniqueNotNull = 0;
isEq = 1; /* "X IS NULL" means X has only a single value */
@@ -3317,8 +3322,8 @@ static void bestBtreeIndex(WhereBestIdx *p){
** indicate this to the caller.
**
** Otherwise, if the search may find more than one row, test to see if
** there is a range constraint on indexed column (pc.plan.nEq+1) that can be
** optimized using the index.
** there is a range constraint on indexed column (pc.plan.nEq+1) that
** can be optimized using the index.
*/
if( pc.plan.nEq==pProbe->nColumn && pProbe->onError!=OE_None ){
testcase( pc.plan.wsFlags & WHERE_COLUMN_IN );