/ Check-in [67bf1c9a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When committing a WAL transaction, make sure at least one page is written to the WAL file so that the WAL subsystem will have a page on which to set the commit flag. Ticket [2d1a5c67dfc236].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 67bf1c9a888b0d84d252d6c4c754c2c51994d208
User & Date: drh 2011-05-19 01:21:42
References
2011-05-19
01:46
Backport the [67bf1c9a88] fix for vanishing WAL transactions due to small cache spillage. Ticket [2d1a5c67dfc236]. Also bump the version number to 3.7.6.3 in preparation for patch release. check-in: e4d0f7ac user: drh tags: branch-3.7.6
Context
2011-05-19
07:53
Add another test for [2d1a5c67df]. check-in: 97fcd9e8 user: dan tags: trunk
02:48
Merge all the latest trunk changes into the sessions branch, especially the disappearing WAL transaction fix. check-in: 5b1b536c user: drh tags: sessions
01:51
Pull all the latest trunk changes, and especially the fix for WAL cache spills causing transactions to disappear, into the apple-osx branch. check-in: 8d1a6bb0 user: drh tags: apple-osx
01:21
When committing a WAL transaction, make sure at least one page is written to the WAL file so that the WAL subsystem will have a page on which to set the commit flag. Ticket [2d1a5c67dfc236]. check-in: 67bf1c9a user: drh tags: trunk
2011-05-18
17:15
Enable URI filenames in the command-line shell. Add a check to the beginning of the shell to make sure it is compiled with the same SQLite source and header. check-in: de58cb28 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  5743   5743       ** function has already been called, it is mostly a no-op.  However, any
  5744   5744       ** backup in progress needs to be restarted.
  5745   5745       */
  5746   5746       sqlite3BackupRestart(pPager->pBackup);
  5747   5747     }else{
  5748   5748       if( pagerUseWal(pPager) ){
  5749   5749         PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);
         5750  +      PgHdr *pPageOne = 0;
         5751  +      if( pList==0 ){
         5752  +        /* Must have at least one page for the WAL commit flag.
         5753  +        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */
         5754  +        rc = sqlite3PagerGet(pPager, 1, &pPageOne);
         5755  +        pList = pPageOne;
         5756  +        pList->pDirty = 0;
         5757  +      }
         5758  +      assert( pList!=0 || rc!=SQLITE_OK );
  5750   5759         if( pList ){
  5751   5760           rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1, 
  5752   5761               (pPager->fullSync ? pPager->syncFlags : 0)
  5753   5762           );
  5754   5763         }
         5764  +      sqlite3PagerUnref(pPageOne);
  5755   5765         if( rc==SQLITE_OK ){
  5756   5766           sqlite3PcacheCleanAll(pPager->pPCache);
  5757   5767         }
  5758   5768       }else{
  5759   5769         /* The following block updates the change-counter. Exactly how it
  5760   5770         ** does this depends on whether or not the atomic-update optimization
  5761   5771         ** was enabled at compile time, and if this transaction meets the 

Added test/tkt-2d1a5c67d.test.

            1  +# 2011 May 19
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library. Specifically,
           12  +# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
           13  +# been resolved.
           14  +#
           15  +# 
           16  +#
           17  +
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +
           21  +ifcapable !wal {finish_test; return}
           22  +
           23  +for {set ii 1} {$ii<=10} {incr ii} {
           24  +  do_test tkt-2d1a5c67d.1.$ii {
           25  +    db close
           26  +    forcedelete test.db test.db-wal
           27  +    sqlite3 db test.db
           28  +    db eval "PRAGMA cache_size=$::ii"
           29  +    db eval {
           30  +      PRAGMA journal_mode=WAL;
           31  +      CREATE TABLE t1(a,b);
           32  +      CREATE INDEX t1b ON t1(b);
           33  +      CREATE TABLE t2(x,y UNIQUE);
           34  +      INSERT INTO t2 VALUES(3,4);
           35  +      BEGIN;
           36  +      INSERT INTO t1(a,b) VALUES(1,2);
           37  +      SELECT 'A', * FROM t2 WHERE y=4;
           38  +      SELECT 'B', * FROM t1;
           39  +      COMMIT;
           40  +      SELECT 'C', * FROM t1;
           41  +    }
           42  +  } {wal A 3 4 B 1 2 C 1 2}
           43  +}
           44  +
           45  +db close
           46  +forcedelete test.db test.db-wal
           47  +sqlite3 db test.db
           48  +register_wholenumber_module db
           49  +db eval {
           50  +  PRAGMA journal_mode=WAL;
           51  +  CREATE TABLE t1(a,b);
           52  +  CREATE INDEX t1b ON t1(b);
           53  +  CREATE TABLE t2(x,y);
           54  +  CREATE VIRTUAL TABLE nums USING wholenumber;
           55  +  INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
           56  +                 WHERE value BETWEEN 1 AND 1000;
           57  +}
           58  +
           59  +for {set ii 1} {$ii<=10} {incr ii} {
           60  +  do_test tkt-2d1a5c67d.2.$ii {
           61  +    db eval "PRAGMA cache_size=$::ii"
           62  +    db eval {
           63  +      DELETE FROM t1;
           64  +      BEGIN;
           65  +      INSERT INTO t1(a,b) VALUES(1,2);
           66  +      SELECT sum(length(y)) FROM t2;
           67  +      COMMIT;
           68  +      SELECT * FROM t1;
           69  +    }
           70  +  } {1000000 1 2}
           71  +}
           72  +
           73  +finish_test