/ Check-in [aef61036]
Login

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

Overview
Comment:Fix minor problems with the output of "PRAGMA wal_checkpoint". In both code and tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:aef61036b31963e4c3ff4e8acf8c1734dc9394af
User & Date: dan 2011-02-02 19:17:39
Context
2011-02-03
01:26
Fix a superlock test case to conform to the new wal_checkpoint returns. check-in: 8bf2d51b user: drh tags: trunk
2011-02-02
19:17
Fix minor problems with the output of "PRAGMA wal_checkpoint". In both code and tests. check-in: aef61036 user: dan tags: trunk
17:30
Optimize handling of equality and range constraints on the "term" column of an fts4aux table. check-in: 386701de user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

  1637   1637     volatile WalCkptInfo *pInfo;    /* The checkpoint status information */
  1638   1638     int (*xBusy)(void*) = 0;        /* Function to call when waiting for locks */
  1639   1639   
  1640   1640     szPage = walPagesize(pWal);
  1641   1641     testcase( szPage<=32768 );
  1642   1642     testcase( szPage>=65536 );
  1643   1643     pInfo = walCkptInfo(pWal);
         1644  +  if( pnCkpt ) *pnCkpt = pInfo->nBackfill;
  1644   1645     if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;
  1645   1646   
  1646   1647     /* Allocate the iterator */
  1647   1648     rc = walIteratorInit(pWal, &pIter);
  1648   1649     if( rc!=SQLITE_OK ){
  1649   1650       return rc;
  1650   1651     }
  1651   1652     assert( pIter );
  1652   1653   
  1653         -  pInfo = walCkptInfo(pWal);
  1654   1654     mxPage = pWal->hdr.nPage;
  1655         -  if( pnCkpt ) *pnCkpt = pInfo->nBackfill;
  1656   1655     if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;
  1657   1656   
  1658   1657     /* Compute in mxSafeFrame the index of the last frame of the WAL that is
  1659   1658     ** safe to write into the database.  Frames beyond mxSafeFrame might
  1660   1659     ** overwrite database pages that are in use by active readers and thus
  1661   1660     ** cannot be backfilled from the WAL.
  1662   1661     */

Changes to test/superlock.test.

    56     56     INSERT INTO t1 VALUES(3, 4);
    57     57     PRAGMA journal_mode = WAL;
    58     58   } {wal}
    59     59   
    60     60   do_test 2.2 { sqlite3demo_superlock unlock test.db } {unlock}
    61     61   do_catchsql_test 2.3 { SELECT * FROM t1 }           {1 {database is locked}}
    62     62   do_catchsql_test 2.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
    63         -do_catchsql_test 2.5 { PRAGMA wal_checkpoint }      {1 {database is locked}}
           63  +do_catchsql_test 2.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}
    64     64   do_test 2.6 { unlock } {}
    65     65   
    66     66   do_execsql_test 3.1 { INSERT INTO t1 VALUES(3, 4) } 
    67     67   
    68     68   do_test 3.2 { sqlite3demo_superlock unlock test.db } {unlock}
    69     69   do_catchsql_test 3.3 { SELECT * FROM t1 }           {1 {database is locked}}
    70     70   do_catchsql_test 3.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
    71         -do_catchsql_test 3.5 { PRAGMA wal_checkpoint }      {1 {database is locked}}
           71  +do_catchsql_test 3.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}
    72     72   do_test 3.6 { unlock } {}
    73     73   
    74         -do_execsql_test 4.1 { PRAGMA wal_checkpoint } {}
           74  +do_execsql_test 4.1 { PRAGMA wal_checkpoint } {0 2 2}
    75     75   
    76     76   do_test 4.2 { sqlite3demo_superlock unlock test.db } {unlock}
    77     77   do_catchsql_test 4.3 { SELECT * FROM t1 }           {1 {database is locked}}
    78     78   do_catchsql_test 4.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}
    79         -do_catchsql_test 4.5 { PRAGMA wal_checkpoint }      {1 {database is locked}}
           79  +do_catchsql_test 4.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}
    80     80   do_test 4.6 { unlock } {}
    81     81   
    82     82   do_multiclient_test tn {
    83     83   
    84     84     proc busyhandler {x} {
    85     85       switch -- $x {
    86     86         1 { sql1 "COMMIT" }
................................................................................
   112    112       set ::busylist
   113    113     } {0 1 2 3}
   114    114   
   115    115     do_test 5.$tn.4 { csql2 { SELECT * FROM t1 } } {1 {database is locked}}
   116    116     do_test 5.$tn.5 { 
   117    117       csql3 { INSERT INTO t1 VALUES(5, 6) } 
   118    118     } {1 {database is locked}}
   119         -  do_test 5.$tn.6 { csql1 "PRAGMA wal_checkpoint" } {1 {database is locked}}
          119  +  do_test 5.$tn.6 { csql1 "PRAGMA wal_checkpoint" } {0 {1 -1 -1}}
   120    120   
   121    121     do_test 5.$tn.7 { unlock } {}
   122    122   
   123    123     
   124    124     do_test 5.$tn.8 {
   125    125       sql1 { BEGIN ; SELECT * FROM t1 }
   126    126       sql2 { BEGIN ; INSERT INTO t1 VALUES(5, 6) }

Changes to test/wal2.test.

  1178   1178       INSERT INTO t1 VALUES(1, 2);          -- 1 wal sync
  1179   1179       PRAGMA wal_checkpoint;                -- 1 wal sync, 1 db sync
  1180   1180       BEGIN;
  1181   1181         INSERT INTO t1 VALUES(3, 4);
  1182   1182         INSERT INTO t1 VALUES(5, 6);
  1183   1183       COMMIT;                               -- 1 wal sync
  1184   1184       PRAGMA wal_checkpoint;                -- 1 wal sync, 1 db sync
  1185         -  } {10}
         1185  +  } {10 0 5 5 0 2 2}
  1186   1186   
  1187   1187     do_test wal2-14.$tn.3 {
  1188   1188       list $sqlite_sync_count $sqlite_fullsync_count
  1189   1189     } [lrange $reslist 0 1]
  1190   1190   
  1191   1191     set sqlite_sync_count 0
  1192   1192     set sqlite_fullsync_count 0