SQLite

Check-in [e3e50bcdab]
Login

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

Overview
Comment:Add new test file wal2big.test.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal2
Files: files | file ages | folders
SHA3-256: e3e50bcdab8c91e003942d84430b3e580e034141236d19dda0e8af4ecf0e085b
User & Date: dan 2018-12-12 20:39:38.782
Context
2018-12-13
16:26
Add tests cases for recovery in wal2 mode. (check-in: 34f56f8a42 user: dan tags: wal2)
2018-12-12
20:39
Add new test file wal2big.test. (check-in: e3e50bcdab user: dan tags: wal2)
19:04
Add tests to ensure that each of the 4 wal read-locks does what it is supposed to. (check-in: 4d5779f31d user: dan tags: wal2)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/wal.c.
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221

  if( 0==(iHash & 0x01) ){
    /* A frame in wal file 0 */
    *piRead = (iExternal <= HASHTABLE_NPAGE_ONE) ? iExternal :
      iExternal - (iHash/2) * HASHTABLE_NPAGE;
    return 0;
  }
  if( iHash==0 ){
    *piRead = iExternal;
    return 0;
  }else{
    *piRead = iExternal - HASHTABLE_NPAGE_ONE - ((iHash-1)/2) * HASHTABLE_NPAGE;
  }

  return (iHash % 2);
}

/*
** Return the number of the wal-index page that contains the hash-table
** and page-number array that contain entries corresponding to WAL frame
** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages 
** are numbered starting from 0.







|
<
<
<
|
<
<
|







1200
1201
1202
1203
1204
1205
1206
1207



1208


1209
1210
1211
1212
1213
1214
1215
1216

  if( 0==(iHash & 0x01) ){
    /* A frame in wal file 0 */
    *piRead = (iExternal <= HASHTABLE_NPAGE_ONE) ? iExternal :
      iExternal - (iHash/2) * HASHTABLE_NPAGE;
    return 0;
  }




  *piRead = iExternal - HASHTABLE_NPAGE_ONE - ((iHash-1)/2) * HASHTABLE_NPAGE;


  return 1;
}

/*
** Return the number of the wal-index page that contains the hash-table
** and page-number array that contain entries corresponding to WAL frame
** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages 
** are numbered starting from 0.
Added test/wal2big.test.






















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 2017 September 19
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the operation of the library in
# "PRAGMA journal_mode=WAL2" mode.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl
source $testdir/wal_common.tcl

set testprefix wal2big
ifcapable !wal {finish_test ; return }

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;
  PRAGMA journal_size_limit = 10000000;

  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200000
  )
  INSERT INTO t1 SELECT random(), random(), random() FROM s;
} {wal2 10000000}

do_execsql_test 1.1 {
  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200000
  )
  INSERT INTO t1 SELECT random(), random(), random() FROM s;
}

do_test 1.1 {
  list [expr [file size test.db-wal]>10000000] \
       [expr [file size test.db-wal2]>10000000]
} {1 1}

do_test 1.2 {
  sqlite3 db2 test.db
  execsql {
    SELECT count(*) FROM t1;
    PRAGMA integrity_check;
  } db2
} {400000 ok}

finish_test