/ Check-in [63483e22]
Login

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

Overview
Comment:Improve testing of the wal.c changes on this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256: 63483e22c775183e01924b5cb3d0f3655b63c3cdd06faf26cacd4d0913c0055c
User & Date: dan 2018-12-26 20:42:32
Wiki:wal2
Context
2018-12-27
16:49
Increase test coverage of wal.c provided by permutation "coverage-wal" on this branch. check-in: 2f7f893a user: dan tags: wal2
2018-12-26
20:42
Improve testing of the wal.c changes on this branch. check-in: 63483e22 user: dan tags: wal2
19:10
Merge latest trunk changes with this branch. check-in: 404f9d99 user: dan tags: wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

   572    572   **
   573    573   **   u32  walidxGetMxFrame(WalIndexHdr*, int iWal);          // get mxFrame
   574    574   **   void walidxSetMxFrame(WalIndexHdr*, int iWal, u32 val); // set mxFrame
   575    575   **   int  walidxGetFile(WalIndexHdr*)                        // get file
   576    576   **   void walidxSetFile(WalIndexHdr*, int val);              // set file
   577    577   */
   578    578   #define walidxGetMxFrame(pHdr, iWal) \
   579         -  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFF) : (pHdr)->mxFrame)
          579  +  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFFF) : (pHdr)->mxFrame)
   580    580   
   581    581   static void walidxSetMxFrame(WalIndexHdr *pHdr, int iWal, u32 mxFrame){
   582    582     if( iWal ){
   583    583       pHdr->mxFrame2 = (pHdr->mxFrame2 & 0x80000000) | mxFrame;
   584    584     }else{
   585    585       pHdr->mxFrame = mxFrame;
   586    586     }
................................................................................
  4423   4423       if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){
  4424   4424         sqlite3OsUnfetch(pWal->pDbFd, 0, 0);
  4425   4425       }
  4426   4426     }
  4427   4427   
  4428   4428     /* Copy data from the log to the database file. */
  4429   4429     if( rc==SQLITE_OK ){
         4430  +    int iCkpt = walidxGetFile(&pWal->hdr);
  4430   4431   
  4431         -    if( (walPagesize(pWal)!=nBuf) 
  4432         -     && (walidxGetMxFrame(&pWal->hdr, 0) || walidxGetMxFrame(&pWal->hdr, 1))
  4433         -    ){
         4432  +    if( (walPagesize(pWal)!=nBuf) && walidxGetMxFrame(&pWal->hdr, iCkpt) ){
  4434   4433         rc = SQLITE_CORRUPT_BKPT;
  4435   4434       }else{
  4436   4435         rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
  4437   4436       }
  4438   4437   
  4439   4438       /* If no error occurred, set the output variables. */
  4440   4439       if( rc==SQLITE_OK || rc==SQLITE_BUSY ){
  4441   4440         if( pnLog ){
  4442   4441           *pnLog = walidxGetMxFrame(&pWal->hdr,0)+walidxGetMxFrame(&pWal->hdr,1);
  4443   4442         }
  4444   4443         if( pnCkpt ){
  4445   4444           if( isWalMode2(pWal) ){
  4446   4445             if( (int)(walCkptInfo(pWal)->nBackfill) ){
  4447         -            *pnCkpt = walidxGetMxFrame(&pWal->hdr, !walidxGetFile(&pWal->hdr));
         4446  +            *pnCkpt = walidxGetMxFrame(&pWal->hdr, iCkpt);
  4448   4447             }else{
  4449   4448               *pnCkpt = 0;
  4450   4449             }
  4451   4450           }else{
  4452   4451             *pnCkpt = walCkptInfo(pWal)->nBackfill;
  4453   4452           }
  4454   4453         }

Changes to test/permutations.test.

   440    440     walprotocol.test walro2.test walrofault.test walro.test
   441    441     walshared.test walslow.test wal.test
   442    442     wal2savepoint.test wal2lock.test wal2recover2.test
   443    443     walvfs.test walfault2.test nockpt.test
   444    444     snapshot2.test snapshot3.test snapshot4.test
   445    445     snapshot_fault.test snapshot.test snapshot_up.test
   446    446     walcrash2.test walcrash3.test walcrash4.test walcrash.test
          447  +  wal2fault.test
   447    448   } 
   448    449   
   449    450   test_suite "coverage-pager" -description {
   450    451     Coverage tests for file pager.c.
   451    452   } -files {
   452    453     pager1.test    pager2.test  pagerfault.test  pagerfault2.test
   453    454     walfault.test  walbak.test  journal2.test    tkt-9d68c883.test

Added test/wal2fault.test.

            1  +# 2010 May 03
            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.  The
           12  +# focus of this file is testing the operation of the library in
           13  +# "PRAGMA journal_mode=WAL" mode.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +source $testdir/malloc_common.tcl
           19  +source $testdir/lock_common.tcl
           20  +
           21  +ifcapable !wal {finish_test ; return }
           22  +set testprefix wal2fault
           23  +
           24  +do_execsql_test 1.0 {
           25  +  CREATE TABLE t1(x,y);
           26  +  PRAGMA journal_mode = wal2;
           27  +  WITH s(i) AS ( SELECT 100 UNION ALL SELECT i-1 FROM s WHERE (i-1)>0 )
           28  +  INSERT INTO t1 SELECT i, randomblob(i) FROM s;
           29  +  WITH s(i) AS ( SELECT 100 UNION ALL SELECT i-1 FROM s WHERE (i-1)>0 )
           30  +  INSERT INTO t1 SELECT i, randomblob(i) FROM s;
           31  +} {wal2}
           32  +
           33  +do_test 1.1 {
           34  +  expr [file size test.db-wal]>10000
           35  +} {1}
           36  +faultsim_save_and_close
           37  +
           38  +do_faultsim_test 1 -prep {
           39  +  faultsim_restore_and_reopen
           40  +  execsql {
           41  +    PRAGMA journal_size_limit = 10000;
           42  +    SELECT count(*) FROM sqlite_master;
           43  +  }
           44  +} -body {
           45  +  execsql {
           46  +    INSERT INTO t1 VALUES(1, 2);
           47  +  }
           48  +} -test {
           49  +  faultsim_test_result {0 {}}
           50  +}
           51  +
           52  +finish_test

Changes to test/wal2savepoint.test.

    50     50       ROLLBACK TO abc;
    51     51       WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 10)
    52     52       INSERT INTO t1 SELECT random(), random(), random() FROM s;
    53     53     COMMIT;
    54     54     SELECT count(*) FROM t1;
    55     55     PRAGMA integrity_check;
    56     56   } {210 ok}
           57  +
           58  +do_execsql_test 1.4 {
           59  +  BEGIN;
           60  +    SAVEPOINT abc;
           61  +      WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 100)
           62  +      INSERT INTO t1 SELECT random(), random(), random() FROM s;
           63  +    ROLLBACK TO abc;
           64  +    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 10)
           65  +    INSERT INTO t1 SELECT random(), random(), random() FROM s;
           66  +  COMMIT;
           67  +  SELECT count(*) FROM t1;
           68  +  PRAGMA integrity_check;
           69  +} {220 ok}
    57     70   
    58     71   
    59     72   finish_test
    60     73