/ Check-in [62a10101]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix an assert() in pager.c added by the previous commit. And various problems with test scripts in autovacuum and in-memory journal mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mistake
Files: files | file ages | folders
SHA1: 62a10101776b41236ff7bd08c8aa85765a43df7c
User & Date: dan 2010-07-03 10:00:01
Context
2010-07-03
12:00
Print the SQLite source_id() string when running speed tests. check-in: 6d7640ed user: drh tags: mistake
10:00
Fix an assert() in pager.c added by the previous commit. And various problems with test scripts in autovacuum and in-memory journal mode. check-in: 62a10101 user: dan tags: mistake
08:01
Do not attempt to open a WAL file for an in-memory or temporary database. Even if the database header suggests that it is a WAL database. check-in: 0fd80924 user: dan tags: mistake
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Deleted src/pager.c.

Changes to test/malloc.test.

330
331
332
333
334
335
336

337
338
339
340
341
342
343

if {$tcl_platform(platform)!="windows"} {
  do_malloc_test 14 -tclprep {
    catch {db close}
    sqlite3 db2 test2.db
    sqlite3_extended_result_codes db2 1
    db2 eval {

      PRAGMA synchronous = 0;
      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
      BEGIN;
      INSERT INTO t1 VALUES(3, 4);
    }
    copy_file test2.db test.db







>







330
331
332
333
334
335
336
337
338
339
340
341
342
343
344

if {$tcl_platform(platform)!="windows"} {
  do_malloc_test 14 -tclprep {
    catch {db close}
    sqlite3 db2 test2.db
    sqlite3_extended_result_codes db2 1
    db2 eval {
      PRAGMA journal_mode = DELETE;    /* For inmemory_journal permutation */
      PRAGMA synchronous = 0;
      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
      BEGIN;
      INSERT INTO t1 VALUES(3, 4);
    }
    copy_file test2.db test.db

Changes to test/pager1.test.

1011
1012
1013
1014
1015
1016
1017

1018
1019
1020
1021
1022
1023
1024
....
1353
1354
1355
1356
1357
1358
1359

1360
1361
1362
1363
1364
1365
1366
....
1425
1426
1427
1428
1429
1430
1431


1432
1433
1434
1435








1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459


1460
1461
1462
1463
1464
1465
1466

#-------------------------------------------------------------------------
# The following tests work with "PRAGMA max_page_count"
#
do_test pager1-6.1 {
  faultsim_delete_and_reopen
  execsql {

    PRAGMA max_page_count = 10;
    CREATE TABLE t2(a, b);
    CREATE TABLE t3(a, b);
    CREATE TABLE t4(a, b);
    CREATE TABLE t5(a, b);
    CREATE TABLE t6(a, b);
    CREATE TABLE t7(a, b);
................................................................................
}
db close

tv sectorsize 4096
do_test pager1.10.x.1 {
  faultsim_delete_and_reopen
  execsql {

    PRAGMA page_size = 1024;
    CREATE TABLE t1(x);
  }
  for {set i 0} {$i<30} {incr i} {
    execsql { INSERT INTO t1 VALUES(zeroblob(900)) }
  }
  file size test.db
................................................................................
do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
db close
tv delete
  
#-------------------------------------------------------------------------
# Test "PRAGMA page_size"
#


foreach pagesize {
    512   1024   2048 4096 8192 16384 32768 
} {
  faultsim_delete_and_reopen









  do_test pager1-12.$pagesize.1 {
    sqlite3 db2 test.db
    execsql "
      PRAGMA page_size = $pagesize;
      CREATE VIEW v AS SELECT * FROM sqlite_master;
    " db2
    file size test.db
  } $pagesize
  do_test pager1-12.$pagesize.2 {
    sqlite3 db2 test.db
    execsql { 
      SELECT count(*) FROM v;
      PRAGMA main.page_size;
    } db2
  } [list 1 $pagesize]
  do_test pager1-12.$pagesize.3 {
    execsql { 
      SELECT count(*) FROM v;
      PRAGMA main.page_size;
    }
  } [list 1 $pagesize]
  db2 close
}



#-------------------------------------------------------------------------
# Test specal "PRAGMA journal_mode=PERSIST" test cases.
#
# pager1-13.1.*: This tests a special case encountered in persistent 
#                journal mode: If the journal associated with a transaction
#                is smaller than the journal file (because a previous 







>







 







>







 







>
>




>
>
>
>
>
>
>
>








|






|





|


>
>







1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
....
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
....
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480

#-------------------------------------------------------------------------
# The following tests work with "PRAGMA max_page_count"
#
do_test pager1-6.1 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA auto_vacuum = none;
    PRAGMA max_page_count = 10;
    CREATE TABLE t2(a, b);
    CREATE TABLE t3(a, b);
    CREATE TABLE t4(a, b);
    CREATE TABLE t5(a, b);
    CREATE TABLE t6(a, b);
    CREATE TABLE t7(a, b);
................................................................................
}
db close

tv sectorsize 4096
do_test pager1.10.x.1 {
  faultsim_delete_and_reopen
  execsql {
    PRAGMA auto_vacuum = none;
    PRAGMA page_size = 1024;
    CREATE TABLE t1(x);
  }
  for {set i 0} {$i<30} {incr i} {
    execsql { INSERT INTO t1 VALUES(zeroblob(900)) }
  }
  file size test.db
................................................................................
do_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}
db close
tv delete
  
#-------------------------------------------------------------------------
# Test "PRAGMA page_size"
#
testvfs tv -default 1
tv sectorsize 1024
foreach pagesize {
    512   1024   2048 4096 8192 16384 32768 
} {
  faultsim_delete_and_reopen

  # The sector-size (according to the VFS) is 1024 bytes. So if the
  # page-size requested using "PRAGMA page_size" is greater than the
  # compile time value of SQLITE_MAX_PAGE_SIZE, then the effective 
  # page-size remains 1024 bytes.
  #
  set eff $pagesize
  if {$eff > $::SQLITE_MAX_PAGE_SIZE} { set eff 1024 }

  do_test pager1-12.$pagesize.1 {
    sqlite3 db2 test.db
    execsql "
      PRAGMA page_size = $pagesize;
      CREATE VIEW v AS SELECT * FROM sqlite_master;
    " db2
    file size test.db
  } $eff
  do_test pager1-12.$pagesize.2 {
    sqlite3 db2 test.db
    execsql { 
      SELECT count(*) FROM v;
      PRAGMA main.page_size;
    } db2
  } [list 1 $eff]
  do_test pager1-12.$pagesize.3 {
    execsql { 
      SELECT count(*) FROM v;
      PRAGMA main.page_size;
    }
  } [list 1 $eff]
  db2 close
}
db close
tv delete

#-------------------------------------------------------------------------
# Test specal "PRAGMA journal_mode=PERSIST" test cases.
#
# pager1-13.1.*: This tests a special case encountered in persistent 
#                journal mode: If the journal associated with a transaction
#                is smaller than the journal file (because a previous 

Changes to test/pagerfault.test.

237
238
239
240
241
242
243
244
245




246
247
248
249
250
251
252
    BEGIN;
      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
      CREATE TABLE aux.t2 AS SELECT * FROM t1;
    COMMIT;
  }
} -test {
  faultsim_test_result {0 {}}
  faultsim_integrity_check





  set res ""
  set rc [catch { set res [db one { PRAGMA aux.integrity_check }] }]
  if {$rc!=0 || $res != "ok"} {error "integrity-check problem:$rc $res"}
}

#-------------------------------------------------------------------------
# Test fault-injection as part of a commit when using 







<

>
>
>
>







237
238
239
240
241
242
243

244
245
246
247
248
249
250
251
252
253
254
255
    BEGIN;
      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
      CREATE TABLE aux.t2 AS SELECT * FROM t1;
    COMMIT;
  }
} -test {
  faultsim_test_result {0 {}}


  catchsql { COMMIT }
  catchsql { ROLLBACK }

  faultsim_integrity_check
  set res ""
  set rc [catch { set res [db one { PRAGMA aux.integrity_check }] }]
  if {$rc!=0 || $res != "ok"} {error "integrity-check problem:$rc $res"}
}

#-------------------------------------------------------------------------
# Test fault-injection as part of a commit when using 

Changes to test/pagerfault2.test.

32
33
34
35
36
37
38

39
40
41
42
43
44
45
}
db func a_string a_string

