/ Check-in [622378db]
Login

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

Overview
Comment:Fix an assert in pager.c. And various test cases that fail with the in-memory journal permutation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:622378dbe3941f06c717c1e272cd1190e4358428
User & Date: dan 2010-07-03 13:50:12
Context
2010-07-03
13:59
Fix a bug in the permutations.test script. check-in: 3b20ad03 user: dan tags: trunk
13:50
Fix an assert in pager.c. And various test cases that fail with the in-memory journal permutation. check-in: 622378db user: dan tags: trunk
13:45
Fix an assert in pager.c. And various test cases that fail with the in-memory journal permutation. Closed-Leaf check-in: 78fc35ff user: dan tags: mistake
12:31
Cherry-pick the correct changes out of the recent "mistake" branch while omitting the bugs. check-in: 48bf3093 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

  5161   5161         ** Otherwise, if the optimization is both enabled and applicable,
  5162   5162         ** then call pager_incr_changecounter() to update the change-counter
  5163   5163         ** in 'direct' mode. In this case the journal file will never be
  5164   5164         ** created for this transaction.
  5165   5165         */
  5166   5166     #ifdef SQLITE_ENABLE_ATOMIC_WRITE
  5167   5167         PgHdr *pPg;
  5168         -      assert( isOpen(pPager->jfd) || pPager->journalMode==PAGER_JOURNALMODE_OFF );
         5168  +      assert( isOpen(pPager->jfd) 
         5169  +           || pPager->journalMode==PAGER_JOURNALMODE_OFF 
         5170  +           || pPager->journalMode==PAGER_JOURNALMODE_WAL 
         5171  +      );
  5169   5172         if( !zMaster && isOpen(pPager->jfd) 
  5170   5173          && pPager->journalOff==jrnlBufferSize(pPager) 
  5171   5174          && pPager->dbSize>=pPager->dbFileSize
  5172   5175          && (0==(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)
  5173   5176         ){
  5174   5177           /* Update the db file change counter via the direct-write method. The 
  5175   5178           ** following call will modify the in-memory representation of page 1 

Changes to test/jrnlmode.test.

   499    499           PRAGMA journal_mode = DELETE;
   500    500           BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;
   501    501         }
   502    502         file exists test.db-journal
   503    503       } {0}
   504    504     }
   505    505   }
          506  +
          507  +ifcapable pragma {
          508  +  catch { db close }
          509  +  do_test jrnlmode-7.1 {
          510  +    foreach f [glob -nocomplain test.db*] { file delete -force $f }
          511  +    sqlite3 db test.db
          512  +    execsql {
          513  +      PRAGMA journal_mode = memory;
          514  +      PRAGMA auto_vacuum = 0;
          515  +      PRAGMA page_size = 1024;
          516  +      PRAGMA user_version = 5;
          517  +      PRAGMA user_version;
          518  +    }
          519  +  } {memory 5}
          520  +  do_test jrnlmode-7.2 { file size test.db } {1024}
          521  +}
   506    522   
   507    523   finish_test

Changes to test/pager1.test.

   555    555     }
   556    556   } {
   557    557     eval $tcl
   558    558     foreach {tn2 sql} {
   559    559       o { 
   560    560         PRAGMA main.synchronous=OFF;
   561    561         PRAGMA aux.synchronous=OFF;
          562  +      PRAGMA journal_mode = DELETE;
   562    563       }
   563    564       o512 { 
   564    565         PRAGMA main.synchronous=OFF;
   565    566         PRAGMA aux.synchronous=OFF;
   566    567         PRAGMA main.page_size = 512;
   567    568         PRAGMA aux.page_size = 512;
          569  +      PRAGMA journal_mode = DELETE;
   568    570       }
   569    571       n { 
   570    572         PRAGMA main.synchronous=NORMAL;
   571    573         PRAGMA aux.synchronous=NORMAL;
          574  +      PRAGMA journal_mode = DELETE;
   572    575       }
   573    576       f { 
   574    577         PRAGMA main.synchronous=FULL;
   575    578         PRAGMA aux.synchronous=FULL;
          579  +      PRAGMA journal_mode = DELETE;
   576    580       }
   577    581     } {
   578    582   
   579    583       set tn "${tn1}.${tn2}"
   580    584     
   581    585       # Set up a connection to have two databases, test.db (main) and 
   582    586       # test.db2 (aux). Then run a multi-file transaction on them. The
................................................................................
   661    665   tv filter xDelete
   662    666   proc copy_on_journal_delete {method filename args} {
   663    667     if {[string match *journal $filename]} faultsim_save 
   664    668     return SQLITE_OK
   665    669   }
   666    670   faultsim_delete_and_reopen
   667    671   do_execsql_test pager1.4.5.1 {
          672  +  PRAGMA journal_mode = DELETE;
   668    673     PRAGMA page_size = 1024;
   669    674     CREATE TABLE t1(a, b);
   670    675     CREATE TABLE t2(a, b);
   671    676     INSERT INTO t1 VALUES('I', 'II');
   672    677     INSERT INTO t2 VALUES('III', 'IV');
   673    678     BEGIN;
   674    679       INSERT INTO t1 VALUES(1, 2);
   675    680       INSERT INTO t2 VALUES(3, 4);
   676    681     COMMIT;
   677         -} {}
          682  +} {delete}
   678    683   tv filter {}
   679    684   
   680    685   # Check the transaction was committed:
   681    686   #
   682    687   do_execsql_test pager1.4.5.2 {
   683    688     SELECT * FROM t1;
   684    689     SELECT * FROM t2;
................................................................................
   738    743       faultsim_save 
   739    744     }
   740    745     return SQLITE_OK
   741    746   }
   742    747   do_test pager1.4.6.1 {
   743    748     faultsim_delete_and_reopen
   744    749     execsql {
          750  +    PRAGMA journal_mode = DELETE;
   745    751       ATTACH 'test.db2' AS two;
   746    752       CREATE TABLE t1(a, b);
   747    753       CREATE TABLE two.t2(a, b);
   748    754       INSERT INTO t1 VALUES(1, 't1.1');
   749    755       INSERT INTO t2 VALUES(1, 't2.1');
   750    756       BEGIN;
   751    757         UPDATE t1 SET b = 't1.2';
................................................................................
   768    774   faultsim_restore_and_reopen
   769    775   db close
   770    776   do_test pager1.4.6.8 {
   771    777     set ::mj_filename1 $::mj_filename
   772    778     tv filter xDelete
   773    779     sqlite3 db test.db2
   774    780     execsql {
          781  +    PRAGMA journal_mode = DELETE;
   775    782       ATTACH 'test.db3' AS three;
   776    783       CREATE TABLE three.t3(a, b);
   777    784       INSERT INTO t3 VALUES(1, 't3.1');
   778    785       BEGIN;
   779    786         UPDATE t2 SET b = 't2.3';
   780    787         UPDATE t3 SET b = 't3.3';
   781    788       COMMIT;
................................................................................
   835    842   tv filter xDelete
   836    843   proc copy_on_journal_delete {method filename args} {
   837    844     if {[string match *journal $filename]} faultsim_save 
   838    845     return SQLITE_OK
   839    846   }
   840    847   faultsim_delete_and_reopen
   841    848   do_execsql_test pager1.4.7.1 {
          849  +  PRAGMA journal_mode = DELETE;
   842    850     CREATE TABLE t1(x PRIMARY KEY, y);
   843    851     CREATE INDEX i1 ON t1(y);
   844    852     INSERT INTO t1 VALUES('I',   'one');
   845    853     INSERT INTO t1 VALUES('II',  'four');
   846    854     INSERT INTO t1 VALUES('III', 'nine');
   847    855     BEGIN;
   848    856       INSERT INTO t1 VALUES('IV', 'sixteen');
   849    857       INSERT INTO t1 VALUES('V' , 'twentyfive');
   850    858     COMMIT;
   851         -} {}
          859  +} {delete}
   852    860   tv filter {}
   853    861   db close
   854    862   tv delete 
   855    863   do_test pager1.4.7.2 {
   856    864     faultsim_restore_and_reopen
   857    865     catch {file attributes test.db-journal -permissions r--------}
   858    866     catch {file attributes test.db-journal -readonly 1}
................................................................................
  1335   1343       execsql {
  1336   1344         CREATE TABLE t6(a, b);
  1337   1345         CREATE TABLE t7(a, b);
  1338   1346         CREATE TABLE t5(a, b);
  1339   1347         DROP TABLE t6;
  1340   1348         DROP TABLE t7;
  1341   1349       }
  1342         -    if {$eff==65536} breakpoint
  1343   1350       execsql {
  1344   1351         BEGIN;
  1345   1352           CREATE TABLE t6(a, b);
  1346   1353       }
  1347   1354       recursive_select 32 t3 {db eval "INSERT INTO t5 VALUES(1, 2)"}
  1348   1355       execsql {
  1349   1356         COMMIT;
................................................................................
  1389   1396   db close
  1390   1397   tv delete
  1391   1398   
  1392   1399   testvfs tv -default 1
  1393   1400   faultsim_delete_and_reopen
  1394   1401   db func a_string a_string
  1395   1402   do_execsql_test pager1-11.1 {
         1403  +  PRAGMA journal_mode = DELETE;
  1396   1404     PRAGMA cache_size = 10;
  1397   1405     BEGIN;
  1398   1406       CREATE TABLE zz(top PRIMARY KEY);
  1399   1407       INSERT INTO zz VALUES(a_string(222));
  1400   1408       INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
  1401   1409       INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
  1402   1410       INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
  1403   1411       INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
  1404   1412       INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;
  1405   1413     COMMIT;
  1406   1414     BEGIN;
  1407   1415       UPDATE zz SET top = a_string(345);
  1408         -} {}
         1416  +} {delete}
  1409   1417   
  1410   1418   proc lockout {method args} { return SQLITE_IOERR }
  1411   1419   tv script lockout
  1412   1420   tv filter {xWrite xTruncate xSync}
  1413   1421   do_catchsql_test pager1-11.2 { COMMIT } {1 {disk I/O error}}
  1414   1422   
  1415   1423   tv script {}

Changes to test/walmode.test.

    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the operation of the library in
    13     13   # "PRAGMA journal_mode=WAL" mode.
    14     14   #
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
           18  +source $testdir/malloc_common.tcl
    18     19   
    19     20   # If the library was compiled without WAL support, check that the 
    20     21   # "PRAGMA journal_mode=WAL" treats "WAL" as an unrecognized mode.
    21     22   #
    22     23   ifcapable !wal {
    23     24   
    24     25     do_test walmode-0.1 {
................................................................................
   263    264     execsql { 
   264    265       INSERT INTO t1 VALUES(3, 4);
   265    266       SELECT * FROM t1;
   266    267       PRAGMA temp.journal_mode;
   267    268     }
   268    269   } [list 1 2 3 4 $tempJrnlMode]
   269    270   
          271  +
          272  +#-------------------------------------------------------------------------
          273  +# Test changing to WAL mode from journal_mode=off or journal_mode=memory
          274  +#
          275  +foreach {tn mode} {
          276  +  3 persist
          277  +  4 delete
          278  +  5 truncate
          279  +  2 memory
          280  +  1 off
          281  +} {
          282  +  do_test walmode-6.$tn {
          283  +    faultsim_delete_and_reopen
          284  +    execsql "
          285  +      PRAGMA journal_mode = $mode;
          286  +      PRAGMA journal_mode = wal;
          287  +    "
          288  +  } [list $mode wal]
          289  +}
          290  +
   270    291   finish_test