diff options
author | drh <drh@noemail.net> | 2012-09-27 23:27:23 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-09-27 23:27:23 +0000 |
commit | a9e3fc05f58a055ffdb67dca2a8215efb698a955 (patch) | |
tree | c394bd9990cd6e6f6ed6d14b8e1e79691619f5a6 /src | |
parent | 5343b2d4a8f778672cffe9ea2d2dd2d0bce7d6ac (diff) | |
download | sqlite-a9e3fc05f58a055ffdb67dca2a8215efb698a955.tar.gz sqlite-a9e3fc05f58a055ffdb67dca2a8215efb698a955.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 7 | ||||
-rw-r--r-- | src/test1.c | 1 | ||||
-rw-r--r-- | src/where.c | 4 |
3 files changed, 5 insertions, 7 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4501c737f..a03b7ac1e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -827,7 +827,7 @@ struct sqlite3 { unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ int errCode; /* Most recent error code (SQLITE_*) */ int errMask; /* & result codes with this before returning */ - u16 dbOptFlags; /* Flags to enable/disable optimizations */ + u8 dbOptFlags; /* Flags to enable/disable optimizations */ u8 autoCommit; /* The auto-commit flag. */ u8 temp_store; /* 1: file 2: memory 0: default */ u8 mallocFailed; /* True if we have seen a malloc failure */ @@ -971,9 +971,8 @@ struct sqlite3 { #define SQLITE_IdxRealAsInt 0x0010 /* Store REAL as INT in indices */ #define SQLITE_DistinctOpt 0x0020 /* DISTINCT using indexes */ #define SQLITE_CoverIdxScan 0x0040 /* Covering index scans */ -#define SQLITE_OrderByIdx 0x0180 /* ORDER BY using indices */ -#define SQLITE_OrderByIdxJoin 0x0100 /* ORDER BY of joins via index */ -#define SQLITE_AllOpts 0x01ff /* All optimizations */ +#define SQLITE_OrderByIdxJoin 0x0080 /* ORDER BY of joins via index */ +#define SQLITE_AllOpts 0x00ff /* All optimizations */ /* ** Macros for testing whether or not optimizations are enabled or disabled. diff --git a/src/test1.c b/src/test1.c index 45ca124bb..3d2fb0203 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5941,7 +5941,6 @@ static int optimization_control( { "real-as-int", SQLITE_IdxRealAsInt }, { "distinct-opt", SQLITE_DistinctOpt }, { "cover-idx-scan", SQLITE_CoverIdxScan }, - { "order-by-idx", SQLITE_OrderByIdx }, { "order-by-idx-join",SQLITE_OrderByIdxJoin }, }; diff --git a/src/where.c b/src/where.c index 9bdcd536c..7f386289c 100644 --- a/src/where.c +++ b/src/where.c @@ -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 |