do_test pagerfault2-1-pre1 {
  faultsim_delete_and_reopen
  db func a_string a_string
  execsql {

    PRAGMA journal_mode = DELETE;
    PRAGMA page_size = 1024;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(a_string(401), a_string(402));
  }
  for {set ii 0} {$ii < 13} {incr ii} {
    execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }







>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
}
db func a_string a_string

do_test pagerfault2-1-pre1 {
  faultsim_delete_and_reopen
  db func a_string a_string
  execsql {
    PRAGMA auto_vacuum = 0;
    PRAGMA journal_mode = DELETE;
    PRAGMA page_size = 1024;
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(a_string(401), a_string(402));
  }
  for {set ii 0} {$ii < 13} {incr ii} {
    execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }

Changes to test/permutations.test.

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Define the coverage related test suites:
#
#   coverage-wal
#
test_suite "coverage-wal" -description {
  Coverage tests for file wal.c.
} -files {
  wal.test       wal2.test      wal3.test      walmode.test    
  walbak.test    walhook.test   walcrash2.test walcksum.test
  walfault.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
} 


lappend ::testsuitelist xxx
#-------------------------------------------------------------------------
# Define the permutation test suites:
#







|
|






<
<
<
|
<
<
<
|







156
157
158
159
160
161
162
163
164
165
166
167
168
169
170



171



172
173
174
175
176
177
178
179
# Define the coverage related test suites:
#
#   coverage-wal
#
test_suite "coverage-wal" -description {
  Coverage tests for file wal.c.
} -files {
  wal.test       wal2.test     wal3.test       walmode.test    
  walbak.test    walhook.test  walcrash2.test  walcksum.test
  walfault.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
} 


lappend ::testsuitelist xxx
#-------------------------------------------------------------------------
# Define the permutation test suites:
#

Changes to test/wal3.test.

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  set testname(1) multiproc
  set testname(2) singleproc
  set tn $testname($i)

  do_test wal3-2.$tn.1 {
    sql1 { 
      PRAGMA page_size = 1024;
      PRAGMA auto_vacuum = OFF; 
      PRAGMA journal_mode = WAL;
    }
    sql1 {
      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 'one');
      BEGIN;
        SELECT * FROM t1;







<







115
116
117
118
119
120
121

122
123
124
125
126
127
128
  set testname(1) multiproc
  set testname(2) singleproc
  set tn $testname($i)

  do_test wal3-2.$tn.1 {
    sql1 { 
      PRAGMA page_size = 1024;

      PRAGMA journal_mode = WAL;
    }
    sql1 {
      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 'one');
      BEGIN;
        SELECT * FROM t1;