1# 2014 August 30 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 the RBU module. More specifically, it 13# contains tests to ensure that it is an error to attempt to update 14# a wal mode database via RBU. 15# 16 17if {![info exists testdir]} { 18 set testdir [file join [file dirname [info script]] .. .. test] 19} 20source $testdir/tester.tcl 21set ::testprefix rbuA 22 23set db_sql { 24 CREATE TABLE t1(a PRIMARY KEY, b, c); 25} 26set rbu_sql { 27 CREATE TABLE data_t1(a, b, c, rbu_control); 28 INSERT INTO data_t1 VALUES(1, 2, 3, 0); 29 INSERT INTO data_t1 VALUES(4, 5, 6, 0); 30 INSERT INTO data_t1 VALUES(7, 8, 9, 0); 31} 32 33do_test 1.0 { 34 db close 35 forcedelete test.db rbu.db 36 37 sqlite3 db test.db 38 db eval $db_sql 39 db eval { PRAGMA journal_mode = wal } 40 db close 41 42 sqlite3 db rbu.db 43 db eval $rbu_sql 44 db close 45 46 sqlite3rbu rbu test.db rbu.db 47 rbu step 48} {SQLITE_ERROR} 49do_test 1.1 { 50 list [catch { rbu close } msg] $msg 51} {1 {SQLITE_ERROR - cannot update wal mode database}} 52 53do_test 2.0 { 54 forcedelete test.db rbu.db 55 56 sqlite3 db test.db 57 db eval $db_sql 58 db close 59 60 sqlite3 db rbu.db 61 db eval $rbu_sql 62 db close 63 64 sqlite3rbu rbu test.db rbu.db 65 rbu step 66 rbu close 67} {SQLITE_OK} 68 69do_test 2.1 { 70 sqlite3 db test.db 71 db eval {PRAGMA journal_mode = wal} 72 db close 73 sqlite3rbu rbu test.db rbu.db 74 rbu step 75} {SQLITE_ERROR} 76 77do_test 2.2 { 78 list [catch { rbu close } msg] $msg 79} {1 {SQLITE_ERROR - cannot update wal mode database}} 80 81 82finish_test 83