]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When committing a WAL transaction, make sure at least one page is
authordrh <drh@noemail.net>
Thu, 19 May 2011 01:21:42 +0000 (01:21 +0000)
committerdrh <drh@noemail.net>
Thu, 19 May 2011 01:21:42 +0000 (01:21 +0000)
written to the WAL file so that the WAL subsystem will have a page
on which to set the commit flag.
Ticket [2d1a5c67dfc236].

FossilOrigin-Name: 67bf1c9a888b0d84d252d6c4c754c2c51994d208

manifest
manifest.uuid
src/pager.c
test/tkt-2d1a5c67d.test [new file with mode: 0644]

index 16faa5700b1215ede5d5a0321cc1520ef4bdafdf..a2fbca16d75c5e183155053362fe3d233bd31a7e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enable\sURI\sfilenames\sin\sthe\scommand-line\sshell.\s\sAdd\sa\scheck\sto\sthe\nbeginning\sof\sthe\sshell\sto\smake\ssure\sit\sis\scompiled\swith\sthe\ssame\nSQLite\ssource\sand\sheader.
-D 2011-05-18T17:15:06.501
+C When\scommitting\sa\sWAL\stransaction,\smake\ssure\sat\sleast\sone\spage\sis\nwritten\sto\sthe\sWAL\sfile\sso\sthat\sthe\sWAL\ssubsystem\swill\shave\sa\spage\non\swhich\sto\sset\sthe\scommit\sflag.\nTicket\s[2d1a5c67dfc236].
+D 2011-05-19T01:21:42.431
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 11dcc00a8d0e5202def00e81732784fb0cc4fe1d
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -165,7 +165,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
 F src/os_unix.c 6d4a58d81ad4b782406519f3790202f330e89bb7
 F src/os_win.c 218b899469e570d46eb8147c2383075f7c026230
-F src/pager.c b7fe4b8e51d51a062618c4630c40d20a1a44cb80
+F src/pager.c 4b2358556c88660a94a4560de95dd728911e00fd
 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1
 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
 F src/pcache.c 09d38c44ab275db581f7a2f6ff8b9bc7f8c0faaa
@@ -705,6 +705,7 @@ F test/threadtest2.c ace893054fa134af3fc8d6e7cfecddb8e3acefb9
 F test/threadtest3.c 0ed13e09690f6204d7455fac3b0e8ece490f6eef
 F test/tkt-02a8e81d44.test 58494de77be2cf249228ada3f313fa399821c6ab
 F test/tkt-26ff0c2d1e.test 888324e751512972c6e0d1a09df740d8f5aaf660
+F test/tkt-2d1a5c67d.test 39d2368072315923021700a216379fcf23ac3a5c
 F test/tkt-2ea2425d34.test 1cf13e6f75d149b3209a0cb32927a82d3d79fb28
 F test/tkt-31338dca7e.test 5741cd48de500347a437ba1be58c8335e83c5a5e
 F test/tkt-313723c356.test c47f8a9330523e6f35698bf4489bcb29609b53ac
@@ -937,7 +938,7 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 186d7ff1d9804d508e472e4939608bf2be67bdc2
-R 45381afe8cd9a292cfb03ba775eccef4
+P de58cb28387f44c35b1a81bdab853cafd938c1a6
+R e623b89a5e0b9474dd0884ecf24382fc
 U drh
-Z 8316bf531771ea80911215ce32a98e54
+Z 83669a82fd950b01af57955dbca1c918
index 5de0e20c97ff7762098adede4f25740e044a5748..ad5e5387847228a7588ff6dc44d9333d51ca5ca9 100644 (file)
@@ -1 +1 @@
-de58cb28387f44c35b1a81bdab853cafd938c1a6
\ No newline at end of file
+67bf1c9a888b0d84d252d6c4c754c2c51994d208
\ No newline at end of file
index b622c7acfe6af0d59062a2a91a936f29923650eb..6bddd7fd1f4ba4e48bb174fb131893f9f58f93ff 100644 (file)
@@ -5747,11 +5747,21 @@ int sqlite3PagerCommitPhaseOne(
   }else{
     if( pagerUseWal(pPager) ){
       PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);
+      PgHdr *pPageOne = 0;
+      if( pList==0 ){
+        /* Must have at least one page for the WAL commit flag.
+        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */
+        rc = sqlite3PagerGet(pPager, 1, &pPageOne);
+        pList = pPageOne;
+        pList->pDirty = 0;
+      }
+      assert( pList!=0 || rc!=SQLITE_OK );
       if( pList ){
         rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1, 
             (pPager->fullSync ? pPager->syncFlags : 0)
         );
       }
+      sqlite3PagerUnref(pPageOne);
       if( rc==SQLITE_OK ){
         sqlite3PcacheCleanAll(pPager->pPCache);
       }
diff --git a/test/tkt-2d1a5c67d.test b/test/tkt-2d1a5c67d.test
new file mode 100644 (file)
index 0000000..676e60b
--- /dev/null
@@ -0,0 +1,73 @@
+# 2011 May 19
+#
+# 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. Specifically,
+# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
+# been resolved.
+#
+# 
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !wal {finish_test; return}
+
+for {set ii 1} {$ii<=10} {incr ii} {
+  do_test tkt-2d1a5c67d.1.$ii {
+    db close
+    forcedelete test.db test.db-wal
+    sqlite3 db test.db
+    db eval "PRAGMA cache_size=$::ii"
+    db eval {
+      PRAGMA journal_mode=WAL;
+      CREATE TABLE t1(a,b);
+      CREATE INDEX t1b ON t1(b);
+      CREATE TABLE t2(x,y UNIQUE);
+      INSERT INTO t2 VALUES(3,4);
+      BEGIN;
+      INSERT INTO t1(a,b) VALUES(1,2);
+      SELECT 'A', * FROM t2 WHERE y=4;
+      SELECT 'B', * FROM t1;
+      COMMIT;
+      SELECT 'C', * FROM t1;
+    }
+  } {wal A 3 4 B 1 2 C 1 2}
+}
+
+db close
+forcedelete test.db test.db-wal
+sqlite3 db test.db
+register_wholenumber_module db
+db eval {
+  PRAGMA journal_mode=WAL;
+  CREATE TABLE t1(a,b);
+  CREATE INDEX t1b ON t1(b);
+  CREATE TABLE t2(x,y);
+  CREATE VIRTUAL TABLE nums USING wholenumber;
+  INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
+                 WHERE value BETWEEN 1 AND 1000;
+}
+
+for {set ii 1} {$ii<=10} {incr ii} {
+  do_test tkt-2d1a5c67d.2.$ii {
+    db eval "PRAGMA cache_size=$::ii"
+    db eval {
+      DELETE FROM t1;
+      BEGIN;
+      INSERT INTO t1(a,b) VALUES(1,2);
+      SELECT sum(length(y)) FROM t2;
+      COMMIT;
+      SELECT * FROM t1;
+    }
+  } {1000000 1 2}
+}
+
+finish_test