From: dan Date: Thu, 26 Sep 2013 11:04:33 +0000 (+0000) Subject: Fix a faulty assert() in sqlite3BtreeBeginTrans() that may fail in shared-cache mode. X-Git-Tag: version-3.8.1~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56c517aa5fa5f11dc4add217c900e13d0420f6f7;p=thirdparty%2Fsqlite.git Fix a faulty assert() in sqlite3BtreeBeginTrans() that may fail in shared-cache mode. FossilOrigin-Name: 1e1321ee985370c2b7e5bd64286bb4d7704b5a30 --- diff --git a/manifest b/manifest index 63dc845268..11d8ceed58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\sthat\sthe\sunicode61\stokenchars=\sand\sseparators=\soptions\swork\swith\sthe\sfts3tokenize\svirtual\stable. -D 2013-09-18T11:16:32.742 +C Fix\sa\sfaulty\sassert()\sin\ssqlite3BtreeBeginTrans()\sthat\smay\sfail\sin\sshared-cache\smode. +D 2013-09-26T11:04:33.317 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c b9b57df546df2636294bfb21a986f5707b417df2 +F src/btree.c 5ccbbaed7a32ba774306f610da4ab4f3e5348294 F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h 51cf220a9b9223354770883e93a859dc377aa27f F src/build.c f63e8929c7f89c0074fbc74929bc946ea117b2f8 @@ -773,7 +773,7 @@ F test/selectE.test fc02a1eb04c8eb537091482644b7d778ae8759b7 F test/server1.test 46803bd3fe8b99b30dbc5ff38ffc756f5c13a118 F test/shared.test 1da9dbad400cee0d93f252ccf76e1ae007a63746 F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 -F test/shared3.test ebf77f023f4bdaa8f74f65822b559e86ce5c6257 +F test/shared3.test fcd65cb11d189eff5f5c85cc4fad246fb0933108 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e @@ -1114,7 +1114,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P cebd6fc551d26aea0f28cd7d25338fe0b72aae88 -R 912d3a86c8cb4e429312147af7faaf76 +P ed24051462c09220ebfb82a347b4a2b5c820ef63 +R 1c9468cd3e4eb9e8ee246e011c3ab7f4 U dan -Z 5b7e8c5d08bc668689f4627e9e0e9c87 +Z 68621d07be6c81e683d28bd021e6b41c diff --git a/manifest.uuid b/manifest.uuid index e597548d65..0255298402 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ed24051462c09220ebfb82a347b4a2b5c820ef63 \ No newline at end of file +1e1321ee985370c2b7e5bd64286bb4d7704b5a30 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 2ea55886aa..3e26f039da 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2668,7 +2668,7 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){ if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){ goto trans_begun; } - assert( IfNotOmitAV(pBt->bDoTruncate)==0 ); + assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 ); /* Write transactions are not possible on a read-only database */ if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){ diff --git a/test/shared3.test b/test/shared3.test index 783ae6a885..acc86d2a07 100644 --- a/test/shared3.test +++ b/test/shared3.test @@ -13,6 +13,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix shared3 db close ifcapable !shared_cache { @@ -103,5 +104,39 @@ db1 close db2 close db3 close +#------------------------------------------------------------------------- +# At one point this was causing a faulty assert to fail. +# +forcedelete test.db +sqlite3 db test.db +sqlite3 db2 test.db +do_execsql_test 3.1 { + PRAGMA auto_vacuum = 2; + CREATE TABLE t1(x, y); + INSERT INTO t1 VALUES(randomblob(500), randomblob(500)); + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; + INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; +} +do_test 3.2 { + execsql { SELECT count(*) FROM sqlite_master } db2 +} {1} +do_execsql_test 3.3 { + BEGIN; + DELETE FROM t1 WHERE 1; + PRAGMA incremental_vacuum; +} {} +do_test 3.4 { + execsql { SELECT count(*) FROM sqlite_master } db2 +} {1} +do_test 3.5 { + execsql { COMMIT } +} {} + sqlite3_enable_shared_cache $::enable_shared_cache finish_test +