mirror of
https://github.com/sqlite/sqlite.git
synced 2026-01-06 08:01:16 +03:00
Fix some corner case behavior in the new ORDER BY optimization logic.
Remove the SQLITE_OrderByIdx bit from the SQLITE_TESTCTRL_OPTIMIZATIONS mask, since enabling it caused many TH3 tests to fail when the NO_OPT configuration parameter was engaged, and since there really isn't any need to turn that optimization off. The SQLITE_OrderByIdxJoin bit remains. FossilOrigin-Name: 98b633717a1c9a08f6a1d00bc6bc891564ae7e9b
This commit is contained in:
@@ -1647,7 +1647,6 @@ static int isSortingIndex(
|
||||
int seenRowid = 0; /* True if an ORDER BY rowid term is seen */
|
||||
int nEqOneRow; /* Idx columns that ref unique values */
|
||||
|
||||
if( OptimizationDisabled(db, SQLITE_OrderByIdx) ) return 0;
|
||||
if( p->i==0 ){
|
||||
nPriorSat = 0;
|
||||
nEqOneRow = nEqCol;
|
||||
@@ -3154,6 +3153,7 @@ static void bestBtreeIndex(WhereBestIdx *p){
|
||||
}
|
||||
}else if( pTerm->eOperator & WO_ISNULL ){
|
||||
wsFlags |= WHERE_COLUMN_NULL;
|
||||
if( nEq==nOrdered ) nOrdered++;
|
||||
}else if( bSort && nEq==nOrdered && isOrderedTerm(p, pTerm, &bRev) ){
|
||||
nOrdered++;
|
||||
}
|
||||
@@ -3216,7 +3216,7 @@ static void bestBtreeIndex(WhereBestIdx *p){
|
||||
bSort = 0;
|
||||
wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE|WHERE_ORDERBY;
|
||||
}
|
||||
if( bRev ) wsFlags |= WHERE_REVERSE;
|
||||
if( bRev & 1 ) wsFlags |= WHERE_REVERSE;
|
||||
}
|
||||
|
||||
/* If there is a DISTINCT qualifier and this index will scan rows in
|
||||
|
||||
Reference in New Issue
Block a user