From: drh Date: Fri, 28 Jun 2013 23:55:45 +0000 (+0000) Subject: Issue the new SQLITE_WARNING_AUTOINDEX warning on the SQLite log whenever X-Git-Tag: version-3.8.0~115 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d56e2059c81a9e415876d174f1928a0a26a6091;p=thirdparty%2Fsqlite.git Issue the new SQLITE_WARNING_AUTOINDEX warning on the SQLite log whenever an automatic index is created. FossilOrigin-Name: 338826ef3f8a209b14f8d42370855cab9ac9ed45 --- diff --git a/manifest b/manifest index bce73f24e9..6527896fc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_DEFAULT_AUTOMATIC_INDEX\scompile-time\soption,\swhich\sif\sset\sto\nzero\sturns\sautomatic\sindices\soff\sby\sdefault.\s\sIncrease\sthe\sestimated\scost\nof\san\sautomatic\sindex.\s\sAdditional\sminor\srefactoring\sof\sthe\sautomatic\nindex\scode. -D 2013-06-28T21:12:20.682 +C Issue\sthe\snew\sSQLITE_WARNING_AUTOINDEX\swarning\son\sthe\sSQLite\slog\swhenever\nan\sautomatic\sindex\sis\screated. +D 2013-06-28T23:55:45.243 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -185,7 +185,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c c48f7f3f170e502fe0cc20748e03c6e0b5a016c2 -F src/main.c 648aea1fdd88d9f04367b325129a33609d933f5d +F src/main.c a1f4bb79e15c3f0a2e4efb2f52781ccbfb3010d4 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -218,7 +218,7 @@ F src/resolve.c 89f9003e8316ee3a172795459efc2a0274e1d5a8 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 91b62654caf8dfe292fb8882715e575d34ad3874 F src/shell.c c0f38cee126d1ea82275195933359e91d90196a0 -F src/sqlite.h.in 9e8d57aa4d2fdc181dc25e9aa295f5ecec7e184a +F src/sqlite.h.in 0a87152a6dde55381afb8f1cf37f337b2f32fd06 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h d936f797812c28b81b26ed18345baf8db28a21a5 F src/sqliteInt.h e461e0f9109ca49ad6aba52198fbe7d237c4a75b @@ -290,7 +290,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 -F src/where.c b0cdc92ae0aeaed2aca53bcd5bcde0a83743d153 +F src/where.c 2c447e377397c9e6cea7d701f89614e093247dba F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -323,7 +323,7 @@ F test/auth.test 4a4c3b034fff7750513520defa910f376c96ab49 F test/auth2.test a2a371aa6df15f8b0c8109b33d3d7f0f73e4c9aa F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5 F test/autoinc.test bd30d372d00045252f6c2e41b5f41455e1975acf -F test/autoindex1.test e19269b74a6f55975a4f2453778f6ef524fd88c9 +F test/autoindex1.test d0c86aad05475188f42ddfded2219e1c3fe38028 F test/autovacuum.test 9f22a7733f39c56ef6a5665d10145ac25d8cb574 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 @@ -1098,7 +1098,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P f308c4851726b4b75636f714466f2314f56e3ec0 -R 4380a773ef3ea80daacb5f7d2d9f9d84 +P 459b3179023c2c45994ea4acbf34ed5f87cf3c18 +R 48bb56ec2d1aeb5153c2eb54b3cdba3c U drh -Z 670c2d71707208c8f107ef52a342b6f3 +Z 0e40ede38a5aee19df0cc5e0fb989f8e diff --git a/manifest.uuid b/manifest.uuid index a0133200d0..3c40c8f277 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -459b3179023c2c45994ea4acbf34ed5f87cf3c18 \ No newline at end of file +338826ef3f8a209b14f8d42370855cab9ac9ed45 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 5323a6ce7a..12a1ad19b6 100644 --- a/src/main.c +++ b/src/main.c @@ -1137,6 +1137,7 @@ const char *sqlite3ErrName(int rc){ case SQLITE_NOTICE_RECOVER_ROLLBACK: zName = "SQLITE_NOTICE_RECOVER_ROLLBACK"; break; case SQLITE_WARNING: zName = "SQLITE_WARNING"; break; + case SQLITE_WARNING_AUTOINDEX: zName = "SQLITE_WARNING_AUTOINDEX"; break; case SQLITE_DONE: zName = "SQLITE_DONE"; break; } } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 741dabc44e..87bce973a4 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -495,6 +495,7 @@ int sqlite3_exec( #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) +#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations diff --git a/src/where.c b/src/where.c index 144e2c834b..f739853598 100644 --- a/src/where.c +++ b/src/where.c @@ -2042,6 +2042,7 @@ static void constructAutomaticIndex( WhereLoop *pLoop; /* The Loop object */ Bitmask idxCols; /* Bitmap of columns used for indexing */ Bitmask extraCols; /* Bitmap of additional columns */ + u8 sentWarning = 0; /* True if a warnning has been issued */ /* Generate code to skip over the creation and initialization of the ** transient index on 2nd and subsequent iterations of the loop. */ @@ -2062,6 +2063,12 @@ static void constructAutomaticIndex( Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); testcase( iCol==BMS ); testcase( iCol==BMS-1 ); + if( !sentWarning ){ + sqlite3_log(SQLITE_WARNING_AUTOINDEX, + "automatic index on %s(%s)", pTable->zName, + pTable->aCol[iCol].zName); + sentWarning = 1; + } if( (idxCols & cMask)==0 ){ if( whereLoopResize(pParse->db, pLoop, nColumn+1) ) return; pLoop->aLTerm[nColumn++] = pTerm; diff --git a/test/autoindex1.test b/test/autoindex1.test index 3e08a527bc..8c6936b3fe 100644 --- a/test/autoindex1.test +++ b/test/autoindex1.test @@ -23,6 +23,13 @@ ifcapable {!autoindex} { return } +# Setup for logging +sqlite3_shutdown +test_sqlite3_log [list lappend ::log] +set ::log [list] +sqlite3 db test.db + + # With automatic index turned off, we do a full scan of the T2 table do_test autoindex1-100 { db eval { @@ -60,6 +67,15 @@ do_test autoindex1-111 { do_test autoindex1-112 { db status autoindex } {7} +do_test autoindex1-113 { + set ::log +} {SQLITE_WARNING_AUTOINDEX {automatic index on t2(c)}} + +db close +sqlite3_shutdown +test_sqlite3_log +sqlite3_initialize +sqlite3 db test.db # The same test as above, but this time the T2 query is a subquery rather # than a join.