/ Check-in [56458220]
Login

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

Overview
Comment:Add wal2 related tests to this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent-wal2
Files: files | file ages | folders
SHA3-256: 5645822039b9f36aeb986645106cac2d95b09964689deb767cadaa6ea1d1867f
User & Date: dan 2018-12-17 18:26:48
Wiki:begin-concurrent-wal2
Context
2018-12-18
16:24
Add the ".integrity_check" command to tserver. check-in: fa46fa3b user: dan tags: begin-concurrent-wal2
2018-12-17
18:26
Add wal2 related tests to this branch. check-in: 56458220 user: dan tags: begin-concurrent-wal2
15:22
Merge changes from wal2 branch. check-in: 85f49f0d user: dan tags: begin-concurrent-wal2
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/wal.c.

   547    547   **
   548    548   **   u32  walidxGetMxFrame(WalIndexHdr*, int iWal);          // get mxFrame
   549    549   **   void walidxSetMxFrame(WalIndexHdr*, int iWal, u32 val); // set mxFrame
   550    550   **   int  walidxGetFile(WalIndexHdr*)                        // get file
   551    551   **   void walidxSetFile(WalIndexHdr*, int val);              // set file
   552    552   */
   553    553   #define walidxGetMxFrame(pHdr, iWal) \
   554         -  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFF) : (pHdr)->mxFrame)
          554  +  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFFF) : (pHdr)->mxFrame)
   555    555   
   556    556   static void walidxSetMxFrame(WalIndexHdr *pHdr, int iWal, u32 mxFrame){
   557    557     if( iWal ){
   558    558       pHdr->mxFrame2 = (pHdr->mxFrame2 & 0x80000000) | mxFrame;
   559    559     }else{
   560    560       pHdr->mxFrame = mxFrame;
   561    561     }
................................................................................
  3762   3762   **
  3763   3763   ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
  3764   3764   */
  3765   3765   static int walUpgradeReadlock(Wal *pWal){
  3766   3766     int cnt;
  3767   3767     int rc;
  3768   3768     assert( pWal->writeLock && pWal->readLock==0 );
         3769  +  assert( isWalMode2(pWal)==0 );
  3769   3770     walUnlockShared(pWal, WAL_READ_LOCK(0));
  3770   3771     pWal->readLock = -1;
  3771   3772     cnt = 0;
  3772   3773     do{
  3773   3774       int notUsed;
  3774   3775       rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);
  3775   3776     }while( rc==WAL_RETRY );

Changes to test/permutations.test.

   436    436   wal64k.test wal6.test wal7.test wal8.test wal9.test
   437    437   walbak.test walbig.test walblock.test walcksum.test 
   438    438   walfault.test walhook.test walmode.test walnoshm.test
   439    439   waloverwrite.test walpersist.test walprotocol2.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  +
          444  +wal2concurrent.test
          445  +concurrent.test concurrent2.test concurrent3.test
          446  +concurrent4.test concurrent5.test concurrent6.test
          447  +concurrent7.test
   443    448   } 
   444    449   
   445    450   test_suite "coverage-pager" -description {
   446    451     Coverage tests for file pager.c.
   447    452   } -files {
   448    453     pager1.test    pager2.test  pagerfault.test  pagerfault2.test
   449    454     walfault.test  walbak.test  journal2.test    tkt-9d68c883.test

Changes to test/wal2concurrent.test.

    96     96       do_execsql_test 1.12 { SELECT count(*) FROM t2 } {2}
    97     97   
    98     98       do_test 1.13 {
    99     99         list [file size test.db-wal] [file size test.db-wal2]
   100    100       } {7368 2128}
   101    101     }
   102    102   }
          103  +
          104  +do_multiclient_test tn {
          105  +  do_test 2.$tn.1 {
          106  +    sql1 {
          107  +      PRAGMA auto_vacuum = OFF;
          108  +      CREATE TABLE t1(x UNIQUE);
          109  +      CREATE TABLE t2(x UNIQUE);
          110  +      PRAGMA journal_mode = wal2;
          111  +      PRAGMA journal_size_limit = 15000;
          112  +    }
          113  +  } {wal2 15000}
          114  +
          115  +  do_test 2.$tn.2 {
          116  +    sql1 {
          117  +      WITH s(i) AS (
          118  +        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<=10
          119  +      )
          120  +      INSERT INTO t1 SELECT randomblob(800) FROM s;
          121  +    }
          122  +  } {}
          123  +
          124  +  do_test 2.$tn.3 {
          125  +    sql1 { DELETE FROM t1 WHERE (rowid%4)==0 }
          126  +    list [expr [file size test.db-wal]>15000] \
          127  +         [expr [file size test.db-wal2]>15000]
          128  +  } {1 0}
          129  +
          130  +  do_test 2.$tn.4 {
          131  +    sql1 { PRAGMA wal_checkpoint; }
          132  +    sql1 { 
          133  +      BEGIN CONCURRENT;
          134  +        INSERT INTO t1 VALUES(randomblob(800));
          135  +    }
          136  +  } {}
          137  +
          138  +  do_test 2.$tn.5 {
          139  +    sql2 { 
          140  +      PRAGMA journal_size_limit = 15000;
          141  +      INSERT INTO t2 VALUES(randomblob(800));
          142  +      INSERT INTO t2 VALUES(randomblob(800));
          143  +      INSERT INTO t2 VALUES(randomblob(800));
          144  +      INSERT INTO t2 VALUES(randomblob(800));
          145  +      INSERT INTO t2 VALUES(randomblob(800));
          146  +      DELETE FROM t2;
          147  +    }
          148  +    list [expr [file size test.db-wal]>15000] \
          149  +         [expr [file size test.db-wal2]>15000]
          150  +  } {1 1}
          151  +
          152  +  do_test 2.$tn.6 {
          153  +    sql1 { 
          154  +        INSERT INTO t1 VALUES(randomblob(800));
          155  +      COMMIT;
          156  +      PRAGMA integrity_check;
          157  +    }
          158  +  } {ok}
          159  +}
          160  +
          161  +
   103    162   
   104    163   finish_test
   105    164   

