From 3c2aeae16e04c903ec6393cb940f23f80c769442 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jan 2014 14:37:44 +0000 Subject: [PATCH 01/14] Add test cases that compare the performance of the transitive_closure virtual table again common table expressions for walking a tree. FossilOrigin-Name: 9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222 --- manifest | 14 ++++++------- manifest.uuid | 2 +- test/closure01.test | 48 +++++++++++++++++++++++++-------------------- test/tester.tcl | 14 +++++++++++++ 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/manifest b/manifest index fb401ca29f..2336aab937 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sshowing\sthe\suse\sof\sORDER\sBY\son\sa\srecursive\squery\sto\scontrol\ndepth-first\sversus\sbreath-first\ssearch\sof\sa\stree. -D 2014-01-24T11:16:01.884 +C Add\stest\scases\sthat\scompare\sthe\sperformance\sof\sthe\stransitive_closure\nvirtual\stable\sagain\scommon\stable\sexpressions\sfor\swalking\sa\stree. +D 2014-01-24T14:37:44.938 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -372,7 +372,7 @@ F test/capi3e.test ad90088b18b0367125ff2d4b5400153fd2f99aab F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 F test/check.test 5831ddb6f2c687782eaf2e1a07b6e17f24c4f763 F test/close.test 340bd24cc58b16c6bc01967402755027c37eb815 -F test/closure01.test dbb28f1ea9eeaf0a53ec5bc0fed352e479def8c7 +F test/closure01.test 52036bd5f5d1734f41ba708e9038198aa274156a F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 F test/collate1.test 73b91005f264b7c403e2d63a6708d150679ac99a F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621 @@ -844,7 +844,7 @@ F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 -F test/tester.tcl 08e9f317afe60d398fa900993503ecaef3295bad +F test/tester.tcl 9bd04481b8b0ef1f2049ad01f28e175ee9a14f7b F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P f4a701d55f5c4e1e62ed64b779ad4fff89dd31b7 -R 15c1d48ec007e0818a79a87f9c81fe3d +P 83b0b2916589db0184435dbd4c304387f393ed60 +R f85f8ae6263bf3d6f45ffff44c95c74a U drh -Z a61c87789af8810b68d544f76885410e +Z be990f0e27dcbfb4abd20beb041780d7 diff --git a/manifest.uuid b/manifest.uuid index 1c78fab271..cc3b6b6830 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83b0b2916589db0184435dbd4c304387f393ed60 \ No newline at end of file +9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222 \ No newline at end of file diff --git a/test/closure01.test b/test/closure01.test index 5dac87a0ce..346ea76e8c 100644 --- a/test/closure01.test +++ b/test/closure01.test @@ -15,41 +15,36 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix closure01 -ifcapable !vtab { finish_test ; return } +ifcapable !vtab||!cte { finish_test ; return } load_static_extension db closure do_execsql_test 1.0 { BEGIN; CREATE TABLE t1(x INTEGER PRIMARY KEY, y INTEGER); + WITH RECURSIVE + cnt(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM cnt LIMIT 131072) + INSERT INTO t1(x, y) SELECT i, nullif(i,1)/2 FROM cnt; CREATE INDEX t1y ON t1(y); - INSERT INTO t1(x) VALUES(1),(2); - INSERT INTO t1(x) SELECT x+2 FROM t1; - INSERT INTO t1(x) SELECT x+4 FROM t1; - INSERT INTO t1(x) SELECT x+8 FROM t1; - INSERT INTO t1(x) SELECT x+16 FROM t1; - INSERT INTO t1(x) SELECT x+32 FROM t1; - INSERT INTO t1(x) SELECT x+64 FROM t1; - INSERT INTO t1(x) SELECT x+128 FROM t1; - INSERT INTO t1(x) SELECT x+256 FROM t1; - INSERT INTO t1(x) SELECT x+512 FROM t1; - INSERT INTO t1(x) SELECT x+1024 FROM t1; - INSERT INTO t1(x) SELECT x+2048 FROM t1; - INSERT INTO t1(x) SELECT x+4096 FROM t1; - INSERT INTO t1(x) SELECT x+8192 FROM t1; - INSERT INTO t1(x) SELECT x+16384 FROM t1; - INSERT INTO t1(x) SELECT x+32768 FROM t1; - INSERT INTO t1(x) SELECT x+65536 FROM t1; - UPDATE t1 SET y=x/2 WHERE x>1; COMMIT; CREATE VIRTUAL TABLE cx USING transitive_closure(tablename=t1, idcolumn=x, parentcolumn=y); } {} # The entire table -do_execsql_test 1.1 { +do_timed_execsql_test 1.1 { SELECT count(*), depth FROM cx WHERE root=1 GROUP BY depth ORDER BY 1; } {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/} +do_timed_execsql_test 1.1-cte { + WITH RECURSIVE + below(id,depth) AS ( + VALUES(1,0) + UNION ALL + SELECT t1.x, below.depth+1 + FROM t1 JOIN below on t1.y=below.id + ) + SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1; +} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/} # descendents of 32768 do_execsql_test 1.2 { @@ -57,9 +52,20 @@ do_execsql_test 1.2 { } {32768 0 65536 1 65537 1 131072 2} # descendents of 16384 -do_execsql_test 1.3 { +do_timed_execsql_test 1.3 { SELECT * FROM cx WHERE root=16384 AND depth<=2 ORDER BY id; } {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2} +do_timed_execsql_test 1.3-cte { + WITH RECURSIVE + below(id,depth) AS ( + VALUES(16384,0) + UNION ALL + SELECT t1.x, below.depth+1 + FROM t1 JOIN below on t1.y=below.id + WHERE below.depth<2 + ) + SELECT id, depth FROM below ORDER BY id; +} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2} # children of 16384 do_execsql_test 1.4 { diff --git a/test/tester.tcl b/test/tester.tcl index 109fb310a9..fefd5e8a8f 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -59,6 +59,7 @@ # do_test TESTNAME SCRIPT EXPECTED # do_execsql_test TESTNAME SQL EXPECTED # do_catchsql_test TESTNAME SQL EXPECTED +# do_timed_execsql_test TESTNAME SQL EXPECTED # # Commands providing a lower level interface to the global test counters: # @@ -717,6 +718,11 @@ proc do_catchsql_test {testname sql result} { fix_testname testname uplevel do_test [list $testname] [list "catchsql {$sql}"] [list $result] } +proc do_timed_execsql_test {testname sql {result {}}} { + fix_testname testname + uplevel do_test [list $testname] [list "execsql_timed {$sql}"]\ + [list [list {*}$result]] +} proc do_eqp_test {name sql res} { uplevel do_execsql_test $name [list "EXPLAIN QUERY PLAN $sql"] [list $res] } @@ -1013,6 +1019,14 @@ proc execsql {sql {db db}} { # puts "SQL = $sql" uplevel [list $db eval $sql] } +proc execsql_timed {sql {db db}} { + set tm [time { + set x [uplevel [list $db eval $sql]] + } 1] + set tm [lindex $tm 0] + puts -nonewline " ([expr {$tm*0.001}]ms) " + set x +} # Execute SQL and catch exceptions. # From 9e2c7ae1b0ce1b88a0bba91f7bdde4ce3e6bc1c4 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jan 2014 15:42:51 +0000 Subject: [PATCH 02/14] Add a few more CTE test cases to closure.test. FossilOrigin-Name: 1b6405d9788c1bb89761b2bcdce560a5020ff503 --- manifest | 12 +++++------ manifest.uuid | 2 +- test/closure01.test | 52 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 2336aab937..275452cb28 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sthat\scompare\sthe\sperformance\sof\sthe\stransitive_closure\nvirtual\stable\sagain\scommon\stable\sexpressions\sfor\swalking\sa\stree. -D 2014-01-24T14:37:44.938 +C Add\sa\sfew\smore\sCTE\stest\scases\sto\sclosure.test. +D 2014-01-24T15:42:51.397 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -372,7 +372,7 @@ F test/capi3e.test ad90088b18b0367125ff2d4b5400153fd2f99aab F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 F test/check.test 5831ddb6f2c687782eaf2e1a07b6e17f24c4f763 F test/close.test 340bd24cc58b16c6bc01967402755027c37eb815 -F test/closure01.test 52036bd5f5d1734f41ba708e9038198aa274156a +F test/closure01.test b1703ba40639cfc9b295cf478d70739415eec6a4 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91 F test/collate1.test 73b91005f264b7c403e2d63a6708d150679ac99a F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 83b0b2916589db0184435dbd4c304387f393ed60 -R f85f8ae6263bf3d6f45ffff44c95c74a +P 9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222 +R f2060716c43f1dee6a2c1f879c1129f5 U drh -Z be990f0e27dcbfb4abd20beb041780d7 +Z 7914ad8fe58314f1f17f9965f9b13c5e diff --git a/manifest.uuid b/manifest.uuid index cc3b6b6830..6ca0ece42c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222 \ No newline at end of file +1b6405d9788c1bb89761b2bcdce560a5020ff503 \ No newline at end of file diff --git a/test/closure01.test b/test/closure01.test index 346ea76e8c..213ef4e966 100644 --- a/test/closure01.test +++ b/test/closure01.test @@ -47,9 +47,20 @@ do_timed_execsql_test 1.1-cte { } {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/} # descendents of 32768 -do_execsql_test 1.2 { +do_timed_execsql_test 1.2 { SELECT * FROM cx WHERE root=32768 ORDER BY id; } {32768 0 65536 1 65537 1 131072 2} +do_timed_execsql_test 1.2-cte { + WITH RECURSIVE + below(id,depth) AS ( + VALUES(32768,0) + UNION ALL + SELECT t1.x, below.depth+1 + FROM t1 JOIN below on t1.y=below.id + WHERE below.depth<2 + ) + SELECT id, depth FROM below ORDER BY id; +} {32768 0 65536 1 65537 1 131072 2} # descendents of 16384 do_timed_execsql_test 1.3 { @@ -76,19 +87,41 @@ do_execsql_test 1.4 { } {32768 1 {} t1 x y 32769 1 {} t1 x y} # great-grandparent of 16384 -do_execsql_test 1.5 { +do_timed_execsql_test 1.5 { SELECT id, depth, root, tablename, idcolumn, parentcolumn FROM cx WHERE root=16384 AND depth=3 AND idcolumn='Y' AND parentcolumn='X'; } {2048 3 {} t1 Y X} +do_timed_execsql_test 1.5-cte { + WITH RECURSIVE + above(id,depth) AS ( + VALUES(16384,0) + UNION ALL + SELECT t1.y, above.depth+1 + FROM t1 JOIN above ON t1.x=above.id + WHERE above.depth<3 + ) + SELECT id FROM above WHERE depth=3; +} {2048} # depth<5 -do_execsql_test 1.6 { +do_timed_execsql_test 1.6 { SELECT count(*), depth FROM cx WHERE root=1 AND depth<5 GROUP BY depth ORDER BY 1; } {1 0 2 1 4 2 8 3 16 4} +do_timed_execsql_test 1.6-cte { + WITH RECURSIVE + below(id,depth) AS ( + VALUES(1,0) + UNION ALL + SELECT t1.x, below.depth+1 + FROM t1 JOIN below ON t1.y=below.id + WHERE below.depth<4 + ) + SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1; +} {1 0 2 1 4 2 8 3 16 4} # depth<=5 do_execsql_test 1.7 { @@ -109,9 +142,20 @@ do_execsql_test 1.9 { } {8 3 16 4 32 5} # depth==5 with min() and max() -do_execsql_test 1.10 { +do_timed_execsql_test 1.10 { SELECT count(*), min(id), max(id) FROM cx WHERE root=1 AND depth=5; } {32 32 63} +do_timed_execsql_test 1.10-cte { + WITH RECURSIVE + below(id,depth) AS ( + VALUES(1,0) + UNION ALL + SELECT t1.x, below.depth+1 + FROM t1 JOIN below ON t1.y=below.id + WHERE below.depth<5 + ) + SELECT count(*), min(id), max(id) FROM below WHERE depth=5; +} {32 32 63} # Create a much smaller table t2 with only 32 elements db eval { From dc3bb0deb2f4d3328d796ee60597bb6adf769546 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jan 2014 16:36:18 +0000 Subject: [PATCH 03/14] Use an unsigned integer to accumulate the string hash. Avoids compiler warnings. FossilOrigin-Name: b1824344ea4918a13abbda4a3b7134d35fd867c4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/hash.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 275452cb28..e446313c60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\sfew\smore\sCTE\stest\scases\sto\sclosure.test. -D 2014-01-24T15:42:51.397 +C Use\san\sunsigned\sinteger\sto\saccumulate\sthe\sstring\shash.\s\sAvoids\scompiler\nwarnings. +D 2014-01-24T16:36:18.370 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 2ab0f5384b70594468ef3ac5c7ed8ca24bfd17d5 F src/func.c 6325ac2ec10833ccf4d5c36d323709221d37ea19 F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 -F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 +F src/hash.c d139319967164f139c8d1bb8a11b14db9c4ba3cd F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c a4450f0c46a9f221622e6551ab0953b03c4f8ee8 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 9a23f020e8ed0e7a1ad227b4ab379fdf5e2de222 -R f2060716c43f1dee6a2c1f879c1129f5 +P 1b6405d9788c1bb89761b2bcdce560a5020ff503 +R f7e02965abaaba2b2c591f1141f3d7cf U drh -Z 7914ad8fe58314f1f17f9965f9b13c5e +Z 197e448152d1aa82b77763ec048456c7 diff --git a/manifest.uuid b/manifest.uuid index 6ca0ece42c..710b1dce96 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1b6405d9788c1bb89761b2bcdce560a5020ff503 \ No newline at end of file +b1824344ea4918a13abbda4a3b7134d35fd867c4 \ No newline at end of file diff --git a/src/hash.c b/src/hash.c index e81dcf95e4..f9901fee8f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -53,7 +53,7 @@ void sqlite3HashClear(Hash *pH){ ** The hashing function. */ static unsigned int strHash(const char *z, int nKey){ - int h = 0; + unsigned int h = 0; assert( nKey>=0 ); while( nKey > 0 ){ h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; From 05d3dc29c5fa8f5e404079493e7e02fc8b033da1 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 Jan 2014 16:57:42 +0000 Subject: [PATCH 04/14] Add test cases for LIMIT and ORDER BY on recursive CTEs. FossilOrigin-Name: 67d6c42d44cb191368ce20f553b32fcb14bfc4d7 --- manifest | 14 ++--- manifest.uuid | 2 +- test/with1.test | 161 +++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 166 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index e446313c60..f46cfae2f5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\san\sunsigned\sinteger\sto\saccumulate\sthe\sstring\shash.\s\sAvoids\scompiler\nwarnings. -D 2014-01-24T16:36:18.370 +C Add\stest\scases\sfor\sLIMIT\sand\sORDER\sBY\son\srecursive\sCTEs. +D 2014-01-24T16:57:42.837 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1092,7 +1092,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test 7a6bd73a5dcdee39b5bb93e92395e1773a194361 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d -F test/with1.test 9d3537372c8cf6d5e0a5e9af037a52f3375fb704 +F test/with1.test 6c9c27b76e320d0ae3a3fc9ff6b236018201470d F test/with2.test 2fe78fcd8deef2a0f9cfc49bfc755911d0b3fd64 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 1b6405d9788c1bb89761b2bcdce560a5020ff503 -R f7e02965abaaba2b2c591f1141f3d7cf -U drh -Z 197e448152d1aa82b77763ec048456c7 +P b1824344ea4918a13abbda4a3b7134d35fd867c4 +R 9a46b9863f9dd82900d571672109f9d1 +U dan +Z c5f919f56b9fa0112bb7211064a506d1 diff --git a/manifest.uuid b/manifest.uuid index 710b1dce96..44c9c799f8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b1824344ea4918a13abbda4a3b7134d35fd867c4 \ No newline at end of file +67d6c42d44cb191368ce20f553b32fcb14bfc4d7 \ No newline at end of file diff --git a/test/with1.test b/test/with1.test index 6dd67d1690..486f025c64 100644 --- a/test/with1.test +++ b/test/with1.test @@ -452,11 +452,165 @@ do_execsql_test 8.2-soduko { SELECT s FROM x WHERE ind=0; } {534678912672195348198342567859761423426853791713924856961537284287419635345286179} +#-------------------------------------------------------------------------- +# Some tests that use LIMIT and OFFSET in the definition of recursive CTEs. +# +set I [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] +proc limit_test {tn iLimit iOffset} { + if {$iOffset < 0} { set iOffset 0 } + if {$iLimit < 0 } { + set result [lrange $::I $iOffset end] + } else { + set result [lrange $::I $iOffset [expr $iLimit+$iOffset-1]] + } + uplevel [list do_execsql_test $tn [subst -nocommands { + WITH ii(a) AS ( + VALUES(1) + UNION ALL + SELECT a+1 FROM ii WHERE a<20 + LIMIT $iLimit OFFSET $iOffset + ) + SELECT * FROM ii + }] $result] +} + +limit_test 9.1 20 0 +limit_test 9.2 0 0 +limit_test 9.3 19 1 +limit_test 9.4 20 -1 +limit_test 9.5 5 5 +limit_test 9.6 0 -1 +limit_test 9.7 40 -1 +limit_test 9.8 -1 -1 +limit_test 9.9 -1 -1 + +#-------------------------------------------------------------------------- +# Test the ORDER BY clause on recursive tables. +# + +do_execsql_test 10.1 { + DROP TABLE IF EXISTS tree; + CREATE TABLE tree(id INTEGER PRIMARY KEY, parentid, payload); +} + +proc insert_into_tree {L} { + db eval { DELETE FROM tree } + foreach key $L { + unset -nocomplain parentid + foreach seg [split $key /] { + if {$seg==""} continue + set id [db one { + SELECT id FROM tree WHERE parentid IS $parentid AND payload=$seg + }] + if {$id==""} { + db eval { INSERT INTO tree VALUES(NULL, $parentid, $seg) } + set parentid [db last_insert_rowid] + } else { + set parentid $id + } + } + } +} + +insert_into_tree { + /a/a/a + /a/b/c + /a/b/c/d + /a/b/d +} +do_execsql_test 10.2 { + WITH flat(fid, p) AS ( + SELECT id, '/' || payload FROM tree WHERE parentid IS NULL + UNION ALL + SELECT id, p || '/' || payload FROM flat, tree WHERE parentid=fid + ) + SELECT p FROM flat ORDER BY p; +} { + /a /a/a /a/a/a + /a/b /a/b/c /a/b/c/d + /a/b/d +} + +# Scan the tree-structure currently stored in table tree. Return a list +# of nodes visited. +# +proc scan_tree {bDepthFirst bReverse} { + + set order "ORDER BY " + if {$bDepthFirst==0} { append order "2 ASC," } + if {$bReverse==0} { + append order " 3 ASC" + } else { + append order " 3 DESC" + } + + db eval " + WITH flat(fid, depth, p) AS ( + SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL + UNION ALL + SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid + $order + ) + SELECT p FROM flat; + " +} + +insert_into_tree { + /a/b + /a/b/c + /a/d + /a/d/e + /a/d/f + /g/h +} + +# Breadth first, siblings in ascending order. +# +do_test 10.3 { + scan_tree 0 0 +} [list {*}{ + /a /g + /a/b /a/d /g/h + /a/b/c /a/d/e /a/d/f +}] + +# Depth first, siblings in ascending order. +# +do_test 10.4 { + scan_tree 1 0 +} [list {*}{ + /a /a/b /a/b/c + /a/d /a/d/e + /a/d/f + /g /g/h +}] + +# Breadth first, siblings in descending order. +# +do_test 10.5 { + scan_tree 0 1 +} [list {*}{ + /g /a + /g/h /a/d /a/b + /a/d/f /a/d/e /a/b/c +}] + +# Depth first, siblings in ascending order. +# +do_test 10.6 { + scan_tree 1 1 +} [list {*}{ + /g /g/h + /a /a/d /a/d/f + /a/d/e + /a/b /a/b/c +}] + # Test cases to illustrate on the ORDER BY clause on a recursive query can be # used to control depth-first versus breath-first search in a tree. # -do_execsql_test 9.1 { +do_execsql_test 11.1 { CREATE TABLE org( name TEXT PRIMARY KEY, boss TEXT REFERENCES org @@ -513,7 +667,7 @@ do_execsql_test 9.1 { # The previous query used "ORDER BY level" to yield a breath-first search. # Change that to "ORDER BY level DESC" for a depth-first search. # -do_execsql_test 9.2 { +do_execsql_test 11.2 { WITH RECURSIVE under_alice(name,level) AS ( VALUES('Alice','0') @@ -544,7 +698,7 @@ do_execsql_test 9.2 { # Without an ORDER BY clause, the recursive query should use a FIFO, # resulting in a breath-first search. # -do_execsql_test 9.3 { +do_execsql_test 11.3 { WITH RECURSIVE under_alice(name,level) AS ( VALUES('Alice','0') @@ -572,3 +726,4 @@ do_execsql_test 9.3 { .........Olivia}} finish_test + From 6ef5e12e1f8af8458cd7fd0623f36554b03580ec Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 24 Jan 2014 17:03:55 +0000 Subject: [PATCH 05/14] Fix harmless compiler warnings in the Tcl interface. FossilOrigin-Name: 35bc81f5ad4503c0db03127ba3c2ee4ce5227448 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index f46cfae2f5..d3ca0de3ef 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sfor\sLIMIT\sand\sORDER\sBY\son\srecursive\sCTEs. -D 2014-01-24T16:57:42.837 +C Fix\sharmless\scompiler\swarnings\sin\sthe\sTcl\sinterface. +D 2014-01-24T17:03:55.776 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -228,7 +228,7 @@ F src/sqliteInt.h 87a90ad4818ac5d68d3463eb7fe3ed96e5209b25 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e -F src/tclsqlite.c 46073db71011b6542fde1f234c56a076d5ff23f9 +F src/tclsqlite.c 21ca0043d7c48cde5dabed5c1116eee1be692f62 F src/test1.c 2401eee14a4309a7cfe2aeb2f30ad517a1d9c299 F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35 F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P b1824344ea4918a13abbda4a3b7134d35fd867c4 -R 9a46b9863f9dd82900d571672109f9d1 -U dan -Z c5f919f56b9fa0112bb7211064a506d1 +P 67d6c42d44cb191368ce20f553b32fcb14bfc4d7 +R 4c6f56cfb9673c8d50f2c5c8d045a419 +U mistachkin +Z 1e8effcea2fae186977e2dc88d96ee04 diff --git a/manifest.uuid b/manifest.uuid index 44c9c799f8..6840f3457c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67d6c42d44cb191368ce20f553b32fcb14bfc4d7 \ No newline at end of file +35bc81f5ad4503c0db03127ba3c2ee4ce5227448 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 1e81912526..969a83ad45 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -873,7 +873,7 @@ static int auth_callback( const char *zArg3, const char *zArg4 ){ - char *zCode; + const char *zCode; Tcl_DString str; int rc; const char *zReply; @@ -999,7 +999,7 @@ static int DbTransPostCmd( Tcl_Interp *interp, /* Tcl interpreter */ int result /* Result of evaluating SCRIPT */ ){ - static const char *azEnd[] = { + static const char *const azEnd[] = { "RELEASE _tcl_transaction", /* rc==TCL_ERROR, nTransaction!=0 */ "COMMIT", /* rc!=TCL_ERROR, nTransaction==0 */ "ROLLBACK TO _tcl_transaction ; RELEASE _tcl_transaction", @@ -1937,7 +1937,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ Tcl_AppendResult(interp, pDb->zCommit, 0); } }else{ - char *zCommit; + const char *zCommit; int len; if( pDb->zCommit ){ Tcl_Free(pDb->zCommit); @@ -2010,14 +2010,14 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ char *zSql; /* An SQL statement */ char *zLine; /* A single line of input from the file */ char **azCol; /* zLine[] broken up into columns */ - char *zCommit; /* How to commit changes */ + const char *zCommit; /* How to commit changes */ FILE *in; /* The input file */ int lineno = 0; /* Line number of input file */ char zLineNum[80]; /* Line number print buffer */ Tcl_Obj *pResult; /* interp result */ - char *zSep; - char *zNull; + const char *zSep; + const char *zNull; if( objc<5 || objc>7 ){ Tcl_WrongNumArgs(interp, 2, objv, "CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?"); @@ -2935,7 +2935,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ if( objc==2 ){ zArg = Tcl_GetStringFromObj(objv[1], 0); if( strcmp(zArg,"-version")==0 ){ - Tcl_AppendResult(interp,sqlite3_version,0); + Tcl_AppendResult(interp,sqlite3_libversion(),0); return TCL_OK; } if( strcmp(zArg,"-has-codec")==0 ){ @@ -3017,7 +3017,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ zErrMsg = 0; p = (SqliteDb*)Tcl_Alloc( sizeof(*p) ); if( p==0 ){ - Tcl_SetResult(interp, "malloc failed", TCL_STATIC); + Tcl_SetResult(interp, (char *)"malloc failed", TCL_STATIC); return TCL_ERROR; } memset(p, 0, sizeof(*p)); From 53bed45ecb66ba6ddd835a448adebdb61c2a81dc Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 24 Jan 2014 20:37:18 +0000 Subject: [PATCH 06/14] Select collation sequences for ORDER BY expressions attached to recursive CTEs in the same way as they are selected for other compound SELECT statements. FossilOrigin-Name: 9554519c126c5e714421a82fd2e8aa9b19e11493 --- manifest | 16 ++++----- manifest.uuid | 2 +- src/select.c | 67 +++++++++++++++++++++++------------- test/with1.test | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 32 deletions(-) diff --git a/manifest b/manifest index d3ca0de3ef..ebef0b5e83 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings\sin\sthe\sTcl\sinterface. -D 2014-01-24T17:03:55.776 +C Select\scollation\ssequences\sfor\sORDER\sBY\sexpressions\sattached\sto\srecursive\sCTEs\sin\sthe\ssame\sway\sas\sthey\sare\sselected\sfor\sother\scompound\sSELECT\sstatements. +D 2014-01-24T20:37:18.933 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 93764e0d81946c070e2c7f1127f35e21efabbcc3 +F src/select.c d88d739b7af398b8d5b6856d1d479b42d15c419d F src/shell.c 24722d24d4ea8ca93db35e44db7308de786767ca F src/sqlite.h.in eed7f7d66a60daaa7b4a597dcd9bad87aad9611b F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e @@ -1092,7 +1092,7 @@ F test/wild001.test bca33f499866f04c24510d74baf1e578d4e44b1c F test/win32heap.test ea19770974795cff26e11575e12d422dbd16893c F test/win32lock.test 7a6bd73a5dcdee39b5bb93e92395e1773a194361 F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d -F test/with1.test 6c9c27b76e320d0ae3a3fc9ff6b236018201470d +F test/with1.test ce15d69d34a2576b0e47d78c244d1ba2a31679d1 F test/with2.test 2fe78fcd8deef2a0f9cfc49bfc755911d0b3fd64 F test/withM.test e97f2a8c506ab3ea9eab94e6f6072f6cc924c991 F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 67d6c42d44cb191368ce20f553b32fcb14bfc4d7 -R 4c6f56cfb9673c8d50f2c5c8d045a419 -U mistachkin -Z 1e8effcea2fae186977e2dc88d96ee04 +P 35bc81f5ad4503c0db03127ba3c2ee4ce5227448 +R c1a71fcb2b287542b440975ad8562a1c +U dan +Z 0004644f36087f5d68980e2ae5cf51c5 diff --git a/manifest.uuid b/manifest.uuid index 6840f3457c..7673b5df8f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -35bc81f5ad4503c0db03127ba3c2ee4ce5227448 \ No newline at end of file +9554519c126c5e714421a82fd2e8aa9b19e11493 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 98ed526e08..9efa822a8c 100644 --- a/src/select.c +++ b/src/select.c @@ -1725,6 +1725,44 @@ static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){ } return pRet; } + +/* +** The select statement passed as the second parameter is a compound SELECT +** with an ORDER BY clause. This function allocates and returns a KeyInfo +** structure suitable for implementing the ORDER BY. +** +** Space to hold the KeyInfo structure is obtained from malloc. The calling +** function is responsible for ensuring that this structure is eventually +** freed. +*/ +static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ + ExprList *pOrderBy = p->pOrderBy; + int nOrderBy = p->pOrderBy->nExpr; + sqlite3 *db = pParse->db; + KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); + if( pRet ){ + int i; + for(i=0; ia[i]; + Expr *pTerm = pItem->pExpr; + CollSeq *pColl; + + if( pTerm->flags & EP_Collate ){ + pColl = sqlite3ExprCollSeq(pParse, pTerm); + }else{ + pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1); + if( pColl==0 ) pColl = db->pDfltColl; + pOrderBy->a[i].pExpr = + sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); + } + assert( sqlite3KeyInfoIsWriteable(pRet) ); + pRet->aColl[i] = pColl; + pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder; + } + } + + return pRet; +} #endif /* SQLITE_OMIT_COMPOUND_SELECT */ #ifndef SQLITE_OMIT_CTE @@ -1799,6 +1837,7 @@ static void generateWithRecursiveQuery( regOffset = p->iOffset; p->pLimit = p->pOffset = 0; p->iLimit = p->iOffset = 0; + pOrderBy = p->pOrderBy; /* Locate the cursor number of the Current table */ for(i=0; ALWAYS(inSrc); i++){ @@ -1808,10 +1847,6 @@ static void generateWithRecursiveQuery( } } - /* Detach the ORDER BY clause from the compound SELECT */ - pOrderBy = p->pOrderBy; - p->pOrderBy = 0; - /* Allocate cursors numbers for Queue and Distinct. The cursor number for ** the Distinct table must be exactly one greater than Queue in order ** for the SRT_DistTable and SRT_DistQueue destinations to work. */ @@ -1828,7 +1863,7 @@ static void generateWithRecursiveQuery( regCurrent = ++pParse->nMem; sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol); if( pOrderBy ){ - KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pOrderBy, 1); + KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1); sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0, (char*)pKeyInfo, P4_KEYINFO); destQueue.pOrderBy = pOrderBy; @@ -1841,6 +1876,9 @@ static void generateWithRecursiveQuery( p->selFlags |= SF_UsesEphemeral; } + /* Detach the ORDER BY clause from the compound SELECT */ + p->pOrderBy = 0; + /* Store the results of the setup-query in Queue. */ rc = sqlite3Select(pParse, pSetup, &destQueue); if( rc ) goto end_of_recursive_query; @@ -2625,24 +2663,7 @@ static int multiSelectOrderBy( && pItem->u.x.iOrderByCol<=p->pEList->nExpr ); aPermute[i] = pItem->u.x.iOrderByCol - 1; } - pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); - if( pKeyMerge ){ - for(i=0; ia[i].pExpr; - if( pTerm->flags & EP_Collate ){ - pColl = sqlite3ExprCollSeq(pParse, pTerm); - }else{ - pColl = multiSelectCollSeq(pParse, p, aPermute[i]); - if( pColl==0 ) pColl = db->pDfltColl; - pOrderBy->a[i].pExpr = - sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); - } - assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); - pKeyMerge->aColl[i] = pColl; - pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; - } - } + pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1); }else{ pKeyMerge = 0; } diff --git a/test/with1.test b/test/with1.test index 486f025c64..2fca12817f 100644 --- a/test/with1.test +++ b/test/with1.test @@ -607,6 +607,97 @@ do_test 10.6 { }] +# Test name resolution in ORDER BY clauses. +# +do_catchsql_test 10.7.1 { + WITH t(a) AS ( + SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY a + ) + SELECT * FROM t +} {1 {1st ORDER BY term does not match any column in the result set}} +do_execsql_test 10.7.2 { + WITH t(a) AS ( + SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY b + ) + SELECT * FROM t +} {1 2 3 4 5} +do_execsql_test 10.7.3 { + WITH t(a) AS ( + SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY c + ) + SELECT * FROM t +} {1 2 3 4 5} + +# Test COLLATE clauses attached to ORDER BY. +# +insert_into_tree { + /a/b + /a/C + /a/d + /B/e + /B/F + /B/g + /c/h + /c/I + /c/j +} + +do_execsql_test 10.8.1 { + WITH flat(fid, depth, p) AS ( + SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL + UNION ALL + SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid + ORDER BY 2, 3 COLLATE nocase + ) + SELECT p FROM flat; +} { + /a /B /c + /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j +} +do_execsql_test 10.8.2 { + WITH flat(fid, depth, p) AS ( + SELECT id, 1, ('/' || payload) COLLATE nocase + FROM tree WHERE parentid IS NULL + UNION ALL + SELECT id, depth+1, (p||'/'||payload) + FROM flat, tree WHERE parentid=fid + ORDER BY 2, 3 + ) + SELECT p FROM flat; +} { + /a /B /c + /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j +} + +do_execsql_test 10.8.3 { + WITH flat(fid, depth, p) AS ( + SELECT id, 1, ('/' || payload) + FROM tree WHERE parentid IS NULL + UNION ALL + SELECT id, depth+1, (p||'/'||payload) COLLATE nocase + FROM flat, tree WHERE parentid=fid + ORDER BY 2, 3 + ) + SELECT p FROM flat; +} { + /a /B /c + /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j +} + +do_execsql_test 10.8.4.1 { + CREATE TABLE tst(a,b); + INSERT INTO tst VALUES('a', 'A'); + INSERT INTO tst VALUES('b', 'B'); + INSERT INTO tst VALUES('c', 'C'); + SELECT a COLLATE nocase FROM tst UNION ALL SELECT b FROM tst ORDER BY 1; +} {a A b B c C} +do_execsql_test 10.8.4.2 { + SELECT a FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1; +} {A B C a b c} +do_execsql_test 10.8.4.3 { + SELECT a||'' FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1; +} {a A b B c C} + # Test cases to illustrate on the ORDER BY clause on a recursive query can be # used to control depth-first versus breath-first search in a tree. # From 693e671936cd7053e874186228b9b0454a643893 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 24 Jan 2014 22:58:00 +0000 Subject: [PATCH 07/14] Fixes for various clang warnings. FossilOrigin-Name: 87bf60637e5863c54c5e2d05aaaca0835b7aace8 --- ext/fts3/fts3_hash.c | 4 ++-- manifest | 38 +++++++++++++++++++------------------- manifest.uuid | 2 +- src/delete.c | 3 ++- src/expr.c | 5 +++-- src/func.c | 2 +- src/os_unix.c | 2 +- src/pcache1.c | 3 ++- src/sqliteInt.h | 1 + src/test8.c | 2 +- src/update.c | 5 +++-- src/util.c | 3 ++- src/vdbe.c | 2 +- src/vdbeaux.c | 26 +++++++++++++++----------- src/vdbemem.c | 2 +- 15 files changed, 55 insertions(+), 45 deletions(-) diff --git a/ext/fts3/fts3_hash.c b/ext/fts3/fts3_hash.c index 57c59b587a..1a32a537b4 100644 --- a/ext/fts3/fts3_hash.c +++ b/ext/fts3/fts3_hash.c @@ -96,13 +96,13 @@ void sqlite3Fts3HashClear(Fts3Hash *pH){ */ static int fts3StrHash(const void *pKey, int nKey){ const char *z = (const char *)pKey; - int h = 0; + unsigned h = 0; if( nKey<=0 ) nKey = (int) strlen(z); while( nKey > 0 ){ h = (h<<3) ^ h ^ *z++; nKey--; } - return h & 0x7fffffff; + return (int)(h & 0x7fffffff); } static int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ if( n1!=n2 ) return 1; diff --git a/manifest b/manifest index ebef0b5e83..4866e9a371 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Select\scollation\ssequences\sfor\sORDER\sBY\sexpressions\sattached\sto\srecursive\sCTEs\sin\sthe\ssame\sway\sas\sthey\sare\sselected\sfor\sother\scompound\sSELECT\sstatements. -D 2014-01-24T20:37:18.933 +C Fixes\sfor\svarious\sclang\swarnings. +D 2014-01-24T22:58:00.303 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -83,7 +83,7 @@ F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h eb5f8029589f3d8f1dc7fd50c773326a640388b1 F ext/fts3/fts3_aux.c 5c211e17a64885faeb16b9ba7772f9d5445c2365 F ext/fts3/fts3_expr.c 5165c365cb5a035f5be8bb296f7aa3211d43e4ac -F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 +F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60 F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5 F ext/fts3/fts3_porter.c 7f8b4bf5af7c0f20f73b8e87e14fa9298f52e290 @@ -174,11 +174,11 @@ F src/callback.c 174e3c8656bc29f91d710ab61550d16eea34be98 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 77779efbe78dd678d84bfb4fc2e87b6b6ad8dccd F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 -F src/delete.c 91e1321021db5dc266360531b8b6550009d771ff -F src/expr.c 61f9105820d6702d7153dfb6ca3d58e751a5e95a +F src/delete.c 22e54756c08b194a29d51cd6552922028b3e21a9 +F src/expr.c 96f00a262308f3f97d2afd8519c7a284e25829f3 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 2ab0f5384b70594468ef3ac5c7ed8ca24bfd17d5 -F src/func.c 6325ac2ec10833ccf4d5c36d323709221d37ea19 +F src/func.c f4499b39d66b71825514334ce67b32ff14bd19f5 F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 F src/hash.c d139319967164f139c8d1bb8a11b14db9c4ba3cd F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -205,14 +205,14 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c 3a4dcb554d3c915075766162f28c3fd4cdb75968 +F src/os_unix.c f3ed0e406cbf9c820565b2118232d0796346130f F src/os_win.c 1b21af72c5fa6f9e519a5fcab33e80d182b1aedb F src/pager.c efa923693e958696eee69b205a20bfbc402c8480 F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 F src/parse.y bd51bc17cbfe7549adb4ca3747b1c3d384645065 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 -F src/pcache1.c 57fee9a9a617218f5037afbbe49b09da65bde56b +F src/pcache1.c 102e6f5a2fbc646154463eb856d1fd716867b64c F src/pragma.c ed409ce4104cf4d9de6ead40ace70974f124853b F src/prepare.c 677521ab7132615a8a26107a1d1c3132f44ae337 F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269 @@ -224,7 +224,7 @@ F src/shell.c 24722d24d4ea8ca93db35e44db7308de786767ca F src/sqlite.h.in eed7f7d66a60daaa7b4a597dcd9bad87aad9611b F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 87a90ad4818ac5d68d3463eb7fe3ed96e5209b25 +F src/sqliteInt.h 22c8f7112f2fa8e778bbd9d331cbebff8c645574 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -236,7 +236,7 @@ F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 F src/test6.c 41cacf3b0dd180823919bf9e1fbab287c9266723 F src/test7.c 72b732baa5642f795655ba1126ea032af46ecfd2 -F src/test8.c c7aab1d9fbbf54fc33d43b73aa24aa55f9eaf534 +F src/test8.c 54ccd7b1df5062f0ecbf50a8f7b618f8b1f13b20 F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 21e11293a2f72080eda70e1124e9102044531cd8 F src/test_autoext.c dea8a01a7153b9adc97bd26161e4226329546e12 @@ -276,17 +276,17 @@ F src/test_vfstrace.c 3a0ab304682fecbceb689e7d9b904211fde11d78 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 6da2de6e12218ccb0aea5184b56727d011f4bee7 F src/trigger.c 5c1c0b899ac0ce284763dcb8fdbaa38ecf15ef98 -F src/update.c c2706a6eb232a96345c35b7e1e75a188e26812bb +F src/update.c a7df6fffce6bfedc578fda6136dd33e34a63f8ee F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 -F src/util.c e71f19b272f05c8695cf747b4bac1732685f9e5c +F src/util.c 15ac2627f548f5481d0d7e6c4eb67be673027695 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 -F src/vdbe.c dede894c2990329f8bc5a70da7de44ce8c3c6bf5 +F src/vdbe.c 5fe94e13fa56c50edb75263706b6fbcc860a3980 F src/vdbe.h e6c4c610fcabad4fa80ebb1efc6822a9367e2b26 F src/vdbeInt.h 42db251e9f863401ff847b90d5fe1614c89a6a56 F src/vdbeapi.c ce4e68ea4842cc6081046f533d088dcf01d247ad -F src/vdbeaux.c 9f4bfc52672acbb0bb4493d6a03603dc5a595ac1 +F src/vdbeaux.c f228f45f5edc8a4cf97e965236519cdcb6baf99b F src/vdbeblob.c bc40f98f256f0b34116d6a44b114da4a81a15d33 -F src/vdbemem.c 0e69351b2c6ff7d8b638688c0ae336a26befa6b2 +F src/vdbemem.c 23cdc14ed43e0aafa57bd72b9bf3d5b1641afa91 F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767 F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 35bc81f5ad4503c0db03127ba3c2ee4ce5227448 -R c1a71fcb2b287542b440975ad8562a1c -U dan -Z 0004644f36087f5d68980e2ae5cf51c5 +P 9554519c126c5e714421a82fd2e8aa9b19e11493 +R c581db3b6e5511f2dddae190976cfffb +U drh +Z 8b12a1dace1d4f79f17e9cd04b2cccdf diff --git a/manifest.uuid b/manifest.uuid index 7673b5df8f..d7e5fe4225 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9554519c126c5e714421a82fd2e8aa9b19e11493 \ No newline at end of file +87bf60637e5863c54c5e2d05aaaca0835b7aace8 \ No newline at end of file diff --git a/src/delete.c b/src/delete.c index e448e47b02..ecf850cf8e 100644 --- a/src/delete.c +++ b/src/delete.c @@ -636,7 +636,8 @@ void sqlite3GenerateRowDelete( ** used by any BEFORE and AFTER triggers that exist. */ sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); for(iCol=0; iColnCol; iCol++){ - if( mask==0xffffffff || mask&(1<a[i].pExpr) ){ - constMask |= (1<funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){ pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr); diff --git a/src/func.c b/src/func.c index 1d6ec9f6ee..e657558ba2 100644 --- a/src/func.c +++ b/src/func.c @@ -137,7 +137,7 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); if( iVal<0 ){ - if( (iVal<<1)==0 ){ + if( iVal==SMALLEST_INT64 ){ /* IMP: R-31676-45509 If X is the integer -9223372036854775808 ** then abs(X) throws an integer overflow error since there is no ** equivalent positive 64-bit two complement value. */ diff --git a/src/os_unix.c b/src/os_unix.c index 96cd5e6191..b539550220 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4097,7 +4097,7 @@ static int unixShmSystemLock( #ifdef SQLITE_DEBUG { u16 mask; OSTRACE(("SHM-LOCK ")); - mask = ofst>31 ? 0xffffffff : (1<<(ofst+n)) - (1<31 ? 0xffff : (1<<(ofst+n)) - (1<bPurgeable || createFlag!=1 ); assert( pCache->bPurgeable || pCache->nMin==0 ); assert( pCache->bPurgeable==0 || pCache->nMin==10 ); @@ -825,7 +826,7 @@ fetch_out: pCache->iMaxKey = iKey; } pcache1LeaveMutex(pGroup); - return &pPage->page; + return (sqlite3_pcache_page*)pPage; } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c1fa7b69ad..f58d826788 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1982,6 +1982,7 @@ typedef u64 Bitmask; ** A bit in a Bitmask */ #define MASKBIT(n) (((Bitmask)1)<<(n)) +#define MASKBIT32(n) (((unsigned int)1)<<(n)) /* ** The following structure describes the FROM clause of a SELECT statement. diff --git a/src/test8.c b/src/test8.c index 9b8b545fa6..8bc835d638 100644 --- a/src/test8.c +++ b/src/test8.c @@ -892,7 +892,7 @@ static int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ pIdxInfo->estimatedCost = cost; }else if( useIdx ){ /* Approximation of log2(nRow). */ - for( ii=0; ii<(sizeof(int)*8); ii++ ){ + for( ii=0; ii<(sizeof(int)*8)-1; ii++ ){ if( nRow & (1<estimatedCost = (double)ii; } diff --git a/src/update.c b/src/update.c index d62d0d3245..a7da4ce71f 100644 --- a/src/update.c +++ b/src/update.c @@ -467,9 +467,10 @@ void sqlite3Update( ); for(i=0; inCol; i++){ if( oldmask==0xffffffff - || (i<32 && (oldmask & (1<aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){ + testcase( oldmask!=0xffffffff && i==31 ); sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); }else{ sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); @@ -504,7 +505,7 @@ void sqlite3Update( j = aXRef[i]; if( j>=0 ){ sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i); - }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<31 || (newmask & MASKBIT32(i)) ){ /* This branch loads the value of a column that will not be changed ** into a register. This is done if there are no BEFORE triggers, or ** if there are one or more BEFORE triggers that use this value via diff --git a/src/util.c b/src/util.c index 362a5d8970..3f3a9649e0 100644 --- a/src/util.c +++ b/src/util.c @@ -1001,7 +1001,8 @@ int sqlite3VarintLen(u64 v){ ** Read or write a four-byte big-endian integer value. */ u32 sqlite3Get4byte(const u8 *p){ - return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; + testcase( p[0]&0x80 ); + return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]; } void sqlite3Put4byte(unsigned char *p, u32 v){ p[0] = (u8)(v>>24); diff --git a/src/vdbe.c b/src/vdbe.c index 10a70750e3..30c9269ea4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -6174,7 +6174,7 @@ case OP_Trace: { if( zTrace ){ int i; for(i=0; inDb; i++){ - if( ((1<btreeMask)==0 ) continue; + if( MASKBIT(i) & p->btreeMask)==0 ) continue; sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); } } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index faabaf75d7..e06f091aed 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2615,8 +2615,9 @@ void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ while( *pp ){ AuxData *pAux = *pp; if( (iOp<0) - || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<iArg)))) + || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg)))) ){ + testcase( pAux->iArg==31 ); if( pAux->xDelete ){ pAux->xDelete(pAux->pAux); } @@ -2931,6 +2932,9 @@ u32 sqlite3VdbeSerialGet( u32 serial_type, /* Serial type to deserialize */ Mem *pMem /* Memory cell to write value into */ ){ + u64 x; + u32 y; + int i; switch( serial_type ){ case 10: /* Reserved for future use */ case 11: /* Reserved for future use */ @@ -2944,23 +2948,26 @@ u32 sqlite3VdbeSerialGet( return 1; } case 2: { /* 2-byte signed integer */ - pMem->u.i = (((signed char)buf[0])<<8) | buf[1]; + i = 256*(signed char)buf[0] | buf[1]; + pMem->u.i = (i64)i; pMem->flags = MEM_Int; return 2; } case 3: { /* 3-byte signed integer */ - pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2]; + i = 65536*(signed char)buf[0] | (buf[1]<<8) | buf[2]; + pMem->u.i = (i64)i; pMem->flags = MEM_Int; return 3; } case 4: { /* 4-byte signed integer */ - pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; + y = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; + pMem->u.i = (i64)*(int*)&y; pMem->flags = MEM_Int; return 4; } case 5: { /* 6-byte signed integer */ - u64 x = (((signed char)buf[0])<<8) | buf[1]; - u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; + u64 x = 256*(signed char)buf[0] + buf[1]; + u32 y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; x = (x<<32) | y; pMem->u.i = *(i64*)&x; pMem->flags = MEM_Int; @@ -2968,8 +2975,6 @@ u32 sqlite3VdbeSerialGet( } case 6: /* 8-byte signed integer */ case 7: { /* IEEE floating point */ - u64 x; - u32 y; #if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT) /* Verify that integers and floating point values use the same ** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is @@ -2982,9 +2987,8 @@ u32 sqlite3VdbeSerialGet( swapMixedEndianFloat(t2); assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 ); #endif - - x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; - y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; + x = ((unsigned)buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; + y = ((unsigned)buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7]; x = (x<<32) | y; if( serial_type==6 ){ pMem->u.i = *(i64*)&x; diff --git a/src/vdbemem.c b/src/vdbemem.c index 3beccd92db..9a621d1f73 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -598,7 +598,7 @@ void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){ /* ** Size of struct Mem not including the Mem.zMalloc member. */ -#define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc)) +#define MEMCELLSIZE offsetof(Mem,zMalloc) /* ** Make an shallow copy of pFrom into pTo. Prior contents of From b68b97789ec4851015f3bb05444088e68cc7cf20 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 25 Jan 2014 12:16:53 +0000 Subject: [PATCH 08/14] Fix a problem causing SQLITE_OMIT_COMPOUND_SELECT builds to fail. FossilOrigin-Name: b30db0ac3096b43d55a6da40cafc7de569082bf8 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/select.c | 4 +--- tool/omittest.tcl | 1 + 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 4866e9a371..1a65c31de1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fixes\sfor\svarious\sclang\swarnings. -D 2014-01-24T22:58:00.303 +C Fix\sa\sproblem\scausing\sSQLITE_OMIT_COMPOUND_SELECT\sbuilds\sto\sfail. +D 2014-01-25T12:16:53.164 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/printf.c 85d07756e45d7496d19439dcae3e6e9e0090f269 F src/random.c d10c1f85b6709ca97278428fd5db5bbb9c74eece F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c d88d739b7af398b8d5b6856d1d479b42d15c419d +F src/select.c a421f3fb7f52a3c0b37f5caeabd27799e8a9ae58 F src/shell.c 24722d24d4ea8ca93db35e44db7308de786767ca F src/sqlite.h.in eed7f7d66a60daaa7b4a597dcd9bad87aad9611b F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e @@ -1127,7 +1127,7 @@ F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 F tool/mkvsix.tcl 6477fb9dab838b7eea1eed50658ff1cda04850b5 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 -F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 +F tool/omittest.tcl 34d7ac01fe4fd18e3637f64abe12c40eca0f6b97 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 9554519c126c5e714421a82fd2e8aa9b19e11493 -R c581db3b6e5511f2dddae190976cfffb -U drh -Z 8b12a1dace1d4f79f17e9cd04b2cccdf +P 87bf60637e5863c54c5e2d05aaaca0835b7aace8 +R 69ab88b9bb0a730071944ebfada4d77f +U dan +Z d44703c5b70f5ed4164d3c8bc064c718 diff --git a/manifest.uuid b/manifest.uuid index d7e5fe4225..ceaaffde0a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -87bf60637e5863c54c5e2d05aaaca0835b7aace8 \ No newline at end of file +b30db0ac3096b43d55a6da40cafc7de569082bf8 \ No newline at end of file diff --git a/src/select.c b/src/select.c index 9efa822a8c..c78d997806 100644 --- a/src/select.c +++ b/src/select.c @@ -1763,7 +1763,6 @@ static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ return pRet; } -#endif /* SQLITE_OMIT_COMPOUND_SELECT */ #ifndef SQLITE_OMIT_CTE /* @@ -1921,7 +1920,7 @@ end_of_recursive_query: p->pOffset = pOffset; return; } -#endif +#endif /* SQLITE_OMIT_CTE */ /* Forward references */ static int multiSelectOrderBy( @@ -1931,7 +1930,6 @@ static int multiSelectOrderBy( ); -#ifndef SQLITE_OMIT_COMPOUND_SELECT /* ** This routine is called to process a compound query form from ** two or more separate queries using UNION, UNION ALL, EXCEPT, or diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 3351b96b32..5437f2eb01 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -190,6 +190,7 @@ proc main {argv} { SQLITE_OMIT_COMPILEOPTION_DIAGS \ SQLITE_OMIT_COMPLETE \ SQLITE_OMIT_COMPOUND_SELECT \ + SQLITE_OMIT_CTE \ SQLITE_OMIT_DATETIME_FUNCS \ SQLITE_OMIT_DECLTYPE \ SQLITE_OMIT_DEPRECATED \ From abfe034692ad10d6b96c2e80975fec1c1568eee8 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 27 Jan 2014 08:48:10 +0000 Subject: [PATCH 09/14] Fix some problems in test scripts. No code changes. FossilOrigin-Name: 08acfc65877e207f1a62d31a14afb4add20c4c35 --- manifest | 14 +++++------ manifest.uuid | 2 +- test/corruptH.test | 1 + test/spellfix.test | 58 ++++++++++++++++++++++++---------------------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/manifest b/manifest index 1a65c31de1..ef413f44a3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\scausing\sSQLITE_OMIT_COMPOUND_SELECT\sbuilds\sto\sfail. -D 2014-01-25T12:16:53.164 +C Fix\ssome\sproblems\sin\stest\sscripts.\sNo\scode\schanges. +D 2014-01-27T08:48:10.724 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -406,7 +406,7 @@ F test/corruptD.test b3c205fac7952b1de645ce44bb02335cd9e3e040 F test/corruptE.test 193b4ca4e927e77c1d5f4f56203ddc998432a7ee F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 F test/corruptG.test c150f156dace653c00a121ad0f5772a0568c41ba -F test/corruptH.test 0a247f3dc8a8f3578db5f639d86c6bb4d520207f +F test/corruptH.test 7c02f5d928499bc1b68ed4610bfc2c3f12565a35 F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f @@ -825,7 +825,7 @@ F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b F test/speedtest1.c 7130d2cb6db45baa553a4ab2f715116c71c2d9f4 -F test/spellfix.test 674db5da8b16d2b54939b68ccc0ac31ca53d9977 +F test/spellfix.test 61309f5efbec53603b3f86457d34a504f80abafe F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 87bf60637e5863c54c5e2d05aaaca0835b7aace8 -R 69ab88b9bb0a730071944ebfada4d77f +P b30db0ac3096b43d55a6da40cafc7de569082bf8 +R c469588e2189e74bc2d9214e1aed9609 U dan -Z d44703c5b70f5ed4164d3c8bc064c718 +Z 7abd7bfcd6752912e65623c5ee39477d diff --git a/manifest.uuid b/manifest.uuid index ceaaffde0a..081ba3ceea 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b30db0ac3096b43d55a6da40cafc7de569082bf8 \ No newline at end of file +08acfc65877e207f1a62d31a14afb4add20c4c35 \ No newline at end of file diff --git a/test/corruptH.test b/test/corruptH.test index 23f80632b1..875a92f504 100644 --- a/test/corruptH.test +++ b/test/corruptH.test @@ -66,6 +66,7 @@ reset_db # Initialize the database. # do_execsql_test 2.1 { + PRAGMA auto_vacuum=0; PRAGMA page_size=1024; CREATE TABLE t1(a INTEGER PRIMARY KEY, b); diff --git a/test/spellfix.test b/test/spellfix.test index 3e6fdf7eec..21383c2d33 100644 --- a/test/spellfix.test +++ b/test/spellfix.test @@ -234,35 +234,37 @@ do_execsql_test 6.1.3 { SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner'; } {keener 300} -proc trace_callback {sql} { - if {[string range $sql 0 2] == "-- "} { - lappend ::trace [string range $sql 3 end] +ifcapable trace { + proc trace_callback {sql} { + if {[string range $sql 0 2] == "-- "} { + lappend ::trace [string range $sql 3 end] + } + } + + proc do_tracesql_test {tn sql {res {}}} { + set ::trace [list] + uplevel [list do_test $tn [subst -nocommands { + set vals [execsql {$sql}] + concat [set vals] [set ::trace] + }] [list {*}$res]] + } + + db trace trace_callback + do_tracesql_test 6.2.1 { + SELECT word FROM t3 WHERE rowid = 10; + } {keener + {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?} + } + do_tracesql_test 6.2.2 { + SELECT word, distance FROM t3 WHERE rowid = 10; + } {keener {} + {SELECT word, rank, NULL, langid, id FROM "main"."t3_vocab" WHERE rowid=?} + } + do_tracesql_test 6.2.3 { + SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner'; + } {keener 300 + {SELECT id, word, rank, k1 FROM "main"."t3_vocab" WHERE langid=0 AND k2>=?1 AND k2=?1 AND k2 Date: Mon, 27 Jan 2014 13:58:58 +0000 Subject: [PATCH 10/14] Fix (harmless) duplicate variable declaration. FossilOrigin-Name: 94ed9bc4207873e0f3f8114009002f56d5aff359 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index ef413f44a3..e7e1dcb4a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssome\sproblems\sin\stest\sscripts.\sNo\scode\schanges. -D 2014-01-27T08:48:10.724 +C Fix\s(harmless)\sduplicate\svariable\sdeclaration. +D 2014-01-27T13:58:58.483 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -284,7 +284,7 @@ F src/vdbe.c 5fe94e13fa56c50edb75263706b6fbcc860a3980 F src/vdbe.h e6c4c610fcabad4fa80ebb1efc6822a9367e2b26 F src/vdbeInt.h 42db251e9f863401ff847b90d5fe1614c89a6a56 F src/vdbeapi.c ce4e68ea4842cc6081046f533d088dcf01d247ad -F src/vdbeaux.c f228f45f5edc8a4cf97e965236519cdcb6baf99b +F src/vdbeaux.c a3327afa8cfcc5bb3d38f2b2a599bac5fb63c6be F src/vdbeblob.c bc40f98f256f0b34116d6a44b114da4a81a15d33 F src/vdbemem.c 23cdc14ed43e0aafa57bd72b9bf3d5b1641afa91 F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P b30db0ac3096b43d55a6da40cafc7de569082bf8 -R c469588e2189e74bc2d9214e1aed9609 -U dan -Z 7abd7bfcd6752912e65623c5ee39477d +P 08acfc65877e207f1a62d31a14afb4add20c4c35 +R 56b35e8471481c78f01b8967b6b0512c +U drh +Z cff646eb741caa60bf91c3c7dcaf59ea diff --git a/manifest.uuid b/manifest.uuid index 081ba3ceea..6180eadb1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -08acfc65877e207f1a62d31a14afb4add20c4c35 \ No newline at end of file +94ed9bc4207873e0f3f8114009002f56d5aff359 \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e06f091aed..69611622af 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2966,8 +2966,8 @@ u32 sqlite3VdbeSerialGet( return 4; } case 5: { /* 6-byte signed integer */ - u64 x = 256*(signed char)buf[0] + buf[1]; - u32 y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; + x = 256*(signed char)buf[0] + buf[1]; + y = ((unsigned)buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5]; x = (x<<32) | y; pMem->u.i = *(i64*)&x; pMem->flags = MEM_Int; From d0879bad420fcfe1106b2bbcf71e27af1208055e Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 27 Jan 2014 14:19:22 +0000 Subject: [PATCH 11/14] Fix a problem in pagerfault.test causing an assert() to fail. FossilOrigin-Name: ba8d2d507f82e2baaceadcf7ac6d71bb91f7e06b --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/pagerfault.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e7e1dcb4a5..a94442148e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\s(harmless)\sduplicate\svariable\sdeclaration. -D 2014-01-27T13:58:58.483 +C Fix\sa\sproblem\sin\spagerfault.test\scausing\san\sassert()\sto\sfail. +D 2014-01-27T14:19:22.594 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -729,7 +729,7 @@ F test/pager1.test 1acbdb14c5952a72dd43129cabdbf69aaa3ed1fa F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pager4.test b40ecb4cc7dff957ee7916e41ab21d1ed702a642 -F test/pagerfault.test 7285379906ab2f1108b8e82bbdf2d386cc8ff3ff +F test/pagerfault.test ae9ee0db5a30aecda9db8290ce3dd12e5f7bbaa1 F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8 F test/pageropt.test 6b8f6a123a5572c195ad4ae40f2987007923bbd6 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 08acfc65877e207f1a62d31a14afb4add20c4c35 -R 56b35e8471481c78f01b8967b6b0512c -U drh -Z cff646eb741caa60bf91c3c7dcaf59ea +P 94ed9bc4207873e0f3f8114009002f56d5aff359 +R 0be44d42254ead49d986d7d5578b5723 +U dan +Z 0a8e95fd0596f45df583df2ebdde1bb1 diff --git a/manifest.uuid b/manifest.uuid index 6180eadb1e..6a6b134850 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94ed9bc4207873e0f3f8114009002f56d5aff359 \ No newline at end of file +ba8d2d507f82e2baaceadcf7ac6d71bb91f7e06b \ No newline at end of file diff --git a/test/pagerfault.test b/test/pagerfault.test index 796f531c37..c0f5de69ac 100644 --- a/test/pagerfault.test +++ b/test/pagerfault.test @@ -1544,5 +1544,6 @@ do_faultsim_test pagerfault-36 -prep { sqlite3_shutdown sqlite3_config_uri 0 +sqlite3_initialize finish_test From a820c05aa03d5a7c643af73f35da3f2743bf85f4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 27 Jan 2014 15:02:07 +0000 Subject: [PATCH 12/14] Update some requirements marks to conform with improvements in the documentation. FossilOrigin-Name: be1acb610f7e594b417dd8409b7a7aa8f3af5f77 --- manifest | 18 +++++++------- manifest.uuid | 2 +- test/e_select.test | 58 ++++++++++++++++++++++----------------------- test/e_select2.test | 30 +++++++++++------------ test/printf2.test | 2 +- 5 files changed, 54 insertions(+), 56 deletions(-) diff --git a/manifest b/manifest index a94442148e..dfa2b5a9f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\spagerfault.test\scausing\san\sassert()\sto\sfail. -D 2014-01-27T14:19:22.594 +C Update\ssome\srequirements\smarks\sto\sconform\swith\simprovements\nin\sthe\sdocumentation. +D 2014-01-27T15:02:07.424 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -444,8 +444,8 @@ F test/e_fts3.test 5c02288842e4f941896fd44afdef564dd5fc1459 F test/e_insert.test 1e44f84d2abe44d66e4fbf198be4b20e3cc724a0 F test/e_reindex.test 396b7b4f0a66863b4e95116a67d93b227193e589 F test/e_resolve.test dcce9308fb13b934ce29591105d031d3e14fbba6 -F test/e_select.test d3226cb94fae4af3f198e68e71f655e106d0be47 -F test/e_select2.test 22c660a7becf0712c95e1ca1b2d9e716a1261460 +F test/e_select.test 51c062a9bda16e0ae1bbeed50806bedbd040b282 +F test/e_select2.test aceb80ab927d46fba5ce7586ebabf23e2bb0604f F test/e_update.test 312cb8f5ccfe41515a6bb092f8ea562a9bd54d52 F test/e_uri.test a2c92d80093a7efdcfbb11093651cbea87097b6b F test/e_vacuum.test 5bfbdc21b65c0abf24398d0ba31dc88d93ca77a9 @@ -741,7 +741,7 @@ F test/permutations.test af3278cbea3a19e025d5169be8193ff48dc3f862 F test/pragma.test e882183ecd21d064cec5c7aaea174fbd36293429 F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 -F test/printf2.test 414fcba6d6c10e0a5e58efd213811e5ead4635a0 +F test/printf2.test bed79b4c3e5da08ba88ad637c0bf62586843cfb1 F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc F test/queryonly.test 5f653159e0f552f0552d43259890c1089391dcca @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 94ed9bc4207873e0f3f8114009002f56d5aff359 -R 0be44d42254ead49d986d7d5578b5723 -U dan -Z 0a8e95fd0596f45df583df2ebdde1bb1 +P ba8d2d507f82e2baaceadcf7ac6d71bb91f7e06b +R 21ce223091709a0563d8c91470de6542 +U drh +Z c5e028d1cb73bb521efada71d2fc02fb diff --git a/manifest.uuid b/manifest.uuid index 6a6b134850..eeb83b19fe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ba8d2d507f82e2baaceadcf7ac6d71bb91f7e06b \ No newline at end of file +be1acb610f7e594b417dd8409b7a7aa8f3af5f77 \ No newline at end of file diff --git a/test/e_select.test b/test/e_select.test index 61646a2a31..58b8987ba6 100644 --- a/test/e_select.test +++ b/test/e_select.test @@ -333,9 +333,9 @@ do_select_tests e_select-1.1 { 6 "SELECT count(*) WHERE 1" {1} } -# EVIDENCE-OF: R-48114-33255 If there is only a single table in the -# join-source following the FROM clause, then the input data used by the -# SELECT statement is the contents of the named table. +# EVIDENCE-OF: R-45424-07352 If there is only a single table or subquery +# in the FROM clause, then the input data used by the SELECT statement +# is the contents of the named table. # # The results of the SELECT queries suggest that they are operating on the # contents of the table 'xx'. @@ -357,10 +357,10 @@ do_select_tests e_select-1.2 { 3 "SELECT sum(x), sum(y) FROM xx" {-17.89 -16.87} } -# EVIDENCE-OF: R-23593-12456 If there is more than one table specified -# as part of the join-source following the FROM keyword, then the -# contents of each named table are joined into a single dataset for the -# simple SELECT statement to operate on. +# EVIDENCE-OF: R-28355-09804 If there is more than one table or subquery +# in FROM clause then the contents of all tables and/or subqueries are +# joined into a single dataset for the simple SELECT statement to +# operate on. # # There are more detailed tests for subsequent requirements that add # more detail to this idea. We just add a single test that shows that @@ -383,10 +383,10 @@ do_select_tests e_select-1.3 { # of cartesian joins in the SELECT documentation is consistent with SQLite. # In doing so, we test the following three requirements as a side-effect: # -# EVIDENCE-OF: R-46122-14930 If the join-op is "CROSS JOIN", "INNER -# JOIN", "JOIN" or a comma (",") and there is no ON or USING clause, -# then the result of the join is simply the cartesian product of the -# left and right-hand datasets. +# EVIDENCE-OF: R-49872-03192 If the join-operator is "CROSS JOIN", +# "INNER JOIN", "JOIN" or a comma (",") and there is no ON or USING +# clause, then the result of the join is simply the cartesian product of +# the left and right-hand datasets. # # The tests are built on this assertion. Really, they test that the output # of a CROSS JOIN, JOIN, INNER JOIN or "," join matches the expected result @@ -513,11 +513,10 @@ do_select_tests e_select-1.4.5 [list \ 4 { SELECT * FROM t1 AS y INNER JOIN t1 AS x } $t1_cross_t1 \ ] - -# EVIDENCE-OF: R-22775-56496 If there is an ON clause specified, then -# the ON expression is evaluated for each row of the cartesian product -# as a boolean expression. All rows for which the expression evaluates -# to false are excluded from the dataset. +# EVIDENCE-OF: R-38465-03616 If there is an ON clause then the ON +# expression is evaluated for each row of the cartesian product as a +# boolean expression. Only rows for which the expression evaluates to +# true are included from the dataset. # foreach {tn select res} [list \ 1 { SELECT * FROM t1 %JOIN% t2 ON (1) } $t1_cross_t2 \ @@ -540,9 +539,9 @@ foreach {tn select res} [list \ do_join_test e_select-1.3.$tn $select $res } -# EVIDENCE-OF: R-63358-54862 If there is a USING clause specified as -# part of the join-constraint, then each of the column names specified -# must exist in the datasets to both the left and right of the join-op. +# EVIDENCE-OF: R-49933-05137 If there is a USING clause then each of the +# column names specified must exist in the datasets to both the left and +# right of the join-operator. # do_select_tests e_select-1.4 -error { cannot join using column %s - column not present in both tables @@ -552,10 +551,10 @@ do_select_tests e_select-1.4 -error { 3 { SELECT * FROM t3, (SELECT a AS b, b AS c FROM t1) USING (a) } "a" } -# EVIDENCE-OF: R-55987-04584 For each pair of namesake columns, the +# EVIDENCE-OF: R-22776-52830 For each pair of named columns, the # expression "lhs.X = rhs.X" is evaluated for each row of the cartesian -# product as a boolean expression. All rows for which one or more of the -# expressions evaluates to false are excluded from the result set. +# product as a boolean expression. Only rows for which all such +# expressions evaluates to true are included from the result set. # do_select_tests e_select-1.5 { 1 { SELECT * FROM t1, t3 USING (a) } {a one 1 b two 2} @@ -566,8 +565,8 @@ do_select_tests e_select-1.5 { # USING clause, the normal rules for handling affinities, collation # sequences and NULL values in comparisons apply. # -# EVIDENCE-OF: R-35466-18578 The column from the dataset on the -# left-hand side of the join operator is considered to be on the +# EVIDENCE-OF: R-38422-04402 The column from the dataset on the +# left-hand side of the join-operator is considered to be on the # left-hand side of the comparison operator (=) for the purposes of # collation sequence and affinity precedence. # @@ -622,10 +621,9 @@ foreach {tn select res} { } { do_join_test e_select-1.7.$tn $select $res } - -# EVIDENCE-OF: R-41434-12448 If the join-op is a "LEFT JOIN" or "LEFT -# OUTER JOIN", then after the ON or USING filtering clauses have been -# applied, an extra row is added to the output for each row in the +# EVIDENCE-OF: R-42531-52874 If the join-operator is a "LEFT JOIN" or +# "LEFT OUTER JOIN", then after the ON or USING filtering clauses have +# been applied, an extra row is added to the output for each row in the # original left-hand input dataset that corresponds to no rows at all in # the composite dataset (if any). # @@ -660,8 +658,8 @@ do_select_tests e_select-1.9 { 2b "SELECT * FROM t7 LEFT JOIN t8 USING (a)" {x ex 24 abc 24 y why 25 {} {}} } -# EVIDENCE-OF: R-01809-52134 If the NATURAL keyword is added to any of -# the join-ops, then an implicit USING clause is added to the +# EVIDENCE-OF: R-04932-55942 If the NATURAL keyword is in the +# join-operator then an implicit USING clause is added to the # join-constraints. The implicit USING clause contains each of the # column names that appear in both the left and right-hand input # datasets. diff --git a/test/e_select2.test b/test/e_select2.test index a2a32a0503..8330894428 100644 --- a/test/e_select2.test +++ b/test/e_select2.test @@ -344,10 +344,10 @@ foreach {tn indexes} { catchsql { DROP INDEX i3 } execsql $indexes - # EVIDENCE-OF: R-46122-14930 If the join-op is "CROSS JOIN", "INNER - # JOIN", "JOIN" or a comma (",") and there is no ON or USING clause, - # then the result of the join is simply the cartesian product of the - # left and right-hand datasets. + # EVIDENCE-OF: R-49872-03192 If the join-operator is "CROSS JOIN", + # "INNER JOIN", "JOIN" or a comma (",") and there is no ON or USING + # clause, then the result of the join is simply the cartesian product of + # the left and right-hand datasets. # # EVIDENCE-OF: R-46256-57243 There is no difference between the "INNER # JOIN", "JOIN" and "," join operators. @@ -368,10 +368,10 @@ foreach {tn indexes} { test_join $tn.1.11 "t2 CROSS JOIN t2 AS x" {t2 t2} test_join $tn.1.12 "t2 JOIN t2 AS x" {t2 t2} - # EVIDENCE-OF: R-22775-56496 If there is an ON clause specified, then - # the ON expression is evaluated for each row of the cartesian product - # as a boolean expression. All rows for which the expression evaluates - # to false are excluded from the dataset. + # EVIDENCE-OF: R-38465-03616 If there is an ON clause then the ON + # expression is evaluated for each row of the cartesian product as a + # boolean expression. Only rows for which the expression evaluates to + # true are included from the dataset. # test_join $tn.2.1 "t1, t2 ON (t1.a=t2.a)" {t1 t2 -on {te_equals a a}} test_join $tn.2.2 "t2, t1 ON (t1.a=t2.a)" {t2 t1 -on {te_equals a a}} @@ -504,14 +504,14 @@ do_execsql_test e_select-2.2.0 { INSERT INTO t5 VALUES(2, 'two'); } {} -# EVIDENCE-OF: R-55824-40976 A sub-select specified in the join-source -# following the FROM clause in a simple SELECT statement is handled as -# if it was a table containing the data returned by executing the -# sub-select statement. +# EVIDENCE-OF: R-59237-46742 A subquery specified in the +# table-or-subquery following the FROM clause in a simple SELECT +# statement is handled as if it was a table containing the data returned +# by executing the subquery statement. # -# EVIDENCE-OF: R-42612-06757 Each column of the sub-select dataset -# inherits the collation sequence and affinity of the corresponding -# expression in the sub-select statement. +# EVIDENCE-OF: R-27438-53558 Each column of the subquery has the +# collation sequence and affinity of the corresponding expression in the +# subquery statement. # foreach {tn subselect select spec} { 1 "SELECT * FROM t2" "SELECT * FROM t1 JOIN %ss%" diff --git a/test/printf2.test b/test/printf2.test index 8985d083cf..4cb1783bfb 100644 --- a/test/printf2.test +++ b/test/printf2.test @@ -59,7 +59,7 @@ do_execsql_test printf2-1.11 { SELECT printf('%lld%n',314159.2653,'hi'); } {314159} -# EVIDENCE-OF: R-20555-31089 The %z format is interchangable with %s. +# EVIDENCE-OF: R-17002-27534 The %z format is interchangeable with %s. # do_execsql_test printf2-1.12 { SELECT printf('%.*z',5,'abcdefghijklmnop'); From 705a48758a30d07d6a9b8792bd7b91bf2154b2a0 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 27 Jan 2014 16:35:15 +0000 Subject: [PATCH 13/14] Fix a couple of problems with new test scripts causing the permutations test to fail. FossilOrigin-Name: 48d736c0ee1ac0879bd12d2f1901f208e87e538a --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/corruptH.test | 27 ++++++++++++++++++++++++++- test/pager4.test | 7 ++++++- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index dfa2b5a9f9..295364ab48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\ssome\srequirements\smarks\sto\sconform\swith\simprovements\nin\sthe\sdocumentation. -D 2014-01-27T15:02:07.424 +C Fix\sa\scouple\sof\sproblems\swith\snew\stest\sscripts\scausing\sthe\spermutations\stest\sto\sfail. +D 2014-01-27T16:35:15.028 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -406,7 +406,7 @@ F test/corruptD.test b3c205fac7952b1de645ce44bb02335cd9e3e040 F test/corruptE.test 193b4ca4e927e77c1d5f4f56203ddc998432a7ee F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 F test/corruptG.test c150f156dace653c00a121ad0f5772a0568c41ba -F test/corruptH.test 7c02f5d928499bc1b68ed4610bfc2c3f12565a35 +F test/corruptH.test 9d8186f6f8751efdfd445d8546fd98f073499039 F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f @@ -728,7 +728,7 @@ F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 F test/pager1.test 1acbdb14c5952a72dd43129cabdbf69aaa3ed1fa F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f -F test/pager4.test b40ecb4cc7dff957ee7916e41ab21d1ed702a642 +F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e F test/pagerfault.test ae9ee0db5a30aecda9db8290ce3dd12e5f7bbaa1 F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8 @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P ba8d2d507f82e2baaceadcf7ac6d71bb91f7e06b -R 21ce223091709a0563d8c91470de6542 -U drh -Z c5e028d1cb73bb521efada71d2fc02fb +P be1acb610f7e594b417dd8409b7a7aa8f3af5f77 +R a3dad1261990ae79a41c0830e9dec218 +U dan +Z bcec9d735db62477dd1be5e976533ffa diff --git a/manifest.uuid b/manifest.uuid index eeb83b19fe..fc234874ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -be1acb610f7e594b417dd8409b7a7aa8f3af5f77 \ No newline at end of file +48d736c0ee1ac0879bd12d2f1901f208e87e538a \ No newline at end of file diff --git a/test/corruptH.test b/test/corruptH.test index 875a92f504..775c30d2a1 100644 --- a/test/corruptH.test +++ b/test/corruptH.test @@ -96,8 +96,31 @@ do_test 2.2 { sqlite3 db test.db } {} + +# The corruption migration caused by the test case below does not +# cause corruption to be detected in mmap mode. +# +# The trick here is that the root page of the tree scanned by the outer +# query is also currently on the free-list. So while the first seek on +# the table (for a==1) works, by the time the second is attempted The +# "INSERT INTO t2..." statements have recycled the root page of t1 and +# used it as an index leaf. Normally, BtreeMovetoUnpacked() detects +# that the PgHdr object associated with said root page does not match +# the cursor (as it is now marked with PgHdr.intKey==0) and returns +# SQLITE_CORRUPT. +# +# However, in mmap mode, the outer query and the inner queries use +# different PgHdr objects (same data, but different PgHdr container +# objects). And so the corruption is not detected. Instead, the second +# seek fails to find anything and only a single row is returned. +# +set res23 {1 {database disk image is malformed}} +if {[permutation]=="mmap"} { + set res23 {0 one} +} do_test 2.3 { list [catch { + set res [list] db eval { SELECT * FROM t1 WHERE a IN (1, 2) } { db eval { INSERT INTO t2 SELECT randomblob(100) FROM t2; @@ -106,9 +129,11 @@ do_test 2.3 { INSERT INTO t2 SELECT randomblob(100) FROM t2; INSERT INTO t2 SELECT randomblob(100) FROM t2; } + lappend res $b } + set res } msg] $msg -} {1 {database disk image is malformed}} +} $res23 #------------------------------------------------------------------------- reset_db diff --git a/test/pager4.test b/test/pager4.test index edfd2660c2..2cf73d1b17 100644 --- a/test/pager4.test +++ b/test/pager4.test @@ -9,7 +9,7 @@ # #*********************************************************************** # -# Tests for the SQLITE_IOERR_NODB error condition: the database file file +# Tests for the SQLITE_READONLY_DBMOVED error condition: the database file # is unlinked or renamed out from under SQLite. # @@ -18,6 +18,11 @@ if {$tcl_platform(platform)!="unix"} return set testdir [file dirname $argv0] source $testdir/tester.tcl +if {[permutation]=="inmemory_journal"} { + finish_test + return +} + # Create a database file for testing # do_execsql_test pager4-1.1 { From 9c2552f2e856ca7ebab74192dcc6de1493514854 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 28 Jan 2014 17:49:13 +0000 Subject: [PATCH 14/14] Minor bugfix in main.c so that the library builds with SQLITE_OMIT_WSD defined. FossilOrigin-Name: 5e3b9ecc7b2b2e50952de819b99bafdb7b9ff59e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/main.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 295364ab48..55d11eedcb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\sof\sproblems\swith\snew\stest\sscripts\scausing\sthe\spermutations\stest\sto\sfail. -D 2014-01-27T16:35:15.028 +C Minor\sbugfix\sin\smain.c\sso\sthat\sthe\slibrary\sbuilds\swith\sSQLITE_OMIT_WSD\sdefined. +D 2014-01-28T17:49:13.545 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -188,7 +188,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c 867c7b330b740c6c917af9956b13b81d0a048303 -F src/main.c 4a05a9706579c7649d7eebb0094586728eb53fcb +F src/main.c 07225af6a00be0b7f34ac52e60f99cf5cbb2a475 F src/malloc.c 0203ebce9152c6a0e5de520140b8ba65187350be F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P be1acb610f7e594b417dd8409b7a7aa8f3af5f77 -R a3dad1261990ae79a41c0830e9dec218 +P 48d736c0ee1ac0879bd12d2f1901f208e87e538a +R 2cc45274993cd572752bb3138d773ec9 U dan -Z bcec9d735db62477dd1be5e976533ffa +Z efd313d0ce443bf7542f8c0ae313a99a diff --git a/manifest.uuid b/manifest.uuid index fc234874ae..5b9b68c635 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48d736c0ee1ac0879bd12d2f1901f208e87e538a \ No newline at end of file +5e3b9ecc7b2b2e50952de819b99bafdb7b9ff59e \ No newline at end of file diff --git a/src/main.c b/src/main.c index 98579105c7..45e31a8076 100644 --- a/src/main.c +++ b/src/main.c @@ -3303,7 +3303,7 @@ int sqlite3_test_control(int op, ...){ ** that demonstrat invariants on well-formed database files. */ case SQLITE_TESTCTRL_NEVER_CORRUPT: { - sqlite3Config.neverCorrupt = va_arg(ap, int); + sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); break; }