sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / rbu / rbupass.test
| 1 | # 2023 January 13 |
| 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 | |
| 13 | source [file join [file dirname [info script]] rbu_common.tcl] |
| 14 | if_no_rbu_support { finish_test ; return } |
| 15 | set ::testprefix rbupass |
| 16 | |
| 17 | if {[info commands register_demovfs]==""} { |
| 18 | finish_test |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | db close |
| 23 | |
| 24 | register_demovfs |
| 25 | sqlite3rbu_create_vfs myvfs demo |
| 26 | |
| 27 | sqlite3 db file:test.db?vfs=myvfs -uri 1 |
| 28 | do_execsql_test 1.0 { |
| 29 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b); |
| 30 | INSERT INTO t1 VALUES(1, 2); |
| 31 | SELECT * FROM t1; |
| 32 | } {1 2} |
| 33 | |
| 34 | if {[permutation]!="inmemory_journal"} { |
| 35 | do_execsql_test 1.1 { |
| 36 | PRAGMA journal_mode = wal; |
| 37 | } {delete} |
| 38 | } |
| 39 | |
| 40 | do_execsql_test 1.2 { |
| 41 | SELECT * FROM t1; |
| 42 | } {1 2} |
| 43 | |
| 44 | do_test 1.3 { |
| 45 | forcedelete rbu.db |
| 46 | sqlite3 rbu rbu.db |
| 47 | rbu eval { |
| 48 | CREATE TABLE data_t1(a, b, rbu_control); |
| 49 | INSERT INTO data_t1 VALUES(2, 4, 0); |
| 50 | } |
| 51 | rbu close |
| 52 | } {} |
| 53 | |
| 54 | do_test 1.4 { |
| 55 | sqlite3rbu rbu test.db rbu.db |
| 56 | } {rbu} |
| 57 | do_test 1.5 { |
| 58 | rbu step |
| 59 | } {SQLITE_CANTOPEN} |
| 60 | do_test 1.6 { |
| 61 | list [catch { rbu close } msg] $msg |
| 62 | } {1 {SQLITE_CANTOPEN - unable to open database file}} |
| 63 | |
| 64 | do_test 1.7 { |
| 65 | sqlite3rbu_vacuum rbu test.db |
| 66 | } {rbu} |
| 67 | do_test 1.8 { |
| 68 | rbu step |
| 69 | catch { rbu close } |
| 70 | } {1} |
| 71 | |
| 72 | do_execsql_test 1.9 { |
| 73 | SELECT * FROM t1; |
| 74 | } {1 2} |
| 75 | |
| 76 | db close |
| 77 | sqlite3rbu_destroy_vfs myvfs |
| 78 | unregister_demovfs |
| 79 | sqlite3_shutdown |
| 80 | finish_test |
| 81 |