From 19be738b4277865578a01bec776454e95bdbed73 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Nov 2013 06:17:56 +0000 Subject: [PATCH 01/10] Fix a test case in temptrigger.test so that it works in auto-vacuum mode. FossilOrigin-Name: c3b7a0e61f4ad690a56ece1d348a3ef74ab300fe --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/temptrigger.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2b11db792d..46cc742312 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunnecessary\slocal\svariables\sfrom\ssqlite3VdbeExec()\sin\sorder\sto\nreduce\sstack-space\srequirements\sof\sthat\sroutine. -D 2013-11-27T21:07:03.594 +C Fix\sa\stest\scase\sin\stemptrigger.test\sso\sthat\sit\sworks\sin\sauto-vacuum\smode. +D 2013-11-28T06:17:56.598 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -839,7 +839,7 @@ F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 -F test/temptrigger.test 0a48d94222d50e6e50d72ac103606c4f8e7cbb81 +F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1 F test/tester.tcl bce6b929932498383ce92431da6a96432c690bf7 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P ec2d47a1db2349d5c9b4fe465506e0e347f77921 -R 7567a16f49e2bdddacaa25bcadbc50b4 -U drh -Z d833492813320be0733490cbebae9751 +P 81891288d9f281cf2ceb4cd701c0c3231b1bab19 +R e5054da8ef1fdd961404f7ffc7aa7a5a +U dan +Z 17d1dc6a3f28e852709091d44bbd59ab diff --git a/manifest.uuid b/manifest.uuid index d8103977d6..0fdb1c275e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -81891288d9f281cf2ceb4cd701c0c3231b1bab19 \ No newline at end of file +c3b7a0e61f4ad690a56ece1d348a3ef74ab300fe \ No newline at end of file diff --git a/test/temptrigger.test b/test/temptrigger.test index d646b672b9..551c620479 100644 --- a/test/temptrigger.test +++ b/test/temptrigger.test @@ -265,10 +265,10 @@ do_test 6.1 { } {} do_execsql_test 6.2 { - SELECT * FROM aux.sqlite_master; + SELECT type,name,tbl_name,sql FROM aux.sqlite_master; INSERT INTO aux.t1 VALUES(1,2,3); } { - table t1 t1 2 {CREATE TABLE t1(a, b, c)} + table t1 t1 {CREATE TABLE t1(a, b, c)} } do_catchsql_test 6.3 { From 0d4a0cdf1895673aef0cf1f8555e855a843e751c Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Nov 2013 14:14:31 +0000 Subject: [PATCH 02/10] Remove an assert() condition that may not be true if the database file is corrupt. Update a test case in corruptC.test. FossilOrigin-Name: 0bcf75516f59e49536f9e5c5cd542058ab61e2fc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/vdbeaux.c | 1 - test/corruptC.test | 6 +++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 46cc742312..f38386e963 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stest\scase\sin\stemptrigger.test\sso\sthat\sit\sworks\sin\sauto-vacuum\smode. -D 2013-11-28T06:17:56.598 +C Remove\san\sassert()\scondition\sthat\smay\snot\sbe\strue\sif\sthe\sdatabase\sfile\sis\scorrupt.\sUpdate\sa\stest\scase\sin\scorruptC.test. +D 2013-11-28T14:14:31.361 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -284,7 +284,7 @@ F src/vdbe.c 54894fde8dc806d259e015ac7c9680145e725835 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed -F src/vdbeaux.c a880c3c7d7c58543574ff7c96feddc5a1deaeae2 +F src/vdbeaux.c 91438d61d807e738c876c902bf93911294fa4e9c F src/vdbeblob.c 8cd05a5630e6d5563ad017bf82edaf812b28acde F src/vdbemem.c af650c2019dc197f062440cdb4650b7204e648bf F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 @@ -401,7 +401,7 @@ F test/corrupt8.test 48eb37ffb9a03bceada62219e2bd4c92f4b0cb75 F test/corrupt9.test 959179e68dc0b7b99f424cf3e0381c86dcdd0112 F test/corruptA.test fafa652aa585753be4f6b62ff0bb250266eaf7ce F test/corruptB.test 20d4a20cbed23958888c3e8995b424a47223d647 -F test/corruptC.test 62a767fe64acb1975f58cc6171192839c783edbb +F test/corruptC.test b497c185822c6042d48e2397bbb61b6afa9145f2 F test/corruptD.test 3b09903a2e2fe07ecafe775fea94177f8a4bb34f F test/corruptE.test d3a3d7e864a95978195741744dda4abfd8286018 F test/corruptF.test 1c7b6f77cf3f237fb7fbb5b61d6c921fd4c7b993 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 81891288d9f281cf2ceb4cd701c0c3231b1bab19 -R e5054da8ef1fdd961404f7ffc7aa7a5a +P c3b7a0e61f4ad690a56ece1d348a3ef74ab300fe +R 21ad128f70c76813a75560c386843590 U dan -Z 17d1dc6a3f28e852709091d44bbd59ab +Z 0b43b2d8a9067c8c1c1e6108e2a66815 diff --git a/manifest.uuid b/manifest.uuid index 0fdb1c275e..f2b05ea696 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c3b7a0e61f4ad690a56ece1d348a3ef74ab300fe \ No newline at end of file +0bcf75516f59e49536f9e5c5cd542058ab61e2fc \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index e2e3843ffd..1f51e681b5 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3114,7 +3114,6 @@ int sqlite3VdbeRecordCompare( d1 = szHdr1; assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField ); assert( pKeyInfo->aSortOrder!=0 ); - assert( idx1nField ); do{ u32 serial_type1; diff --git a/test/corruptC.test b/test/corruptC.test index 34e81a1be8..bf5c3f3972 100644 --- a/test/corruptC.test +++ b/test/corruptC.test @@ -202,6 +202,10 @@ do_test corruptC-2.8 { } {1 {database disk image is malformed}} # corruption (seed 170434) +# +# UPDATE: Prior to 3.8.2, this used to return SQLITE_CORRUPT. It no longer +# does. That is Ok, the point of these tests is to verify that no buffer +# overruns or overreads can be caused by corrupt databases. do_test corruptC-2.9 { db close forcecopy test.bu test.db @@ -211,7 +215,7 @@ do_test corruptC-2.9 { sqlite3 db test.db catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;} -} {1 {database disk image is malformed}} +} {0 {}} # corruption (seed 186504) do_test corruptC-2.10 { From 1b4b334abbf67fe23e7ca03f76045625b24c8ef1 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 28 Nov 2013 19:28:00 +0000 Subject: [PATCH 03/10] Update a few test cases to account for the new error message formats. FossilOrigin-Name: 65a5bce3ffb656a43a2e5d2308a4bc67497105de --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fkey_malloc.test | 5 ++++- test/ioerr.test | 2 +- test/trans2.test | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index f38386e963..428b7ba491 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sassert()\scondition\sthat\smay\snot\sbe\strue\sif\sthe\sdatabase\sfile\sis\scorrupt.\sUpdate\sa\stest\scase\sin\scorruptC.test. -D 2013-11-28T14:14:31.361 +C Update\sa\sfew\stest\scases\sto\saccount\sfor\sthe\snew\serror\smessage\sformats. +D 2013-11-28T19:28:00.296 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -470,7 +470,7 @@ F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 8a1fde4e7721ae00b05b3178888833726ca2df8d F test/fkey6.test abb59f866c1b44926fd02d1fdd217d831fe04f48 F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc -F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 +F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb F test/fts-9fd058691.test 78b887e30ae6816df0e1fed6259de4b5a64ad33c F test/fts1a.test 46090311f85da51bb33bd5ce84f7948359c6d8d7 @@ -624,7 +624,7 @@ F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc F test/intpkey.test 7506090fc08e028712a8bf47e5f54111947e3844 F test/io.test 3a7abcef18727cc0f2399e04b0e8903eccae50f8 -F test/ioerr.test 40bb2cfcab63fb6aa7424cd97812a84bc16b5fb8 +F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d F test/ioerr2.test 9d71166f8466eda510f1af6137bdabaa82b5408d F test/ioerr3.test d3cec5e1a11ad6d27527d0d38573fbff14c71bdd F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c @@ -989,7 +989,7 @@ F test/tpch01.test 8f4ac52f62f3e9f6bce0889105aecdf0275e331b F test/trace.test 4b36a41a3e9c7842151af6da5998f5080cdad9e5 F test/trace2.test e7a988fdd982cdec62f1f1f34b0360e6476d01a0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 -F test/trans2.test d5337e61de45e66b1fcbf9db833fa8c82e624b22 +F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76 F test/trans3.test 373ac5183cc56be69f48ae44090e7f672939f732 F test/transitive1.test 03f532954f46cdf5608f7766bff0b0c52bf2a7cd F test/trigger1.test dc47573ac79ffe0ee3eecaa517d70d8dacbccd03 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P c3b7a0e61f4ad690a56ece1d348a3ef74ab300fe -R 21ad128f70c76813a75560c386843590 +P 0bcf75516f59e49536f9e5c5cd542058ab61e2fc +R 6e7556e59872b6a951f274edf04e3ab4 U dan -Z 0b43b2d8a9067c8c1c1e6108e2a66815 +Z 028b27b689b89b3e9fc267cb7f1e10e7 diff --git a/manifest.uuid b/manifest.uuid index f2b05ea696..a1bddb66b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0bcf75516f59e49536f9e5c5cd542058ab61e2fc \ No newline at end of file +65a5bce3ffb656a43a2e5d2308a4bc67497105de \ No newline at end of file diff --git a/test/fkey_malloc.test b/test/fkey_malloc.test index b4b5b4eed7..382e6f67d9 100644 --- a/test/fkey_malloc.test +++ b/test/fkey_malloc.test @@ -69,7 +69,10 @@ proc catch_fk_error {zSql} { if {[string match {*foreign key*} $msg]} { return "" } - if {$msg eq "out of memory" || $msg eq "constraint failed"} { + if {$msg eq "out of memory" + || $msg eq "FOREIGN KEY constraint failed" + || $msg eq "constraint failed" + } { error 1 } error $msg diff --git a/test/ioerr.test b/test/ioerr.test index b237439ea2..e59647fe50 100644 --- a/test/ioerr.test +++ b/test/ioerr.test @@ -258,7 +258,7 @@ do_ioerr_test ioerr-10 -ckrefcount true -tclprep { INSERT INTO t1 SELECT (a+500)%900, 'good string' FROM t1; }} msg - if {$msg != "column a is not unique"} { + if {$msg != "UNIQUE constraint failed: t1.a"} { error $msg } } diff --git a/test/trans2.test b/test/trans2.test index cfd3e67736..36a2f9986b 100644 --- a/test/trans2.test +++ b/test/trans2.test @@ -161,7 +161,7 @@ for {set i 2} {$i<=30} {incr i} { z = CASE WHEN id<$max_rowid THEN zeroblob((random()&65535)%5000 + 1000) END; } - } {1 {t1.z may not be NULL}} + } {1 {NOT NULL constraint failed: t1.z}} do_test trans2-$i.11 { db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id} } $newres @@ -185,7 +185,7 @@ for {set i 2} {$i<=30} {incr i} { z = CASE WHEN id<$max1 THEN zeroblob((random()&65535)%5000 + 1000) END; } - } {1 {t1.z may not be NULL}} + } {1 {NOT NULL constraint failed: t1.z}} do_test trans2-$i.31 { db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id} } $origres From 09fe614372b54ba46196ba8387561460919ecfc9 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Nov 2013 15:06:27 +0000 Subject: [PATCH 04/10] Add a new sqlite3_test_control() that indicates that database files are always well-formed. Use this during testing to enable assert() statements that prove conditions that are always true for well-formed databases. FossilOrigin-Name: 15e4f63d1f3cbcd0aa789fd3e460cd6e4d3338f9 --- manifest | 58 +++++++++++++++++++++++----------------------- manifest.uuid | 2 +- src/global.c | 2 +- src/main.c | 13 +++++++++++ src/sqlite.h.in | 3 ++- src/sqliteInt.h | 18 ++++++++++++++ src/test1.c | 33 ++++++++++++++++++++++++++ src/vdbeaux.c | 3 ++- test/corrupt.test | 4 ++++ test/corrupt2.test | 4 ++++ test/corrupt3.test | 4 ++++ test/corrupt4.test | 4 ++++ test/corrupt5.test | 4 ++++ test/corrupt6.test | 4 ++++ test/corrupt7.test | 4 ++++ test/corrupt8.test | 4 ++++ test/corrupt9.test | 4 ++++ test/corruptA.test | 4 ++++ test/corruptB.test | 4 ++++ test/corruptC.test | 4 ++++ test/corruptD.test | 4 ++++ test/corruptE.test | 4 ++++ test/corruptF.test | 4 ++++ test/corruptG.test | 4 ++++ test/tester.tcl | 6 +++++ 25 files changed, 169 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 428b7ba491..1aaac60acf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sa\sfew\stest\scases\sto\saccount\sfor\sthe\snew\serror\smessage\sformats. -D 2013-11-28T19:28:00.296 +C Add\sa\snew\ssqlite3_test_control()\sthat\sindicates\sthat\sdatabase\sfiles\sare\nalways\swell-formed.\s\sUse\sthis\sduring\stesting\sto\senable\sassert()\sstatements\nthat\sprove\sconditions\sthat\sare\salways\strue\sfor\swell-formed\sdatabases. +D 2013-11-29T15:06:27.785 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,7 +179,7 @@ F src/expr.c 31a2b65339f6c3795d4cfa5e99798cd72f9fdfdf F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 2ab0f5384b70594468ef3ac5c7ed8ca24bfd17d5 F src/func.c ef30d26ae4d79bbc7300c74e77fd117a0ba30235 -F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 +F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 @@ -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 441a2e106d0e2913fec47e5f13d5802c742e32bb +F src/main.c 74bdee8f574588868e67c25cd377df7cba80102e F src/malloc.c 543a8eb5508eaf4cadf55a9b503379eba2088128 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c c0c990fcaddff810ea277b4fb5d9138603dd5d4b @@ -221,15 +221,15 @@ F src/resolve.c 7eda9097b29fcf3d2b42fdc17d1de672134e09b6 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c d41381d80a22d3a83352aeca274cccf264ac277a F src/shell.c 936a72ff784efff3832cce274a96ed0b036e6758 -F src/sqlite.h.in af7f4349f939c40848bdfa217855d0bb88f3a581 +F src/sqlite.h.in baf55c31c4e15a4b626acfeaa792f2aaa566657f F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 9d586cb37572cd9e0a48242d449c6a69c2e74e72 +F src/sqliteInt.h c26e4cde71fd6dbe34b708f2abd2f6436ce191bf F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c 651b10698c87bbc3ae5772e2491e3444c5bbf153 -F src/test1.c 5757066e503a8ed51313cb3a5d9bcdcced2991a9 +F src/test1.c 760e0419705f712d80595f47199568cd7e3b57a4 F src/test2.c 7355101c085304b90024f2261e056cdff13c6c35 F src/test3.c 1c0e5d6f080b8e33c1ce8b3078e7013fdbcd560c F src/test4.c 9b32d22f5f150abe23c1830e2057c4037c45b3df @@ -284,7 +284,7 @@ F src/vdbe.c 54894fde8dc806d259e015ac7c9680145e725835 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed -F src/vdbeaux.c 91438d61d807e738c876c902bf93911294fa4e9c +F src/vdbeaux.c 28a791e1694018f7143c349b154b78237f0ea1fb F src/vdbeblob.c 8cd05a5630e6d5563ad017bf82edaf812b28acde F src/vdbemem.c af650c2019dc197f062440cdb4650b7204e648bf F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 @@ -390,22 +390,22 @@ F test/conflict.test 841bcf7cabbfca39c577eb8411ea8601843b46a8 F test/conflict2.test 3ed0b6ec3c2cb8acebbc89677ea0e58c01aaa1ff F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 -F test/corrupt.test 4aabd06cff3fe759e3e658bcc17b71789710665e -F test/corrupt2.test 9c0ab4becd50e9050bc1ebb8675456a4e5587bf0 -F test/corrupt3.test 889d7cdb811800303aa722d7813fe8a4299cf726 -F test/corrupt4.test b963f9e01e0f92d15c76fb0747876fd4b96dc30a -F test/corrupt5.test c23da7bfb20917cc7fdbb13ee25c7cc4e9fffeff -F test/corrupt6.test 4e4161aef1f30b9f34582bb4142334b7f47eacae -F test/corrupt7.test a90caf89c7d7cb7893ea4d92529bd0c129317ee4 -F test/corrupt8.test 48eb37ffb9a03bceada62219e2bd4c92f4b0cb75 -F test/corrupt9.test 959179e68dc0b7b99f424cf3e0381c86dcdd0112 -F test/corruptA.test fafa652aa585753be4f6b62ff0bb250266eaf7ce -F test/corruptB.test 20d4a20cbed23958888c3e8995b424a47223d647 -F test/corruptC.test b497c185822c6042d48e2397bbb61b6afa9145f2 -F test/corruptD.test 3b09903a2e2fe07ecafe775fea94177f8a4bb34f -F test/corruptE.test d3a3d7e864a95978195741744dda4abfd8286018 -F test/corruptF.test 1c7b6f77cf3f237fb7fbb5b61d6c921fd4c7b993 -F test/corruptG.test c67fd860e9e3943bc90b856a3049c9a28827167e +F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 +F test/corrupt2.test f2064e0bf934124cc38868fd8badb8f0dd67b552 +F test/corrupt3.test 4b548d0bbe2933bc81d3f54099a05fc4d28aff18 +F test/corrupt4.test b99652079d542b21f4965f6248703b983e40fe80 +F test/corrupt5.test 8ead52af76006f3286e9396cb41898018ccea107 +F test/corrupt6.test 269548d19427ac554c830763b1c5ea54a0252f80 +F test/corrupt7.test 22cc644c2e76c9804bc844121267aa6f8f7c0ded +F test/corrupt8.test 2399dfe40d2c0c63af86706e30f3e6302a8d0516 +F test/corrupt9.test 730a3db08d4ab9aa43392ea30d9c2b4879cbff85 +F test/corruptA.test 53e56dafd180addcdadb402244b8cb9771d2ba26 +F test/corruptB.test 73a8d6c0b9833697ecf16b63e3c5c05c945b5dec +F test/corruptC.test 02405cf7ed0c1e989060e1aab6d02ffbc3906fbb +F test/corruptD.test b3c205fac7952b1de645ce44bb02335cd9e3e040 +F test/corruptE.test 193b4ca4e927e77c1d5f4f56203ddc998432a7ee +F test/corruptF.test be9fde98e4c93648f1ba52b74e5318edc8f59fe4 +F test/corruptG.test c150f156dace653c00a121ad0f5772a0568c41ba F test/count.test 42a251178e32f617eda33f76236a7f79825a50b5 F test/coveridxscan.test cdb47d01acc4a634a34fd25abe85189e0d0f1e62 F test/crash.test fb9dc4a02dcba30d4aa5c2c226f98b220b2b959f @@ -840,7 +840,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 bce6b929932498383ce92431da6a96432c690bf7 +F test/tester.tcl 2a7cce4abf404557c09323a84a2444b189835d0f F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 0bcf75516f59e49536f9e5c5cd542058ab61e2fc -R 6e7556e59872b6a951f274edf04e3ab4 -U dan -Z 028b27b689b89b3e9fc267cb7f1e10e7 +P 65a5bce3ffb656a43a2e5d2308a4bc67497105de +R e2c54e83c6d9de52db2502c5f23f4d01 +U drh +Z 79de7aa38f99c75e5cc2a8b158cbdc48 diff --git a/manifest.uuid b/manifest.uuid index a1bddb66b0..f6f482e260 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65a5bce3ffb656a43a2e5d2308a4bc67497105de \ No newline at end of file +15e4f63d1f3cbcd0aa789fd3e460cd6e4d3338f9 \ No newline at end of file diff --git a/src/global.c b/src/global.c index 7b02cf2130..1ee3f6436f 100644 --- a/src/global.c +++ b/src/global.c @@ -148,6 +148,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_USE_URI, /* bOpenUri */ SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ 0x7ffffffe, /* mxStrlen */ + 0, /* neverCorrupt */ 128, /* szLookaside */ 500, /* nLookaside */ {0,0,0,0,0,0,0,0}, /* m */ @@ -183,7 +184,6 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = { #endif }; - /* ** Hash table for global functions - functions common to all ** database connections. After initialization, this table is diff --git a/src/main.c b/src/main.c index a6a04b4b4c..69a399f385 100644 --- a/src/main.c +++ b/src/main.c @@ -3296,6 +3296,19 @@ int sqlite3_test_control(int op, ...){ } #endif + /* sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int); + ** + ** Set or clear a flag that indicates that the database file is always well- + ** formed and never corrupt. This flag is clear by default, indicating that + ** database files might have arbitrary corruption. Setting the flag during + ** testing causes certain assert() statements in the code to be activated + ** that demonstrat invariants on well-formed database files. + */ + case SQLITE_TESTCTRL_NEVER_CORRUPT: { + sqlite3Config.neverCorrupt = va_arg(ap, int); + break; + } + } va_end(ap); #endif /* SQLITE_OMIT_BUILTIN_TEST */ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 228d9cca36..98c89da322 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -6069,7 +6069,8 @@ int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 -#define SQLITE_TESTCTRL_LAST 19 +#define SQLITE_TESTCTRL_NEVER_CORRUPT 20 +#define SQLITE_TESTCTRL_LAST 20 /* ** CAPI3REF: SQLite Runtime Status diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6373bb75d7..98dabeb4ef 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2538,6 +2538,7 @@ struct Sqlite3Config { int bOpenUri; /* True to interpret filenames as URIs */ int bUseCis; /* Use covering indices for full-scans */ int mxStrlen; /* Maximum string length */ + int neverCorrupt; /* Database is always well-formed */ int szLookaside; /* Default lookaside buffer size */ int nLookaside; /* Default lookaside buffer count */ sqlite3_mem_methods m; /* Low-level memory allocation interface */ @@ -2574,6 +2575,23 @@ struct Sqlite3Config { #endif }; +/* +** This macro is used inside of assert() statements to indicate that +** the assert is only valid on a well-formed database. Instead of: +** +** assert( X ); +** +** One writes: +** +** assert( X || CORRUPTIBLE ); +** +** CORRUPTIBLE is true during normal operation. But for many test cases, +** it is set to false using a sqlite3_test_control(). This enables assert() +** statements to prove things that are always true for well-formed +** databases. +*/ +#define CORRUPTIBLE (sqlite3Config.neverCorrupt==0) + /* ** Context pointer passed down through the tree-walk. */ diff --git a/src/test1.c b/src/test1.c index d8a9e52d21..e0c16e13ae 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5453,6 +5453,37 @@ static int reset_prng_state( return TCL_OK; } +/* +** tclcmd: database_may_be_corrupt +** +** Indicate that database files might be corrupt. In other words, set the normal +** state of operation. +*/ +static int database_may_be_corrupt( + ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int objc, /* Number of arguments */ + Tcl_Obj *CONST objv[] /* Command arguments */ +){ + sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0); + return TCL_OK; +} +/* +** tclcmd: database_never_corrupt +** +** Indicate that database files are always well-formed. This enables extra assert() +** statements that test conditions that are always true for well-formed databases. +*/ +static int database_never_corrupt( + ClientData clientData, /* Pointer to sqlite3_enable_XXX function */ + Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ + int objc, /* Number of arguments */ + Tcl_Obj *CONST objv[] /* Command arguments */ +){ + sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 1); + return TCL_OK; +} + /* ** tclcmd: pcache_stats */ @@ -6331,6 +6362,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "save_prng_state", save_prng_state, 0 }, { "restore_prng_state", restore_prng_state, 0 }, { "reset_prng_state", reset_prng_state, 0 }, + { "database_never_corrupt", database_never_corrupt, 0}, + { "database_may_be_corrupt", database_may_be_corrupt, 0}, { "optimization_control", optimization_control,0}, #if SQLITE_OS_WIN { "lock_win32_file", win32_file_lock, 0 }, diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 1f51e681b5..85685f3572 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3112,8 +3112,9 @@ int sqlite3VdbeRecordCompare( idx1 = getVarint32(aKey1, szHdr1); d1 = szHdr1; - assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField ); + assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField || CORRUPTIBLE ); assert( pKeyInfo->aSortOrder!=0 ); + assert( (idx1<=szHdr1 && inField) || CORRUPTIBLE ); do{ u32 serial_type1; diff --git a/test/corrupt.test b/test/corrupt.test index 09f3c5bd7c..3e49a9ff18 100644 --- a/test/corrupt.test +++ b/test/corrupt.test @@ -25,6 +25,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # Construct a large database for testing. # do_test corrupt-1.1 { diff --git a/test/corrupt2.test b/test/corrupt2.test index 744a76ed04..805a6148f0 100644 --- a/test/corrupt2.test +++ b/test/corrupt2.test @@ -23,6 +23,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + set presql "" catch { set presql "$::G(perm:presql);" } unset -nocomplain ::G(perm:presql) diff --git a/test/corrupt3.test b/test/corrupt3.test index a3827227b7..436a466189 100644 --- a/test/corrupt3.test +++ b/test/corrupt3.test @@ -23,6 +23,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas||direct_read { diff --git a/test/corrupt4.test b/test/corrupt4.test index 19061134f6..24db60fd52 100644 --- a/test/corrupt4.test +++ b/test/corrupt4.test @@ -23,6 +23,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas { diff --git a/test/corrupt5.test b/test/corrupt5.test index dca06e5fec..3f5099630e 100644 --- a/test/corrupt5.test +++ b/test/corrupt5.test @@ -19,6 +19,10 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas { diff --git a/test/corrupt6.test b/test/corrupt6.test index c0dcedf3d9..7d90c4a3ba 100644 --- a/test/corrupt6.test +++ b/test/corrupt6.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas { diff --git a/test/corrupt7.test b/test/corrupt7.test index ad566560f7..db92cf1de9 100644 --- a/test/corrupt7.test +++ b/test/corrupt7.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas { diff --git a/test/corrupt8.test b/test/corrupt8.test index 012beb562e..d7bceba31c 100644 --- a/test/corrupt8.test +++ b/test/corrupt8.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas||!autovacuum { diff --git a/test/corrupt9.test b/test/corrupt9.test index f199452f95..bb37758b17 100644 --- a/test/corrupt9.test +++ b/test/corrupt9.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # We must have the page_size pragma for these tests to work. # ifcapable !pager_pragmas { diff --git a/test/corruptA.test b/test/corruptA.test index 8b76d3a201..bb9912bd2b 100644 --- a/test/corruptA.test +++ b/test/corruptA.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # Create a database to work with. # diff --git a/test/corruptB.test b/test/corruptB.test index 0ff2d6e9e0..c51cb57680 100644 --- a/test/corruptB.test +++ b/test/corruptB.test @@ -30,6 +30,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + do_test corruptB-1.1 { execsql { diff --git a/test/corruptC.test b/test/corruptC.test index bf5c3f3972..adf6f44c44 100644 --- a/test/corruptC.test +++ b/test/corruptC.test @@ -27,6 +27,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # Construct a compact, dense database for testing. # do_test corruptC-1.1 { diff --git a/test/corruptD.test b/test/corruptD.test index 2423cd428e..63474584c3 100644 --- a/test/corruptD.test +++ b/test/corruptD.test @@ -19,6 +19,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + #-------------------------------------------------------------------------- # OVERVIEW # diff --git a/test/corruptE.test b/test/corruptE.test index 48292ab2e9..4d5b5db3d6 100644 --- a/test/corruptE.test +++ b/test/corruptE.test @@ -24,6 +24,10 @@ source $testdir/tester.tcl # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # Do not run the tests in this file if ENABLE_OVERSIZE_CELL_CHECK is on. # ifcapable oversize_cell_check { diff --git a/test/corruptF.test b/test/corruptF.test index 64c6eb890b..8c4fd84219 100644 --- a/test/corruptF.test +++ b/test/corruptF.test @@ -19,6 +19,10 @@ set testprefix corruptF # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + proc str {i} { format %08d $i } # Create a 6 page database containing a single table - t1. Table t1 diff --git a/test/corruptG.test b/test/corruptG.test index c34911195c..11253fd12c 100644 --- a/test/corruptG.test +++ b/test/corruptG.test @@ -19,6 +19,10 @@ set testprefix corruptG # do_not_use_codec +# These tests deal with corrupt database files +# +database_may_be_corrupt + # Create a simple database with a single entry. Then corrupt the # header-size varint on the index payload so that it maps into a # negative number. Try to use the database. diff --git a/test/tester.tcl b/test/tester.tcl index c1272210d0..771ca91442 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1886,5 +1886,11 @@ set AUTOVACUUM $sqlite_options(default_autovacuum) # Make sure the FTS enhanced query syntax is disabled. set sqlite_fts3_enable_parentheses 0 +# During testing, assume that all database files are well-formed. The +# few test cases that deliberately corrupt database files should rescind +# this setting by invoking "database_can_be_corrupt" +# +database_never_corrupt + source $testdir/thread_common.tcl source $testdir/malloc_common.tcl From b202366509ad80878c297bb97e68c15ec6df48e0 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 29 Nov 2013 15:39:36 +0000 Subject: [PATCH 05/10] Change the name of the CORRUPTIBLE macro to CORRUPT_DB. FossilOrigin-Name: f865be10e85a4063394a21827db2d854fc25960c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 13 +++++++------ src/vdbeaux.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 1aaac60acf..8b8ce60236 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\ssqlite3_test_control()\sthat\sindicates\sthat\sdatabase\sfiles\sare\nalways\swell-formed.\s\sUse\sthis\sduring\stesting\sto\senable\sassert()\sstatements\nthat\sprove\sconditions\sthat\sare\salways\strue\sfor\swell-formed\sdatabases. -D 2013-11-29T15:06:27.785 +C Change\sthe\sname\sof\sthe\sCORRUPTIBLE\smacro\sto\sCORRUPT_DB. +D 2013-11-29T15:39:36.814 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -224,7 +224,7 @@ F src/shell.c 936a72ff784efff3832cce274a96ed0b036e6758 F src/sqlite.h.in baf55c31c4e15a4b626acfeaa792f2aaa566657f F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h c26e4cde71fd6dbe34b708f2abd2f6436ce191bf +F src/sqliteInt.h f3a5d663fe9c6c0b2ee7fc2e20a6204eaea5bc7c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -284,7 +284,7 @@ F src/vdbe.c 54894fde8dc806d259e015ac7c9680145e725835 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 F src/vdbeInt.h 05fbda0e061dbc4aaa2709a8cccf3515c245b263 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed -F src/vdbeaux.c 28a791e1694018f7143c349b154b78237f0ea1fb +F src/vdbeaux.c 5b58b242afe50f6bae77da1c1e26330af32e51c7 F src/vdbeblob.c 8cd05a5630e6d5563ad017bf82edaf812b28acde F src/vdbemem.c af650c2019dc197f062440cdb4650b7204e648bf F src/vdbesort.c 9d83601f9d6243fe70dd0169a2820c5ddfd48147 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 65a5bce3ffb656a43a2e5d2308a4bc67497105de -R e2c54e83c6d9de52db2502c5f23f4d01 +P 15e4f63d1f3cbcd0aa789fd3e460cd6e4d3338f9 +R 962cc490e8fc3a8042a30112d4f3290d U drh -Z 79de7aa38f99c75e5cc2a8b158cbdc48 +Z d6583fce3162aa40a5f7e6ad518960af diff --git a/manifest.uuid b/manifest.uuid index f6f482e260..a0b1398f2f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -15e4f63d1f3cbcd0aa789fd3e460cd6e4d3338f9 \ No newline at end of file +f865be10e85a4063394a21827db2d854fc25960c \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 98dabeb4ef..8bf05a9c8e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2583,14 +2583,15 @@ struct Sqlite3Config { ** ** One writes: ** -** assert( X || CORRUPTIBLE ); +** assert( X || CORRUPT_DB ); ** -** CORRUPTIBLE is true during normal operation. But for many test cases, -** it is set to false using a sqlite3_test_control(). This enables assert() -** statements to prove things that are always true for well-formed -** databases. +** CORRUPT_DB is true during normal operation. CORRUPT_DB does not indicate +** that the database is definitely corrupt, only that it might be corrupt. +** For most test cases, CORRUPT_DB is set to false using a special +** sqlite3_test_control(). This enables assert() statements to prove +** things that are always true for well-formed databases. */ -#define CORRUPTIBLE (sqlite3Config.neverCorrupt==0) +#define CORRUPT_DB (sqlite3Config.neverCorrupt==0) /* ** Context pointer passed down through the tree-walk. diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 85685f3572..7a672fdf27 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -3112,9 +3112,9 @@ int sqlite3VdbeRecordCompare( idx1 = getVarint32(aKey1, szHdr1); d1 = szHdr1; - assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField || CORRUPTIBLE ); + assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField || CORRUPT_DB ); assert( pKeyInfo->aSortOrder!=0 ); - assert( (idx1<=szHdr1 && inField) || CORRUPTIBLE ); + assert( (idx1<=szHdr1 && inField) || CORRUPT_DB ); do{ u32 serial_type1; From 094b7587fcade1fc3d33216c410a3d0ba7e0c2f4 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 30 Nov 2013 12:49:28 +0000 Subject: [PATCH 06/10] Detect a corrupt UnpackedRecord and return SQLITE_CORRUPT prior to calling sqlite3BtreeMovetoUnpacked(). FossilOrigin-Name: 55ec474db8935ef36fae30da5d11f5701c60c088 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 8b8ce60236..940dfe0022 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sthe\sname\sof\sthe\sCORRUPTIBLE\smacro\sto\sCORRUPT_DB. -D 2013-11-29T15:39:36.814 +C Detect\sa\scorrupt\sUnpackedRecord\sand\sreturn\sSQLITE_CORRUPT\sprior\sto\scalling\nsqlite3BtreeMovetoUnpacked(). +D 2013-11-30T12:49:28.537 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -166,7 +166,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 1809a7caa2504233bdddd12f5018422421789537 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c ec8a4dcac5c1ec1ba9705b8c5a13e62167958317 +F src/btree.c fe6c95c57fd14ed4b3329f4b5bb08132fe7c322d F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9 F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 F src/build.c 07054d45319953e54a89d726e589a423e9c1c590 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 15e4f63d1f3cbcd0aa789fd3e460cd6e4d3338f9 -R 962cc490e8fc3a8042a30112d4f3290d +P f865be10e85a4063394a21827db2d854fc25960c +R b4c7c44fd7f9f4c41a202ec1f5d2e636 U drh -Z d6583fce3162aa40a5f7e6ad518960af +Z 430bb09012d5a037af5177ecb970e2fe diff --git a/manifest.uuid b/manifest.uuid index a0b1398f2f..4da7a7d3de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f865be10e85a4063394a21827db2d854fc25960c \ No newline at end of file +55ec474db8935ef36fae30da5d11f5701c60c088 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 27e7146893..30fdf4256f 100644 --- a/src/btree.c +++ b/src/btree.c @@ -694,6 +694,10 @@ static int btreeMoveto( ); if( pIdxKey==0 ) return SQLITE_NOMEM; sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey); + if( pIdxKey->nField==0 ){ + sqlite3DbFree(pCur->pKeyInfo->db, pFree); + return SQLITE_CORRUPT_BKPT; + } }else{ pIdxKey = 0; } From a256c1a4b3e362733577d0b151e985b2453ae71f Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 1 Dec 2013 01:18:29 +0000 Subject: [PATCH 07/10] Fix typos in the header comment on the sqlite3Atoi64() routine. FossilOrigin-Name: c85e0c546ea6c6be46deea5c7a716b5fb553c7b4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/util.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 940dfe0022..7b389a5499 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Detect\sa\scorrupt\sUnpackedRecord\sand\sreturn\sSQLITE_CORRUPT\sprior\sto\scalling\nsqlite3BtreeMovetoUnpacked(). -D 2013-11-30T12:49:28.537 +C Fix\stypos\sin\sthe\sheader\scomment\son\sthe\ssqlite3Atoi64()\sroutine. +D 2013-12-01T01:18:29.458 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -278,7 +278,7 @@ F src/tokenize.c ec4c1a62b890bf1dbcdb966399e140b904c700a4 F src/trigger.c d84e1f3669e9a217731a14a9d472b1c7b87c87ba F src/update.c c05a0ee658f1a149e0960dfd110f3b8bd846bcb0 F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269 -F src/util.c cbe054290f780fcd472b89d701c7404c51ec9684 +F src/util.c c1d47254d805074226eb68bab2327f2559799d88 F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 F src/vdbe.c 54894fde8dc806d259e015ac7c9680145e725835 F src/vdbe.h c06f0813f853566457ce9cfb1a4a4bc39a5da644 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P f865be10e85a4063394a21827db2d854fc25960c -R b4c7c44fd7f9f4c41a202ec1f5d2e636 +P 55ec474db8935ef36fae30da5d11f5701c60c088 +R d4e526e47db9fa86e2dd72e39606971c U drh -Z 430bb09012d5a037af5177ecb970e2fe +Z 5cc45f2d22e4b0c01c22c0dac659e6ce diff --git a/manifest.uuid b/manifest.uuid index 4da7a7d3de..2023f47b7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -55ec474db8935ef36fae30da5d11f5701c60c088 \ No newline at end of file +c85e0c546ea6c6be46deea5c7a716b5fb553c7b4 \ No newline at end of file diff --git a/src/util.c b/src/util.c index 5aa8af68d9..e59f5238f8 100644 --- a/src/util.c +++ b/src/util.c @@ -465,12 +465,12 @@ static int compare2pow63(const char *zNum, int incr){ ** If the zNum value is representable as a 64-bit twos-complement ** integer, then write that value into *pNum and return 0. ** -** If zNum is exactly 9223372036854665808, return 2. This special -** case is broken out because while 9223372036854665808 cannot be a -** signed 64-bit integer, its negative -9223372036854665808 can be. +** If zNum is exactly 9223372036854775808, return 2. This special +** case is broken out because while 9223372036854775808 cannot be a +** signed 64-bit integer, its negative -9223372036854775808 can be. ** ** If zNum is too big for a 64-bit integer and is not -** 9223372036854665808 or if zNum contains any non-numeric text, +** 9223372036854775808 or if zNum contains any non-numeric text, ** then return 1. ** ** length is the number of bytes in the string (bytes, not characters). From 290ea4053a3b767ce90522386a861a098baddf09 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 1 Dec 2013 18:10:01 +0000 Subject: [PATCH 08/10] Add some #if SQLITE_VERSION_NUMBER macros to test/speedtest1.c in order to make it compatible with older versions of SQLite so that it can be used for historical speed comparisons. FossilOrigin-Name: a9e1627ae714156cf6bd419e41cf9b79fbbe99a9 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 10 +++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 7b389a5499..4bc50bd00e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sin\sthe\sheader\scomment\son\sthe\ssqlite3Atoi64()\sroutine. -D 2013-12-01T01:18:29.458 +C Add\ssome\s#if\sSQLITE_VERSION_NUMBER\smacros\sto\stest/speedtest1.c\sin\sorder\sto\nmake\sit\scompatible\swith\solder\sversions\sof\sSQLite\sso\sthat\sit\scan\sbe\sused\sfor\nhistorical\sspeed\scomparisons. +D 2013-12-01T18:10:01.701 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -820,7 +820,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c 184ded13ffe61df44d6e2ac9985b61a6417d5311 +F test/speedtest1.c aa1ff125bc9c4b8eb55db2e3cbb82ba76794dedf F test/spellfix.test 8c40b169b104086d8795781f670ba3c786d6d8be F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test c8eccfe8fcd3f3cfc864ce22d5b9e803a3c69940 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 55ec474db8935ef36fae30da5d11f5701c60c088 -R d4e526e47db9fa86e2dd72e39606971c +P c85e0c546ea6c6be46deea5c7a716b5fb553c7b4 +R 3cfbbdfa905179d97133dd917fc5f770 U drh -Z 5cc45f2d22e4b0c01c22c0dac659e6ce +Z aec8d6f2ae39d50473657768f7788a16 diff --git a/manifest.uuid b/manifest.uuid index 2023f47b7b..e66ea9881c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c85e0c546ea6c6be46deea5c7a716b5fb553c7b4 \ No newline at end of file +a9e1627ae714156cf6bd419e41cf9b79fbbe99a9 \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index ea9ec2e351..473b3d191e 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -79,6 +79,12 @@ static int hexDigitValue(char c){ return -1; } +/* Provide an alternative to sqlite3_stricmp() in older versions of +** SQLite */ +#if SQLITE_VERSION_NUMBER<3007011 +# define sqlite3_stricmp strcmp +#endif + /* ** Interpret zArg as an integer value, possibly with suffixes. */ @@ -131,7 +137,7 @@ sqlite3_int64 speedtest1_timestamp(void){ static sqlite3_vfs *clockVfs = 0; sqlite3_int64 t; if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); - if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){ + if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ clockVfs->xCurrentTimeInt64(clockVfs, &t); }else{ double r; @@ -898,6 +904,7 @@ int main(int argc, char **argv){ /* Database connection statistics printed after both prepared statements ** have been finalized */ +#if SQLITE_VERSION_NUMBER>=3007009 if( showStats ){ sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHi, 0); printf("-- Lookaside Slots Used: %d (max %d)\n", iCur,iHi); @@ -920,6 +927,7 @@ int main(int argc, char **argv){ sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0); printf("-- Statement Heap Usage: %d bytes\n", iCur); } +#endif sqlite3_close(g.db); From d79e9c58021a832138e3440810722846b0363cc6 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 Dec 2013 01:24:05 +0000 Subject: [PATCH 09/10] Still more #if SQLITE_VERSION_NUMBER macros in test/speedtest1.c to enable compilation against older versions of SQLite. FossilOrigin-Name: 4b20cf4206ac12975ca9c4ec7ef76aa21bbd734d --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 7 ++++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 4bc50bd00e..f04576e670 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssome\s#if\sSQLITE_VERSION_NUMBER\smacros\sto\stest/speedtest1.c\sin\sorder\sto\nmake\sit\scompatible\swith\solder\sversions\sof\sSQLite\sso\sthat\sit\scan\sbe\sused\sfor\nhistorical\sspeed\scomparisons. -D 2013-12-01T18:10:01.701 +C Still\smore\s#if\sSQLITE_VERSION_NUMBER\smacros\sin\stest/speedtest1.c\sto\senable\ncompilation\sagainst\solder\sversions\sof\sSQLite. +D 2013-12-02T01:24:05.116 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -820,7 +820,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c aa1ff125bc9c4b8eb55db2e3cbb82ba76794dedf +F test/speedtest1.c ae9d739b7ffba4d63086e365753c56561815514c F test/spellfix.test 8c40b169b104086d8795781f670ba3c786d6d8be F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test c8eccfe8fcd3f3cfc864ce22d5b9e803a3c69940 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P c85e0c546ea6c6be46deea5c7a716b5fb553c7b4 -R 3cfbbdfa905179d97133dd917fc5f770 +P a9e1627ae714156cf6bd419e41cf9b79fbbe99a9 +R 84934b6097c3af0a8962d3cfd75d2be6 U drh -Z aec8d6f2ae39d50473657768f7788a16 +Z a36aa806db8ddb60dca1807195d9ce52 diff --git a/manifest.uuid b/manifest.uuid index e66ea9881c..a685b51324 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a9e1627ae714156cf6bd419e41cf9b79fbbe99a9 \ No newline at end of file +4b20cf4206ac12975ca9c4ec7ef76aa21bbd734d \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index 473b3d191e..766e80dac6 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -137,9 +137,12 @@ sqlite3_int64 speedtest1_timestamp(void){ static sqlite3_vfs *clockVfs = 0; sqlite3_int64 t; if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); +#if SQLITE_VERSION_NUMBER>=3007000 if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ clockVfs->xCurrentTimeInt64(clockVfs, &t); - }else{ + }else +#endif + { double r; clockVfs->xCurrentTime(clockVfs, &r); t = (sqlite3_int64)(r*86400000.0); @@ -936,8 +939,10 @@ int main(int argc, char **argv){ if( showStats ){ sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHi, 0); printf("-- Memory Used (bytes): %d (max %d)\n", iCur,iHi); +#if SQLITE_VERSION_NUMBER>=3007000 sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHi, 0); printf("-- Outstanding Allocations: %d (max %d)\n", iCur,iHi); +#endif sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHi, 0); printf("-- Pcache Overflow Bytes: %d (max %d)\n", iCur,iHi); sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHi, 0); From 2a702db1cf51dc94db0f40e8dd8e8ce60612180c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 2 Dec 2013 21:25:40 +0000 Subject: [PATCH 10/10] Another #if SQLITE_VERSION_NUMBER macro in speedtest1.c for compatibility with older versions of SQLite. FossilOrigin-Name: bc8eacc7f71413184ef5be1412e51f8fd7174cd1 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f04576e670..baeef82ada 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Still\smore\s#if\sSQLITE_VERSION_NUMBER\smacros\sin\stest/speedtest1.c\sto\senable\ncompilation\sagainst\solder\sversions\sof\sSQLite. -D 2013-12-02T01:24:05.116 +C Another\s#if\sSQLITE_VERSION_NUMBER\smacro\sin\sspeedtest1.c\sfor\scompatibility\nwith\solder\sversions\sof\sSQLite. +D 2013-12-02T21:25:40.013 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -820,7 +820,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c ae9d739b7ffba4d63086e365753c56561815514c +F test/speedtest1.c 4f1e34b6af9af0b59ca11b57d62c3cd851990fba F test/spellfix.test 8c40b169b104086d8795781f670ba3c786d6d8be F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test c8eccfe8fcd3f3cfc864ce22d5b9e803a3c69940 @@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P a9e1627ae714156cf6bd419e41cf9b79fbbe99a9 -R 84934b6097c3af0a8962d3cfd75d2be6 +P 4b20cf4206ac12975ca9c4ec7ef76aa21bbd734d +R fc7264469bd7eed8b2c47bd423fccf15 U drh -Z a36aa806db8ddb60dca1807195d9ce52 +Z f0389d08b87706a34ccfa173cc3d5e77 diff --git a/manifest.uuid b/manifest.uuid index a685b51324..c2586c5739 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b20cf4206ac12975ca9c4ec7ef76aa21bbd734d \ No newline at end of file +bc8eacc7f71413184ef5be1412e51f8fd7174cd1 \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index 766e80dac6..f3e79ec816 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -922,9 +922,11 @@ int main(int argc, char **argv){ sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHi, 1); printf("-- Page cache hits: %d\n", iCur); sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHi, 1); - printf("-- Page cache misses: %d\n", iCur); + printf("-- Page cache misses: %d\n", iCur); +#if SQLITE_VERSION_NUMBER>=3007012 sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHi, 1); printf("-- Page cache writes: %d\n", iCur); +#endif sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHi, 0); printf("-- Schema Heap Usage: %d bytes\n", iCur); sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0);