From: drh Date: Fri, 29 May 2015 14:36:30 +0000 (+0000) Subject: Add some extra source-code comments and a test case. X-Git-Tag: version-3.8.11~194^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcoroutine-autoindex;p=thirdparty%2Fsqlite.git Add some extra source-code comments and a test case. FossilOrigin-Name: 6d410442fb532e2cf0ad1859bc9e843651f8ff4d --- diff --git a/manifest b/manifest index ad97f6d074..a58d875015 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C An\sattempt\sto\sallow\sautomatic\sindex\screation\son\ssubqueries\saccessed\svia\nco-routine. -D 2015-05-29T13:55:33.273 +C Add\ssome\sextra\ssource-code\scomments\sand\sa\stest\scase. +D 2015-05-29T14:36:30.811 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 994bab32a3a69e0c35bd148b65cde49879772964 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -326,7 +326,7 @@ F src/vxworks.h c18586c8edc1bddbc15c004fa16aeb1e1342b4fb F src/wal.c ce2cb2d06faab54d1bce3e739bec79e063dd9113 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804 -F src/where.c 5eb9ab47f6e256f0f241a000469bc4e1bd2cb085 +F src/where.c f6f41c2f8b9903854992170ea5178898f9cb6c9c F src/whereInt.h a6f5a762bc1b4b1c76e1cea79976b437ac35a435 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -373,6 +373,7 @@ F test/autoindex1.test 14b63a9f1e405fe6d5bfc8c8d00249c2ebaf13ea F test/autoindex2.test af7e595c6864cc6ef5fc38d5db579a3e34940cb8 F test/autoindex3.test a3be0d1a53a7d2edff208a5e442312957047e972 F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf +F test/autoindex5.test 6f487290ce2a667c24517191651bfb8c7d86b6dc F test/autovacuum.test 941892505d2c0f410a0cb5970dfa1c7c4e5f6e74 F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 @@ -1280,10 +1281,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P a29e117d7ecec05da949348689dbfb0d3acb1280 -R 88c52c7945c3c5cf23282c30dc23f438 -T *branch * coroutine-autoindex -T *sym-coroutine-autoindex * -T -sym-trunk * +P 521345add67e9dfd7df1446eb942aa0d84b9e6eb +R 12e2c54c40333a10e1b02fb50d487ba7 U drh -Z 77000af208e80e6a672a8b20d82a8232 +Z 1b48f7e21062a41962258c7fda06b04f diff --git a/manifest.uuid b/manifest.uuid index 2ae7950981..7ce2b9c4a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -521345add67e9dfd7df1446eb942aa0d84b9e6eb \ No newline at end of file +6d410442fb532e2cf0ad1859bc9e843651f8ff4d \ No newline at end of file diff --git a/src/where.c b/src/where.c index a547ec72d4..bcd3129189 100644 --- a/src/where.c +++ b/src/where.c @@ -5220,14 +5220,14 @@ static int whereLoopAddBtree( #ifndef SQLITE_OMIT_AUTOMATIC_INDEX /* Automatic indexes */ - if( !pBuilder->pOrSet + if( !pBuilder->pOrSet /* Not part of an OR optimization */ && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 - && pSrc->pIndex==0 - && !pSrc->notIndexed - && HasRowid(pTab) - && !pSrc->isCorrelated - && !pSrc->isRecursive + && pSrc->pIndex==0 /* Has no INDEXED BY clause */ + && !pSrc->notIndexed /* Has no NOT INDEXED clause */ + && HasRowid(pTab) /* Is not a WITHOUT ROWID table. (FIXME: Why not?) */ + && !pSrc->isCorrelated /* Not a correlated subquery */ + && !pSrc->isRecursive /* Not a recursive common table expression. */ ){ /* Generate auto-index WhereLoops */ WhereTerm *pTerm; diff --git a/test/autoindex5.test b/test/autoindex5.test new file mode 100644 index 0000000000..2d5fad2eda --- /dev/null +++ b/test/autoindex5.test @@ -0,0 +1,108 @@ +# 2014-10-24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#************************************************************************* +# +# This file implements regression tests for SQLite library. The +# focus of this script is testing automatic index creation logic, +# and specifically ensuring that automatic indexes can be used with +# co-routine subqueries. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Schema is from the Debian security database +# +do_execsql_test autoindex5-1.0 { + CREATE TABLE source_package_status + (bug_name TEXT NOT NULL, + package INTEGER NOT NULL, + vulnerable INTEGER NOT NULL, + urgency TEXT NOT NULL, + PRIMARY KEY (bug_name, package)); + CREATE INDEX source_package_status_package + ON source_package_status(package); + + CREATE TABLE source_packages + (name TEXT NOT NULL, + release TEXT NOT NULL, + subrelease TEXT NOT NULL, + archive TEXT NOT NULL, + version TEXT NOT NULL, + version_id INTEGER NOT NULL DEFAULT 0, + PRIMARY KEY (name, release, subrelease, archive)); + + CREATE TABLE bugs + (name TEXT NOT NULL PRIMARY KEY, + cve_status TEXT NOT NULL + CHECK (cve_status IN + ('', 'CANDIDATE', 'ASSIGNED', 'RESERVED', 'REJECTED')), + not_for_us INTEGER NOT NULL CHECK (not_for_us IN (0, 1)), + description TEXT NOT NULL, + release_date TEXT NOT NULL, + source_file TEXT NOT NULL, + source_line INTEGER NOT NULL); + + CREATE TABLE package_notes + (id INTEGER NOT NULL PRIMARY KEY, + bug_name TEXT NOT NULL, + package TEXT NOT NULL, + fixed_version TEXT + CHECK (fixed_version IS NULL OR fixed_version <> ''), + fixed_version_id INTEGER NOT NULL DEFAULT 0, + release TEXT NOT NULL, + package_kind TEXT NOT NULL DEFAULT 'unknown', + urgency TEXT NOT NULL, + bug_origin TEXT NOT NULL DEFAULT ''); + CREATE INDEX package_notes_package + ON package_notes(package); + CREATE UNIQUE INDEX package_notes_bug + ON package_notes(bug_name, package, release); + + CREATE TABLE debian_bugs + (bug INTEGER NOT NULL, + note INTEGER NOT NULL, + PRIMARY KEY (bug, note)); + + + CREATE VIEW debian_cve AS + SELECT DISTINCT debian_bugs.bug, st.bug_name + FROM package_notes, debian_bugs, source_package_status AS st + WHERE package_notes.bug_name = st.bug_name + AND debian_bugs.note = package_notes.id + ORDER BY debian_bugs.bug; +} {} + +# The following query should use an automatic index for the view +# in FROM clause of the subquery of the second result column. +# +do_execsql_test autoindex5-1.1 { + EXPLAIN QUERY PLAN + SELECT + st.bug_name, + (SELECT ALL debian_cve.bug FROM debian_cve + WHERE debian_cve.bug_name = st.bug_name + ORDER BY debian_cve.bug), + sp.release + FROM + source_package_status AS st, + source_packages AS sp, + bugs + WHERE + sp.rowid = st.package + AND st.bug_name = bugs.name + AND ( st.bug_name LIKE 'CVE-%' OR st.bug_name LIKE 'TEMP-%' ) + AND ( sp.release = 'sid' OR sp.release = 'stretch' OR sp.release = 'jessie' + OR sp.release = 'wheezy' OR sp.release = 'squeeze' ) + ORDER BY sp.name, st.bug_name, sp.release, sp.subrelease; +} {/SEARCH SUBQUERY 2 USING AUTOMATIC COVERING INDEX .bug_name=/} + + +finish_test