| Index: third_party/sqlite/src/test/pager1.test
|
| diff --git a/third_party/sqlite/src/test/pager1.test b/third_party/sqlite/src/test/pager1.test
|
| index 005b356080dd98271b8aaf306ca8bb021d3dc4ed..c25c837b670b9cebb416b64d8f81b8468f1a0944 100644
|
| --- a/third_party/sqlite/src/test/pager1.test
|
| +++ b/third_party/sqlite/src/test/pager1.test
|
| @@ -529,6 +529,7 @@ set pwd [get_pwd]
|
| testvfs tv -default 1
|
| tv script copy_on_mj_delete
|
| set ::mj_filename_length 0
|
| +set ::mj_delete_cnt 0
|
| proc copy_on_mj_delete {method filename args} {
|
| if {[string match *mj* [file tail $filename]]} {
|
| #
|
| @@ -542,6 +543,7 @@ proc copy_on_mj_delete {method filename args} {
|
| set ::mj_filename_length [string length $filename]
|
| }
|
| faultsim_save
|
| + incr ::mj_delete_cnt
|
| }
|
| return SQLITE_OK
|
| }
|
| @@ -579,29 +581,68 @@ foreach {tn1 tcl} {
|
| }
|
| } {
|
| eval $tcl
|
| - foreach {tn2 sql} {
|
| + foreach {tn2 sql usesMJ} {
|
| o {
|
| PRAGMA main.synchronous=OFF;
|
| PRAGMA aux.synchronous=OFF;
|
| PRAGMA journal_mode = DELETE;
|
| - }
|
| + } 0
|
| o512 {
|
| PRAGMA main.synchronous=OFF;
|
| PRAGMA aux.synchronous=OFF;
|
| PRAGMA main.page_size = 512;
|
| PRAGMA aux.page_size = 512;
|
| PRAGMA journal_mode = DELETE;
|
| - }
|
| + } 0
|
| n {
|
| PRAGMA main.synchronous=NORMAL;
|
| PRAGMA aux.synchronous=NORMAL;
|
| PRAGMA journal_mode = DELETE;
|
| - }
|
| + } 1
|
| f {
|
| PRAGMA main.synchronous=FULL;
|
| PRAGMA aux.synchronous=FULL;
|
| PRAGMA journal_mode = DELETE;
|
| - }
|
| + } 1
|
| + w1 {
|
| + PRAGMA main.synchronous=NORMAL;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA journal_mode = WAL;
|
| + } 0
|
| + w2 {
|
| + PRAGMA main.synchronous=NORMAL;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA main.journal_mode=DELETE;
|
| + PRAGMA aux.journal_mode=WAL;
|
| + } 0
|
| + o1a {
|
| + PRAGMA main.synchronous=FULL;
|
| + PRAGMA aux.synchronous=OFF;
|
| + PRAGMA journal_mode=DELETE;
|
| + } 0
|
| + o1b {
|
| + PRAGMA main.synchronous=OFF;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA journal_mode=DELETE;
|
| + } 0
|
| + m1 {
|
| + PRAGMA main.synchronous=NORMAL;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA main.journal_mode=DELETE;
|
| + PRAGMA aux.journal_mode = MEMORY;
|
| + } 0
|
| + t1 {
|
| + PRAGMA main.synchronous=NORMAL;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA main.journal_mode=DELETE;
|
| + PRAGMA aux.journal_mode = TRUNCATE;
|
| + } 1
|
| + p1 {
|
| + PRAGMA main.synchronous=NORMAL;
|
| + PRAGMA aux.synchronous=NORMAL;
|
| + PRAGMA main.journal_mode=DELETE;
|
| + PRAGMA aux.journal_mode = PERSIST;
|
| + } 1
|
| } {
|
|
|
| set tn "${tn1}.${tn2}"
|
| @@ -613,6 +654,7 @@ foreach {tn1 tcl} {
|
| #
|
| tv filter xDelete
|
| do_test pager1-4.4.$tn.1 {
|
| + set ::mj_delete_cnt 0
|
| faultsim_delete_and_reopen $prefix
|
| execsql "
|
| ATTACH '${prefix}2' AS aux;
|
| @@ -634,6 +676,13 @@ foreach {tn1 tcl} {
|
| }
|
| } {}
|
| tv filter {}
|
| +
|
| + # Verify that a master journal was deleted only for those cases where
|
| + # master journals really ought to be used
|
| + #
|
| + do_test pager1-4.4.$tn.1b {
|
| + set ::mj_delete_cnt
|
| + } $usesMJ
|
|
|
| # Check that the transaction was committed successfully.
|
| #
|
| @@ -644,25 +693,33 @@ foreach {tn1 tcl} {
|
| SELECT * FROM b
|
| } {won too free double-you why zed}
|
|
|
| - # Restore the file-system and reopen the databases. Check that it now
|
| - # appears that the transaction was not committed (because the file-system
|
| - # was restored to the state where it had not been).
|
| - #
|
| - do_test pager1-4.4.$tn.4 {
|
| - faultsim_restore_and_reopen $prefix
|
| - execsql "ATTACH '${prefix}2' AS aux"
|
| - } {}
|
| - do_execsql_test pager1-4.4.$tn.5 {SELECT * FROM a} {double-you why zed}
|
| - do_execsql_test pager1-4.4.$tn.6 {SELECT * FROM b} {won too free}
|
| + if {$usesMJ} {
|
| + # Restore the file-system and reopen the databases. Check that it now
|
| + # appears that the transaction was not committed (because the file-system
|
| + # was restored to the state where it had not been).
|
| + #
|
| + do_test pager1-4.4.$tn.4 {
|
| + faultsim_restore_and_reopen $prefix
|
| + execsql "ATTACH '${prefix}2' AS aux"
|
| + } {}
|
| + do_execsql_test pager1-4.4.$tn.5 {SELECT * FROM a} {double-you why zed}
|
| + do_execsql_test pager1-4.4.$tn.6 {SELECT * FROM b} {won too free}
|
| + }
|
|
|
| # Restore the file-system again. This time, before reopening the databases,
|
| # delete the master-journal file from the file-system. It now appears that
|
| # the transaction was committed (no master-journal file == no rollback).
|
| #
|
| do_test pager1-4.4.$tn.7 {
|
| - faultsim_restore_and_reopen $prefix
|
| - foreach f [glob ${prefix}-mj*] { forcedelete $f }
|
| + if {$::mj_delete_cnt>0} {
|
| + faultsim_restore_and_reopen $prefix
|
| + foreach f [glob ${prefix}-mj*] { forcedelete $f }
|
| + } else {
|
| + db close
|
| + sqlite3 db $prefix
|
| + }
|
| execsql "ATTACH '${prefix}2' AS aux"
|
| + glob -nocomplain ${prefix}-mj*
|
| } {}
|
| do_execsql_test pager1-4.4.$tn.8 {
|
| SELECT * FROM a
|
| @@ -678,7 +735,6 @@ db close
|
| tv delete
|
| forcedelete $dirname
|
|
|
| -
|
| # Set up a VFS to make a copy of the file-system just before deleting a
|
| # journal file to commit a transaction. The transaction modifies exactly
|
| # two database pages (and page 1 - the change counter).
|
| @@ -1340,26 +1396,47 @@ do_test pager1-9.3.1 {
|
| execsql { PRAGMA page_size = 1024 }
|
| for {set ii 0} {$ii < 4} {incr ii} { execsql "CREATE TABLE t${ii}(a, b)" }
|
| } {}
|
| -do_test pager1-9.3.2 {
|
| - sqlite3 db2 test.db2
|
| -
|
| - execsql {
|
| - PRAGMA page_size = 4096;
|
| - PRAGMA synchronous = OFF;
|
| - CREATE TABLE t1(a, b);
|
| - CREATE TABLE t2(a, b);
|
| - } db2
|
| -
|
| - sqlite3_backup B db2 main db main
|
| - B step 30
|
| - list [B step 10000] [B finish]
|
| -} {SQLITE_DONE SQLITE_OK}
|
| -do_test pager1-9.3.3 {
|
| - db2 close
|
| - db close
|
| - tv delete
|
| - file size test.db2
|
| -} [file size test.db]
|
| +if {[nonzero_reserved_bytes]} {
|
| + # backup with a page size changes is not possible with the codec
|
| + #
|
| + do_test pager1-9.3.2codec {
|
| + sqlite3 db2 test.db2
|
| + execsql {
|
| + PRAGMA page_size = 4096;
|
| + PRAGMA synchronous = OFF;
|
| + CREATE TABLE t1(a, b);
|
| + CREATE TABLE t2(a, b);
|
| + } db2
|
| + sqlite3_backup B db2 main db main
|
| + B step 30
|
| + list [B step 10000] [B finish]
|
| + } {SQLITE_READONLY SQLITE_READONLY}
|
| + do_test pager1-9.3.3codec {
|
| + db2 close
|
| + db close
|
| + tv delete
|
| + file size test.db2
|
| + } [file size test.db2]
|
| +} else {
|
| + do_test pager1-9.3.2 {
|
| + sqlite3 db2 test.db2
|
| + execsql {
|
| + PRAGMA page_size = 4096;
|
| + PRAGMA synchronous = OFF;
|
| + CREATE TABLE t1(a, b);
|
| + CREATE TABLE t2(a, b);
|
| + } db2
|
| + sqlite3_backup B db2 main db main
|
| + B step 30
|
| + list [B step 10000] [B finish]
|
| + } {SQLITE_DONE SQLITE_OK}
|
| + do_test pager1-9.3.3 {
|
| + db2 close
|
| + db close
|
| + tv delete
|
| + file size test.db2
|
| + } [file size test.db]
|
| +}
|
|
|
| do_test pager1-9.4.1 {
|
| faultsim_delete_and_reopen
|
| @@ -2391,13 +2468,23 @@ do_test pager1-29.1 {
|
| }
|
| file size test.db
|
| } [expr 1024*3]
|
| -do_test pager1-29.2 {
|
| - execsql {
|
| - PRAGMA page_size = 4096;
|
| - VACUUM;
|
| - }
|
| - file size test.db
|
| -} [expr 4096*3]
|
| +if {[nonzero_reserved_bytes]} {
|
| + # VACUUM with size changes is not possible with the codec.
|
| + do_test pager1-29.2 {
|
| + catchsql {
|
| + PRAGMA page_size = 4096;
|
| + VACUUM;
|
| + }
|
| + } {1 {attempt to write a readonly database}}
|
| +} else {
|
| + do_test pager1-29.2 {
|
| + execsql {
|
| + PRAGMA page_size = 4096;
|
| + VACUUM;
|
| + }
|
| + file size test.db
|
| + } [expr 4096*3]
|
| +}
|
|
|
| #-------------------------------------------------------------------------
|
| # Test that if an empty database file (size 0 bytes) is opened in
|
|
|