Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/rbu/rbucorrupt.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / rbu / rbucorrupt.test` 100 lines ยท 2256 bytes Raw Blame History 1 # 2026 July 6 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 rbucorrupt 16 17 catch {db close} 18 sqlite3_shutdown 19 sqlite3_config_lookaside 0 0 20 sqlite3_initialize 21 autoinstall_test_functions 22 reset_db 23 24 forcedelete rbu.db 25 forcedelete state.db 26 27 do_execsql_test 1.0 { 28 CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b); 29 WITH s(i) AS ( 30 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<63 31 ) 32 INSERT INTO t1 SELECT i, i*10, 'row'||i FROM s; 33 } 34 35 sqlite3 db rbu.db 36 do_execsql_test 1.1 { 37 CREATE TABLE data_t1(id INTEGER PRIMARY KEY, a, b, rbu_control); 38 WITH s(i) AS ( 39 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<63 40 ) 41 INSERT INTO data_t1 SELECT i, i*100, NULL, '.x.' FROM s; 42 } 43 44 db close 45 46 do_test 1.2 { 47 sqlite3rbu rbu test.db rbu.db state.db 48 while {[rbu step]=="SQLITE_OK"} { 49 set st [rbu state] 50 if {$st=="checkpoint"} break 51 } 52 rbu close 53 } {SQLITE_OK} 54 55 do_test 1.3 { 56 sqlite3 db state.db 57 db eval { UPDATE rbu_state SET v=-1 WHERE k=4 } 58 db close 59 } {} 60 61 do_test 1.4 { 62 sqlite3rbu rbu test.db rbu.db state.db 63 rbu step 64 list [catch { rbu close } msg] $msg 65 } {1 SQLITE_CORRUPT} 66 67 #------------------------------------------------------------------------- 68 reset_db 69 forcedelete rbu.db 70 forcedelete state.db 71 72 do_test 2.0 { 73 for {set ii 0} {$ii<200} {incr ii} { 74 lappend cols "c$ii" 75 } 76 execsql " 77 CREATE TABLE t1(a INTEGER PRIMARY KEY, [join $cols ,]); 78 INSERT INTO t1(a, c0) VALUES(10, 100); 79 " 80 } {} 81 82 db close 83 sqlite3 db rbu.db 84 do_test 2.1 { 85 execsql " 86 CREATE TABLE data_t1(a INTEGER PRIMARY KEY, [join $cols ,], rbu_control); 87 INSERT INTO data_t1(a, c0, rbu_control) VALUES(10, 100, 'x'); 88 " 89 db close 90 } {} 91 92 breakpoint 93 do_test 2.2 { 94 sqlite3rbu rbu test.db rbu.db 95 while {[rbu step]=="SQLITE_OK"} {} 96 list [catch { rbu close } msg] $msg 97 } {1 {SQLITE_ERROR - invalid rbu_control value}} 98 99 100 finish_test