SQLite

Check-in [5645822039]
Login

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

Overview
Comment:Add wal2 related tests to this branch.
Downloads: Tarball | ZIP 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.041
Context
2018-12-18
16:24
Add the ".integrity_check" command to tserver. (check-in: fa46fa3bfc user: dan tags: begin-concurrent-wal2)
2018-12-17
18:26
Add wal2 related tests to this branch. (check-in: 5645822039 user: dan tags: begin-concurrent-wal2)
15:22
Merge changes from wal2 branch. (check-in: 85f49f0d73 user: dan tags: begin-concurrent-wal2)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/wal.c.
547
548
549
550
551
552
553
554

555
556
557
558
559
560
561
547
548
549
550
551
552
553

554
555
556
557
558
559
560
561







-
+







**
**   u32  walidxGetMxFrame(WalIndexHdr*, int iWal);          // get mxFrame
**   void walidxSetMxFrame(WalIndexHdr*, int iWal, u32 val); // set mxFrame
**   int  walidxGetFile(WalIndexHdr*)                        // get file
**   void walidxSetFile(WalIndexHdr*, int val);              // set file
*/
#define walidxGetMxFrame(pHdr, iWal) \
  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFF) : (pHdr)->mxFrame)
  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFFF) : (pHdr)->mxFrame)

static void walidxSetMxFrame(WalIndexHdr *pHdr, int iWal, u32 mxFrame){
  if( iWal ){
    pHdr->mxFrame2 = (pHdr->mxFrame2 & 0x80000000) | mxFrame;
  }else{
    pHdr->mxFrame = mxFrame;
  }
3762
3763
3764
3765
3766
3767
3768

3769
3770
3771
3772
3773
3774
3775
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776







+







**
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
*/
static int walUpgradeReadlock(Wal *pWal){
  int cnt;
  int rc;
  assert( pWal->writeLock && pWal->readLock==0 );
  assert( isWalMode2(pWal)==0 );
  walUnlockShared(pWal, WAL_READ_LOCK(0));
  pWal->readLock = -1;
  cnt = 0;
  do{
    int notUsed;
    rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);
  }while( rc==WAL_RETRY );
Changes to test/permutations.test.
436
437
438
439
440
441
442





443
444
445
446
447
448
449
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454







+
+
+
+
+







wal64k.test wal6.test wal7.test wal8.test wal9.test
walbak.test walbig.test walblock.test walcksum.test 
walfault.test walhook.test walmode.test walnoshm.test
waloverwrite.test walpersist.test walprotocol2.test
walprotocol.test walro2.test walrofault.test walro.test
walshared.test walslow.test wal.test
wal2savepoint.test wal2lock.test wal2recover2.test

wal2concurrent.test
concurrent.test concurrent2.test concurrent3.test
concurrent4.test concurrent5.test concurrent6.test
concurrent7.test
} 

test_suite "coverage-pager" -description {
  Coverage tests for file pager.c.
} -files {
  pager1.test    pager2.test  pagerfault.test  pagerfault2.test
  walfault.test  walbak.test  journal2.test    tkt-9d68c883.test
Changes to test/wal2concurrent.test.
96
97
98
99
100
101
102



























































103
104
105
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



    do_execsql_test 1.12 { SELECT count(*) FROM t2 } {2}

    do_test 1.13 {
      list [file size test.db-wal] [file size test.db-wal2]
    } {7368 2128}
  }
}

do_multiclient_test tn {
  do_test 2.$tn.1 {
    sql1 {
      PRAGMA auto_vacuum = OFF;
      CREATE TABLE t1(x UNIQUE);
      CREATE TABLE t2(x UNIQUE);
      PRAGMA journal_mode = wal2;
      PRAGMA journal_size_limit = 15000;
    }
  } {wal2 15000}

  do_test 2.$tn.2 {
    sql1 {
      WITH s(i) AS (
        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<=10
      )
      INSERT INTO t1 SELECT randomblob(800) FROM s;
    }
  } {}

  do_test 2.$tn.3 {
    sql1 { DELETE FROM t1 WHERE (rowid%4)==0 }
    list [expr [file size test.db-wal]>15000] \
         [expr [file size test.db-wal2]>15000]
  } {1 0}

  do_test 2.$tn.4 {
    sql1 { PRAGMA wal_checkpoint; }
    sql1 { 
      BEGIN CONCURRENT;
        INSERT INTO t1 VALUES(randomblob(800));
    }
  } {}

  do_test 2.$tn.5 {
    sql2 { 
      PRAGMA journal_size_limit = 15000;
      INSERT INTO t2 VALUES(randomblob(800));
      INSERT INTO t2 VALUES(randomblob(800));
      INSERT INTO t2 VALUES(randomblob(800));
      INSERT INTO t2 VALUES(randomblob(800));
      INSERT INTO t2 VALUES(randomblob(800));
      DELETE FROM t2;
    }
    list [expr [file size test.db-wal]>15000] \
         [expr [file size test.db-wal2]>15000]
  } {1 1}

  do_test 2.$tn.6 {
    sql1 { 
        INSERT INTO t1 VALUES(randomblob(800));
      COMMIT;
      PRAGMA integrity_check;
    }
  } {ok}
}



finish_test

Changes to test/wal2recover2.test.
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
180
181
182
183
184
185
186

187
188
189
190
191
192
193







-







  4 test.db2-wal2   salt1
} {
  do_test 1.6.$tn {
    forcecopy test.db test.db2
    forcecopy test.db-wal2 test.db2-wal
    forcecopy test.db-wal test.db2-wal2
    wal_incr_hdrfield $file $field
    breakpoint
    sqlite3 db2 test.db2
    execsql {
      SELECT sum(x) FROM t1;
      SELECT sum(x) FROM t2;
    } db2
  } [list $H $L]
  db2 close
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224








225





































226
227
206
207
208
209
210
211
212

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270







-










+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


    forcecopy test.db-wal2 test.db2-wal
    forcecopy test.db-wal test.db2-wal2

    wal_set_nckpt test.db2-wal2 $nCkpt2
    wal_set_nckpt test.db2-wal  $nCkpt1
    wal_set_follow test.db2-wal test.db2-wal2

    if {$tn==1} breakpoint

    sqlite3 db2 test.db2
    execsql {
      SELECT sum(x) FROM t1;
      SELECT sum(x) FROM t2;
    } db2
  } $res
  db2 close
}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 1.0 {
  CREATE TABLE t1(a, b, c);
  CREATE INDEX t1a ON t1(a);
  CREATE INDEX t1b ON t1(b);
  CREATE INDEX t1c ON t1(c);
  PRAGMA journal_mode = wal2;

  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  PRAGMA journal_size_limit = 5000;
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
  INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
} {wal2 5000}

do_test 2.1 {
  forcecopy test.db test.db2
  forcecopy test.db-wal2 test.db2-wal
  forcecopy test.db-wal test.db2-wal2
  
  hexio_write test.db2-wal 5000 1234567890
} {5}

do_test 2.2 {
  sqlite3 db2 test.db2
  breakpoint
  execsql {
    SELECT count(*) FROM t1;
    PRAGMA integrity_check
  } db2
} {4 ok}

do_test 2.3 {
  execsql {
    INSERT INTO t1 VALUES(randomblob(50), randomblob(50), randomblob(50));
    SELECT count(*) FROM t1;
    PRAGMA integrity_check
  } db2
} {5 ok}


finish_test