From: dan Date: Thu, 27 Jun 2013 14:24:15 +0000 (+0000) Subject: Add a test to ensure that if BEGIN IMMEDIATE fails with SQLITE_BUSY, it does not... X-Git-Tag: version-3.8.0~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e8e570ab1586323c2bbbb774594203709c6fac13;p=thirdparty%2Fsqlite.git Add a test to ensure that if BEGIN IMMEDIATE fails with SQLITE_BUSY, it does not leave the user with an open read transaction (unless one was already open). FossilOrigin-Name: 22bced36f0f121f29d94f1f9eab45c8731517a53 --- diff --git a/manifest b/manifest index 9c67932ae5..db6e3038a9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C If\sthe\sfilename\sargument\sto\sthe\s".import"\scommand\sin\sthe\scommand-line\sshell\nbegins\swith\s'|'\sthen\streat\sit\sas\san\sinput\spipe\srather\sthan\sa\sfile. -D 2013-06-27T14:07:53.488 +C Add\sa\stest\sto\sensure\sthat\sif\sBEGIN\sIMMEDIATE\sfails\swith\sSQLITE_BUSY,\sit\sdoes\snot\sleave\sthe\suser\swith\san\sopen\sread\stransaction\s(unless\sone\swas\salready\sopen). +D 2013-06-27T14:24:15.136 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1012,7 +1012,7 @@ F test/wal2.test d4b470f13c87f6d8268b004380afa04c3c67cb90 F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal5.test 8f888b50f66b78821e61ed0e233ded5de378224b -F test/wal6.test b7dc01a1e8938b86e3a8f4e510634daf8bd50a44 +F test/wal6.test 1fbaf1f98415be10339b0ec85c9cba34fd2d4396 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test 75c42e1bc4545c277fed212f8fc9b7723cd02216 F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750 @@ -1098,7 +1098,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 656a1fe5dd670e6ce7173ed3ce3392c0151641a0 -R 97949a48417894542203b78a8164f7cc -U drh -Z 363202d577b3d015f15870ab9c3327f8 +P 4c02b344f5c6f6fb1c61b79d51063a1e0e2d75c0 +R f7e72c4156e7c539662844a39b9e3b02 +U dan +Z d4c7b57dd14fca50abddc9b4b3e495d3 diff --git a/manifest.uuid b/manifest.uuid index f795e73365..deb56ed743 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4c02b344f5c6f6fb1c61b79d51063a1e0e2d75c0 \ No newline at end of file +22bced36f0f121f29d94f1f9eab45c8731517a53 \ No newline at end of file diff --git a/test/wal6.test b/test/wal6.test index 75e8daeb27..d0ffa39d83 100644 --- a/test/wal6.test +++ b/test/wal6.test @@ -143,5 +143,57 @@ do_test 2.x { db2 close } {} +#------------------------------------------------------------------------- +# Check that if BEGIN IMMEDIATE fails, it does not leave the user with +# an open read-transaction (unless one was already open before the BEGIN +# IMMEDIATE). Even if there are other active VMs. +# + +proc test4 {prefix} { + do_test $prefix.1 { + catchsql { BEGIN IMMEDIATE } + } {1 {database is locked}} + + do_test $prefix.2 { + execsql { COMMIT } db2 + } {} + + do_test $prefix.3 { + execsql { BEGIN IMMEDIATE } + } {} + do_test $prefix.4 { + execsql { COMMIT } + } {} +} + +reset_db +sqlite3 db2 test.db +do_execsql_test 3.1 { + PRAGMA journal_mode = WAL; + CREATE TABLE ab(a PRIMARY KEY, b); +} {wal} + +do_test 3.2.1 { + execsql { + BEGIN; + INSERT INTO ab VALUES(1, 2); + } db2 +} {} +test4 3.2.2 + +db func test4 test4 +do_test 3.3.1 { + execsql { + BEGIN; + INSERT INTO ab VALUES(3, 4); + } db2 +} {} + +db eval {SELECT test4('3.3.2')} + +do_test 3.x { + db2 close +} {} + finish_test