From: danielk1977 Date: Fri, 21 Nov 2008 08:50:50 +0000 (+0000) Subject: Add another test case to tkt35xx.test showing that a statement rollback can also... X-Git-Tag: version-3.6.10~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e168ebec2aec831cd5b89f4dba433272e4349a6;p=thirdparty%2Fsqlite.git Add another test case to tkt35xx.test showing that a statement rollback can also trigger the problem. (CVS 5937) FossilOrigin-Name: 74c08b8dd9577d1997b4bc8147beed786150f22b --- diff --git a/manifest b/manifest index a683cb3b8f..aa5af2f985 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C On\sa\sROLLBACK,\sif\sthere\spage\scache\sentries\swhich\sare\sdirty\sbut\snot\sin\sthe\nrollback\sjournal,\smake\ssure\sthey\sget\sreinitialized\sin\sthe\sbtree\slayer.\s(CVS\s5936) -D 2008-11-21T03:23:43 +C Add\sanother\stest\scase\sto\stkt35xx.test\sshowing\sthat\sa\sstatement\srollback\scan\salso\strigger\sthe\sproblem.\s(CVS\s5937) +D 2008-11-21T08:50:50 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 0aa7bbe3be6acc4045706e3bb3fd0b8f38f4a3b5 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -581,7 +581,7 @@ F test/tkt3457.test e9ca2b90f0eb1fb8be73a30d29aacb2e3abedeb9 F test/tkt3461.test 5a63e8d8ee5ce00f076b1e2f82aba5480a0f14ed F test/tkt3472.test e689a687631e59c7a47d9438148115fee23b16c3 F test/tkt3493.test 8472b3464e49a27ff7271308eec46154209e667b -F test/tkt35xx.test 7bad910326076e1147b56717a436a68c9d5a227a +F test/tkt35xx.test 0519cbf85a5531e30177bfb58ff94238a9972ef3 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00 F test/trans.test 2fd24cd7aa0b879d49a224cbd647d698f1e7ac5c @@ -661,7 +661,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 6f910b7036817f4bb4de807bf48938d20ab033cc -R 07e73e1f53ea5064ce74d8b65c948f50 -U drh -Z 8e850a75352c5d8dd456f4d89f060e1a +P faded96f36229ee85039276db693391d0f10648c +R 3f6a31e8be46dea16b333ede4095e47c +U danielk1977 +Z 06fd4a309d695ebc1047a668a58696a1 diff --git a/manifest.uuid b/manifest.uuid index da2be48dad..4408ebf272 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -faded96f36229ee85039276db693391d0f10648c \ No newline at end of file +74c08b8dd9577d1997b4bc8147beed786150f22b \ No newline at end of file diff --git a/test/tkt35xx.test b/test/tkt35xx.test index 4cbb2e92fb..e9ca785a0e 100644 --- a/test/tkt35xx.test +++ b/test/tkt35xx.test @@ -14,11 +14,20 @@ # page cache which are not in the rollback journal are reinitialized # in the btree layer. # -# $Id: tkt35xx.test,v 1.1 2008/11/21 03:23:43 drh Exp $ +# $Id: tkt35xx.test,v 1.2 2008/11/21 08:50:50 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl +do_test tkt35xx-1.1 { + execsql { + PRAGMA auto_vacuum = 0; + PRAGMA page_size = 1024; + } +} {} + +# Trigger the problem using explicit rollback. +# do_test tkt35xx-1.1 { execsql { PRAGMA auto_vacuum = 0; @@ -37,3 +46,61 @@ do_test tkt35xx-1.1 { INSERT INTO t1 VALUES(1, 1, zeroblob(676)); } } {} + +# Trigger the problem using statement rollback. +# +db close +file delete test.db +sqlite3 db test.db +set big [string repeat abcdefghij 22] ;# 220 byte string +do_test tkt35xx-1.2.1 { + execsql { + PRAGMA auto_vacuum = 0; + PRAGMA page_size = 1024; + CREATE TABLE t3(a INTEGER PRIMARY KEY, b); + INSERT INTO t3 VALUES(1, $big); + INSERT INTO t3 VALUES(2, $big); + INSERT INTO t3 VALUES(3, $big); + INSERT INTO t3 VALUES(4, $big); + CREATE TABLE t4(c, d); + INSERT INTO t4 VALUES(5, $big); + INSERT INTO t4 VALUES(1, $big); + } +} {} +do_test tkt35xx-1.2.2 { + catchsql { + BEGIN; + CREATE TABLE t5(e PRIMARY KEY, f); + DROP TABLE t5; + INSERT INTO t3(a, b) SELECT c, d FROM t4; + } +} {1 {PRIMARY KEY must be unique}} + +do_test tkt35xx-1.2.3 { + # Show that the transaction has not been rolled back. + catchsql BEGIN +} {1 {cannot start a transaction within a transaction}} + +# Before the bug was fixed, if SQLITE_DEBUG was defined an assert() +# would fail during the following INSERT statement. If SQLITE_DEBUG +# was not defined, then the statement would pass and the transaction +# would be committed. But, the "SELECT count(*)" in tkt35xx-1.2.6 would +# return 1, not 5. Data magically disappeared! +# +do_test tkt35xx-1.2.4 { + execsql { SELECT count(*) FROM t3 } +} {4} +do_test tkt35xx-1.2.5 { + execsql { + INSERT INTO t3 VALUES(5, $big); + COMMIT; + } +} {} +do_test tkt35xx-1.2.6 { + execsql { SELECT count(*) FROM t3 } +} {5} + +integrity_check tkt35xx-1.2.7 + +finish_test +