drh | 253cea5 | 2011-07-26 16:23:25 +0000 | [diff] [blame] | 1 | # 2011 July 26 |
| 2 | # |
| 3 | # The author disclaims copyright to this source code. In place of |
| 4 | # a legal notice, here is a blessing: |
| 5 | # |
| 6 | # May you do good and not evil. |
| 7 | # May you find forgiveness for yourself and forgive others. |
| 8 | # May you share freely, never taking more than you give. |
| 9 | # |
| 10 | #*********************************************************************** |
| 11 | # |
| 12 | # This file contains tests for using WAL with persistent WAL file mode. |
| 13 | # |
| 14 | |
| 15 | set testdir [file dirname $argv0] |
| 16 | source $testdir/tester.tcl |
| 17 | source $testdir/lock_common.tcl |
| 18 | set ::testprefix walpersist |
| 19 | |
| 20 | do_test walpersist-1.0 { |
| 21 | db eval { |
| 22 | PRAGMA journal_mode=WAL; |
| 23 | CREATE TABLE t1(a); |
| 24 | INSERT INTO t1 VALUES(randomblob(5000)); |
| 25 | } |
| 26 | file exists test.db-wal |
| 27 | } {1} |
| 28 | do_test walpersist-1.1 { |
| 29 | file exists test.db-shm |
| 30 | } {1} |
| 31 | do_test walpersist-1.2 { |
| 32 | db close |
| 33 | list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm] |
| 34 | } {1 0 0} |
| 35 | do_test walpersist-1.3 { |
| 36 | sqlite3 db test.db |
| 37 | db eval {SELECT length(a) FROM t1} |
| 38 | } {5000} |
| 39 | do_test walpersist-1.4 { |
| 40 | list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm] |
| 41 | } {1 1 1} |
| 42 | do_test walpersist-1.5 { |
| 43 | file_control_persist_wal db -1 |
| 44 | } {0 0} |
| 45 | do_test walpersist-1.6 { |
| 46 | file_control_persist_wal db 1 |
| 47 | } {0 1} |
| 48 | do_test walpersist-1.7 { |
| 49 | file_control_persist_wal db -1 |
| 50 | } {0 1} |
| 51 | do_test walpersist-1.8 { |
| 52 | file_control_persist_wal db 0 |
| 53 | } {0 0} |
| 54 | do_test walpersist-1.9 { |
| 55 | file_control_persist_wal db -1 |
| 56 | } {0 0} |
| 57 | do_test walpersist-1.10 { |
| 58 | file_control_persist_wal db 1 |
| 59 | } {0 1} |
| 60 | do_test walpersist-1.11 { |
| 61 | db close |
| 62 | list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm] |
| 63 | } {1 1 1} |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | finish_test |