From d6ee353c84e50a855a330c91447052a67b1db0a6 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 29 Mar 2011 15:00:17 +0000 Subject: [PATCH] If the keyword "unordered" appears at the end of the SQLITE_STAT1.STAT column for an index, then use that index for equality lookups only, never for range queries or sorting. FossilOrigin-Name: 3b964155f611c437d53d44feafa22f531942b1b4 --- install-sh | 0 manifest | 28 ++++++++++++++++------------ manifest.uuid | 2 +- src/analyze.c | 4 ++++ src/sqliteInt.h | 1 + src/where.c | 3 ++- test/progress.test | 0 tool/mkopts.tcl | 0 8 files changed, 24 insertions(+), 14 deletions(-) mode change 100644 => 100755 install-sh mode change 100755 => 100644 test/progress.test mode change 100755 => 100644 tool/mkopts.tcl diff --git a/install-sh b/install-sh old mode 100644 new mode 100755 diff --git a/manifest b/manifest index 5041a0d7f0..e5474f9e2b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sunix\sVFS\simplementation\sof\sxNextSystemCall().\sAlso\ssome\stypos\sthat\sprevent\scompilation\swhen\sHAVE_POSIX_FALLOCATE\sis\sdefined. -D 2011-03-29T10:04:23 +C If\sthe\skeyword\s"unordered"\sappears\sat\sthe\send\sof\sthe\sSQLITE_STAT1.STAT\ncolumn\sfor\san\sindex,\sthen\suse\sthat\sindex\sfor\sequality\slookups\sonly,\snever\nfor\srange\squeries\sor\ssorting. +D 2011-03-29T15:00:17.756 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -99,7 +99,7 @@ F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0 F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 -F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 +F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F main.mk 7e4d4d0433c9cbfd906c6451a7cc50310a8f4555 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a @@ -115,7 +115,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 6a0c176e64a34929a4436048066a84ef4f1445b3 -F src/analyze.c a038162344265ac21dfb24b3fcc06c666ebb9c07 +F src/analyze.c 0a58e3d8228617e619c48a3aa8991a1ff5ad7768 F src/attach.c 438ea6f6b5d5961c1f49b737f2ce0f14ce7c6877 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 6728d6d48d55b449af76a3e51c0808849cb32a2e @@ -180,7 +180,7 @@ F src/select.c d24406c45dd2442eb2eeaac413439066b149c944 F src/shell.c 9dc0b4bb59290c0a35256d278cab0f314987ad6a F src/sqlite.h.in e047f69a61d604d4f8be6cf1d1bdfc68be9ba7e5 F src/sqlite3ext.h c90bd5507099f62043832d73f6425d8d5c5da754 -F src/sqliteInt.h f8f1d00a22c98fd3f2fbc94da74eeb880879f89f +F src/sqliteInt.h da41a2f4aa71d8490c55d2eaec423839300226f6 F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 F src/status.c 4997380fbb915426fef9e500b4872e79c99267fc F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -244,7 +244,7 @@ F src/vtab.c e1edca38c4c4310710635bb91bb3c87fdf60f21d F src/wal.c 7334009b396285b658a95a3b6bc6d2b016a1f794 F src/wal.h 7a5fbb00114b7f2cd40c7e1003d4c41ce9d26840 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f -F src/where.c a6e89fe7e56ab7e633be6fdebdddd857e9e5bc99 +F src/where.c 8614b235f8c944e9210fd50c4619fc899bfa196e F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 51756962d522e474338e9b2ebb26e7364d4aa125 @@ -604,7 +604,7 @@ F test/permutations.test 5b2a4cb756ffb2407cb4743163668d1d769febb6 F test/pragma.test fdfc09067ea104a0c247a1a79d8093b56656f850 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea -F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x +F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/quick.test 1681febc928d686362d50057c642f77a02c62e57 F test/quota.test ddafe133653093eb9a99ccd6264884ae43f9c9b8 @@ -894,7 +894,7 @@ F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/lemon.c dfd81a51b6e27e469ba21d01a75ddf092d429027 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309 -F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x +F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c.tcl cf44512a48112b1ba09590548660a5a6877afdb3 F tool/mksqlite3h.tcl d76c226a5e8e1f3b5f6593bcabe5e98b3b1ec9ff @@ -919,7 +919,11 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 7270f80ac5dd17b979f1f790b2dfcf811866c1dc -R 667989871349daf241bf6e2f9ef88c3d -U dan -Z e094d9a9a392624fe79d654e33f9ed32 +P bc6cce81565b17f886478bd51500bba2ed11ec1d +R 28f7b55473c6274def40f06b898262fe +T *bgcolor * #c0c0c0 +T *branch * unordered-index-hack +T *sym-unordered-index-hack * +T -sym-trunk * +U drh +Z 6d40d1dbb9e51f61cda2be9cc9ee0b6e diff --git a/manifest.uuid b/manifest.uuid index 96763a4275..f0761ed34e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bc6cce81565b17f886478bd51500bba2ed11ec1d \ No newline at end of file +3b964155f611c437d53d44feafa22f531942b1b4 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 0a8339bafb..8aef9d7731 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -535,6 +535,10 @@ static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ if( pIndex==0 ) break; pIndex->aiRowEst[i] = v; if( *z==' ' ) z++; + if( memcmp(z, "unordered", 10)==0 ){ + pIndex->bUnordered = 1; + break; + } } return 0; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0825af4cdf..8d3e2b1144 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1462,6 +1462,7 @@ struct Index { int tnum; /* Page containing root of this index in database file */ u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ + u8 bUnordered; /* Use this index for == or IN queries only */ char *zColAff; /* String defining the affinity of each column */ Index *pNext; /* The next index associated with the same table */ Schema *pSchema; /* Schema containing this index */ diff --git a/src/where.c b/src/where.c index cdcaa98c01..00975e5fdc 100644 --- a/src/where.c +++ b/src/where.c @@ -2860,7 +2860,7 @@ static void bestBtreeIndex( } /* Determine the value of estBound. */ - if( nEqnColumn ){ + if( nEqnColumn && pProbe->bUnordered==0 ){ int j = pProbe->aiColumn[nEq]; if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){ WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx); @@ -2892,6 +2892,7 @@ static void bestBtreeIndex( ** will scan rows in a different order, set the bSort variable. */ if( pOrderBy ){ if( (wsFlags & WHERE_COLUMN_IN)==0 + && pProbe->bUnordered==0 && isSortingIndex(pParse, pWC->pMaskSet, pProbe, iCur, pOrderBy, nEq, wsFlags, &rev) ){ diff --git a/test/progress.test b/test/progress.test old mode 100755 new mode 100644 diff --git a/tool/mkopts.tcl b/tool/mkopts.tcl old mode 100755 new mode 100644 -- 2.39.5