aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest29
-rw-r--r--manifest.uuid2
-rw-r--r--src/btree.c23
-rw-r--r--src/btree.h4
-rw-r--r--src/main.c11
-rw-r--r--test/walshared.test60
6 files changed, 99 insertions, 30 deletions
diff --git a/manifest b/manifest
index f39b0eebd..f9a9bac42 100644
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Fix\sa\stypo\sin\san\serror\smessage\sof\sthe\sTCL\sinterface.
-D 2010-08-01T22:41:33
+C In\sshared-cache\smode,\sdo\snot\sallow\sone\sconnection\sto\scheckpoint\sa\sdatabase\swhile\sa\ssecond\sconnection\sis\sreading\sor\swriting\sthe\ssame\sshared-cache.
+D 2010-08-02T10:47:06
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -116,8 +113,8 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 51d83300fe0baee39405c416ceb19a58ed30a8ed
F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0
F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff
-F src/btree.c ed454f53f7bf7fb89c7a89f93fa93c5cd35e7aae
-F src/btree.h dd83041eda10c17daf023257c1fc883b5f71f85a
+F src/btree.c 2b122b7d7dec94670ecaa70f92397406100036aa
+F src/btree.h b4ba2fdf6b64c7c376bdfffa826af6b786b151d9
F src/btreeInt.h b0c87f6725b06a0aa194a6d25d54b16ce9d6e291
F src/build.c 0018d49629fc4807100c988dd191dd95e185bb38
F src/callback.c da3c38d0ef5d7f04fae371e519bda61aa9cb1704
@@ -138,7 +135,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 6d422ea91cf3d2d00408c5a8f2391cd458da85f8
-F src/main.c a487fe90aecaccb142e4a6b738c7e26e99145bcd
+F src/main.c 99622181f36d68e9f2a851c7b34263b3dcd03470
F src/malloc.c 19a468460c7df72de245f10c06bd0625777b7c83
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
@@ -796,6 +793,7 @@ F test/walcrash2.test 019d60b89d96c1937adb2b30b850ac7e86e5a142
F test/walfault.test 05c470688d742688e455dd56816bd6bcffa298f8
F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
F test/walmode.test 5dc3008ef71988ecdd949ea16e5750e325b92b54
+F test/walshared.test 985b4a3406b2b2dace1d52a42d26a11dd6900981
F test/walslow.test d21625e2e99e11c032ce949e8a94661576548933
F test/walthread.test a25a393c068a2b42b44333fa3fdaae9072f1617c
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
@@ -843,14 +841,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 83395a3d24f18170fc068d9e644291678694c3f0
-R f92e6db0a39655cd68bcc5f2c50bf7a0
-U drh
-Z 96b88b49422a23bacf04ccec86ee4d52
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFMVfghoxKgR168RlERAhFwAJ9pUD0NJCUWOUwGS01mnwnvqODQagCeM58z
-x49wm+oddVpJJ0N9H8UCG4k=
-=ka8W
------END PGP SIGNATURE-----
+P 8eadd7b87bfe8786e0352ca14b29d1451998c02c
+R a67fb210b5d7dd1a4ef9d58317971625
+U dan
+Z 5d06583ec8d1edb28c3029d4562549b8
diff --git a/manifest.uuid b/manifest.uuid
index 8b286a005..c41b79e53 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-8eadd7b87bfe8786e0352ca14b29d1451998c02c \ No newline at end of file
+e75b52d156905ce16bedb94f65c01a4640bdfa75 \ No newline at end of file
diff --git a/src/btree.c b/src/btree.c
index d07e4c3d6..c03d3c92b 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -7848,6 +7848,29 @@ int sqlite3BtreeIsInTrans(Btree *p){
return (p && (p->inTrans==TRANS_WRITE));
}
+#ifndef SQLITE_OMIT_WAL
+/*
+** Run a checkpoint on the Btree passed as the first argument.
+**
+** Return SQLITE_LOCKED if this or any other connection has an open
+** transaction on the shared-cache the argument Btree is connected to.
+*/
+int sqlite3BtreeCheckpoint(Btree *p){
+ int rc = SQLITE_OK;
+ if( p ){
+ BtShared *pBt = p->pBt;
+ sqlite3BtreeEnter(p);
+ if( pBt->inTransaction!=TRANS_NONE ){
+ rc = SQLITE_LOCKED;
+ }else{
+ rc = sqlite3PagerCheckpoint(pBt->pPager);
+ }
+ sqlite3BtreeLeave(p);
+ }
+ return rc;
+}
+#endif
+
/*
** Return non-zero if a read (or write) transaction is active.
*/
diff --git a/src/btree.h b/src/btree.h
index 584b46338..c989307aa 100644
--- a/src/btree.h
+++ b/src/btree.h
@@ -201,6 +201,10 @@ int sqlite3BtreeCursorInfo(BtCursor*, int*, int);
void sqlite3BtreeCursorList(Btree*);
#endif
+#ifndef SQLITE_OMIT_WAL
+ int sqlite3BtreeCheckpoint(Btree*);
+#endif
+
/*
** If we are not using shared cache, then there is no need to
** use mutexes to access the BtShared structures. So make the
diff --git a/src/main.c b/src/main.c
index c3828d5d9..b233c8473 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1308,16 +1308,7 @@ int sqlite3Checkpoint(sqlite3 *db, int iDb){
for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){
- Btree *pBt = db->aDb[i].pBt;
- if( pBt ){
- if( sqlite3BtreeIsInReadTrans(pBt) ){
- rc = SQLITE_LOCKED;
- }else{
- sqlite3BtreeEnter(pBt);
- rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
- sqlite3BtreeLeave(pBt);
- }
- }
+ rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt);
}
}
diff --git a/test/walshared.test b/test/walshared.test
new file mode 100644
index 000000000..658a25f9e
--- /dev/null
+++ b/test/walshared.test
@@ -0,0 +1,60 @@
+# 2010 August 2
+#
+# 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.
+#
+#***********************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this file is testing the operation of the library in
+# "PRAGMA journal_mode=WAL" mode with shared-cache turned on.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db close
+set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+
+sqlite3 db test.db
+sqlite3 db2 test.db
+
+do_test walshared-1.0 {
+ execsql {
+ PRAGMA cache_size = 10;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
+ }
+} {wal}
+
+do_test walshared-1.1 {
+ execsql {
+ BEGIN;
+ INSERT INTO t1 VALUES(randomblob(100), randomblob(200));
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;
+ }
+} {}
+
+do_test walshared-1.2 {
+ catchsql { PRAGMA wal_checkpoint }
+} {1 {database table is locked}}
+
+do_test walshared-1.3 {
+ catchsql { PRAGMA wal_checkpoint } db2
+} {1 {database table is locked}}
+
+do_test walshared-1.4 {
+ execsql { COMMIT }
+ execsql { PRAGMA integrity_check } db2
+} {ok}
+
+
+
+sqlite3_enable_shared_cache $::enable_shared_cache
+finish_test
+