Changes to test/wal2recover2.test.

   180    180     4 test.db2-wal2   salt1
   181    181   } {
   182    182     do_test 1.6.$tn {
   183    183       forcecopy test.db test.db2
   184    184       forcecopy test.db-wal2 test.db2-wal
   185    185       forcecopy test.db-wal test.db2-wal2
   186    186       wal_incr_hdrfield $file $field
   187         -    breakpoint
   188    187       sqlite3 db2 test.db2
   189    188       execsql {
   190    189         SELECT sum(x) FROM t1;
   191    190         SELECT sum(x) FROM t2;
   192    191       } db2
   193    192     } [list $H $L]
   194    193     db2 close
................................................................................
   207    206       forcecopy test.db-wal2 test.db2-wal
   208    207       forcecopy test.db-wal test.db2-wal2
   209    208   
   210    209       wal_set_nckpt test.db2-wal2 $nCkpt2
   211    210       wal_set_nckpt test.db2-wal  $nCkpt1
   212    211       wal_set_follow test.db2-wal test.db2-wal2
   213    212   
   214         -    if {$tn==1} breakpoint
   215    213   
   216    214       sqlite3 db2 test.db2
   217    215       execsql {
   218    216         SELECT sum(x) FROM t1;
   219    217         SELECT sum(x) FROM t2;
   220    218       } db2
   221    219     } $res
   222    220     db2 close
   223    221   }
          222  +
          223  +#-------------------------------------------------------------------------
          224  +reset_db
          225  +do_execsql_test 1.0 {
          226  +  CREATE TABLE t1(a, b, c);
          227  +  CREATE INDEX t1a ON t1(a);
          228  +  CREATE INDEX t1b ON t1(b);
          229  +  CREATE INDEX t1c ON t1(c);
          230  +  PRAGMA journal_mode = wal2;
          231  +
          232  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          233  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          234  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          235  +  PRAGMA journal_size_limit = 5000;
          236  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          237  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          238  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          239  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          240  +  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          241  +} {wal2 5000}
          242  +
          243  +do_test 2.1 {
          244  +  forcecopy test.db test.db2
          245  +  forcecopy test.db-wal2 test.db2-wal
          246  +  forcecopy test.db-wal test.db2-wal2
          247  +  
          248  +  hexio_write test.db2-wal 5000 1234567890
          249  +} {5}
          250  +
          251  +do_test 2.2 {
          252  +  sqlite3 db2 test.db2
          253  +  breakpoint
          254  +  execsql {
          255  +    SELECT count(*) FROM t1;
          256  +    PRAGMA integrity_check
          257  +  } db2
          258  +} {4 ok}
          259  +
          260  +do_test 2.3 {
          261  +  execsql {
          262  +    INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
          263  +    SELECT count(*) FROM t1;
          264  +    PRAGMA integrity_check
          265  +  } db2
          266  +} {5 ok}
   224    267   
   225    268   
   226    269   finish_test
   227    270