From cd7b91a7f16274bd4dc9ee2d6bf8976a99e7f6a7 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 13 May 2013 18:23:15 +0000 Subject: [PATCH] Candidate fixes for problems revealed by notify2.test. Notify2.test is still failing at this point. FossilOrigin-Name: ea0428f9b6e63066e7444a2ba2f8c12a2e3ab7e4 --- manifest | 18 +++++--- manifest.uuid | 2 +- src/main.c | 4 +- test/sharedA.test | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 test/sharedA.test diff --git a/manifest b/manifest index 525586f02f..008ee4a3df 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sassert()s\sto\sthe\simplementation\sof\sxRead()\sin\sthe\sbuilt-in\sVFSes\sto\s\nverify\sthat\sthe\soffset\sparameter\sis\salways\snon-negative. -D 2013-05-09T18:12:40.898 +C Candidate\sfixes\sfor\sproblems\srevealed\sby\snotify2.test.\sNotify2.test\sis\sstill\sfailing\sat\sthis\spoint. +D 2013-05-13T18:23:15.893 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in ce81671efd6223d19d4c8c6b88ac2c4134427111 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -159,7 +159,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/loadext.c c48f7f3f170e502fe0cc20748e03c6e0b5a016c2 -F src/main.c 7531758e3167006f55cd65678d9c72a3c1a6759a +F src/main.c 2ef7316bae009d8b1cf218a52f25abda50712aab F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 437c7c4af964895d4650f29881df63535caaa1fa @@ -737,6 +737,7 @@ F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e F test/shared8.test b27befbefbe7f4517f1d6b7ff8f64a41ec74165d F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21 +F test/sharedA.test 2dad757bb388779d6bda8c05ec52e39e9981a135 F test/shared_err.test 0079c05c97d88cfa03989b7c20a8b266983087aa F test/sharedlock.test ffa0a3c4ac192145b310f1254f8afca4d553eabf F test/shell1.test 4a2f57952719972c6f862134463f8712e953c038 @@ -1062,7 +1063,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 1128575d0ab24f7023a0f6e6ce4828b9a09a7c6c -R 1cad29e868ca8cf8d5b7d354acd90934 -U drh -Z 3b3f34da85296e9879a826be138cb510 +P cf5c3642247fdd34d87f0368594cd7b8f081636a +R 9334ad7d318214aee7b701f9959b5d6e +T *branch * shared-cache-fixes +T *sym-shared-cache-fixes * +T -sym-trunk * +U dan +Z 816ab4789f48f56b3bf310736184e47d diff --git a/manifest.uuid b/manifest.uuid index 03a8fec162..133cb8b794 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cf5c3642247fdd34d87f0368594cd7b8f081636a \ No newline at end of file +ea0428f9b6e63066e7444a2ba2f8c12a2e3ab7e4 \ No newline at end of file diff --git a/src/main.c b/src/main.c index 3b6cd9e821..6f674cf4a3 100644 --- a/src/main.c +++ b/src/main.c @@ -836,7 +836,7 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ ** SQL statements below, as the v-table implementation may be storing ** some prepared statements internally. */ - sqlite3VtabRollback(db); + sqlite3RollbackAll(db, SQLITE_ABORT); /* Legacy behavior (sqlite3_close() behavior) is to return ** SQLITE_BUSY if the connection can not be closed immediately. @@ -1002,6 +1002,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ int inTrans = 0; assert( sqlite3_mutex_held(db->mutex) ); sqlite3BeginBenignMalloc(); + sqlite3BtreeEnterAll(db); for(i=0; inDb; i++){ Btree *p = db->aDb[i].pBt; if( p ){ @@ -1019,6 +1020,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){ sqlite3ExpirePreparedStatements(db); sqlite3ResetAllSchemasOfConnection(db); } + sqlite3BtreeLeaveAll(db); /* Any deferred constraint violations have now been resolved. */ db->nDeferredCons = 0; diff --git a/test/sharedA.test b/test/sharedA.test new file mode 100644 index 0000000000..675041408b --- /dev/null +++ b/test/sharedA.test @@ -0,0 +1,115 @@ +# 2013 May 14 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Test some specific circumstances to do with shared cache mode. +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +db close +set ::testprefix x + +set ::enable_shared_cache [sqlite3_enable_shared_cache 1] + +#------------------------------------------------------------------------- +# +do_test 1.1 { + sqlite3 db1 test.db + sqlite3 db2 test.db + db2 eval { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(123); + } + db1 eval { + SELECT * FROM t1; + CREATE INDEX i1 ON t1(x); + } +} {123} + +do_test 1.2 { + db2 eval { SELECT * FROM t1 ORDER BY x; } + + db1 eval { + BEGIN; DROP INDEX i1; + } + db1 close + + db2 eval { SELECT * FROM t1 ORDER BY x; } +} {123} + +do_test 1.3 { + db2 close +} {} + +#------------------------------------------------------------------------- +# +testvfs tvfs +tvfs filter xRead +tvfs script read_callback +proc read_callback {args} { } + +do_test 2.1 { + forcedelete test.db test.db2 + sqlite3 db1 test.db -vfs tvfs + db1 eval { ATTACH 'test.db2' AS two } + + db1 eval { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(1); + INSERT INTO t1 VALUES(2); + INSERT INTO t1 VALUES(3); + CREATE TABLE two.t2(x); + INSERT INTO t2 SELECT * FROM t1; + } + + sqlite3 db2 test.db -vfs tvfs + db2 eval { SELECT * FROM t1 } +} {1 2 3} + +do_test 2.2 { + set ::STMT [sqlite3_prepare db2 "CREATE INDEX i1 ON t1(x)" -1 tail] + set {} {} +} {} + +do_test 2.3 { + db1 eval { + BEGIN; + CREATE INDEX i1 ON t1(x); + INSERT INTO t2 VALUES('value!'); + } +} {} + +set ::bFired 0 +proc read_callback {call file args} { + if { $::bFired==0 && [string match *test.db2-journal $file] } { + sqlthread spawn ::thread_result [subst -nocommands { + sqlite3_step $::STMT + set rc [sqlite3_finalize $::STMT] + }] + after 1000 { set ::bFired 1 } + vwait ::bFired + } +} +do_test 2.4 { db1 eval ROLLBACK } {} + +if {[info exists ::thread_result]==0} { vwait ::thread_result } +do_test 2.5 { + list $::thread_result [sqlite3_errmsg db2] +} {SQLITE_SCHEMA {database schema has changed}} + +db1 close +db2 close +tvfs delete + +sqlite3_enable_shared_cache $::enable_shared_cache +finish_test +