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/rbustrict.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 / rbustrict.test` 115 lines ยท 3248 bytes Raw Blame History 1 # 2026 October 29 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 # Tests for RBU updates and RBU vacuums of STRICT tables. In particular, 13 # that values stored in columns of type ANY are not subjected to 14 # NUMERIC affinity by the imposter tables RBU uses to write to the 15 # target database. 16 # 17 18 source [file join [file dirname [info script]] rbu_common.tcl] 19 if_no_rbu_support { finish_test ; return } 20 set ::testprefix rbustrict 21 22 #------------------------------------------------------------------------- 23 # RBU vacuum. 24 # 25 foreach {tn bIndex} {1 0 2 1} { 26 reset_db 27 do_execsql_test 1.$tn.0 { 28 CREATE TABLE t1(id INTEGER PRIMARY KEY, v ANY) STRICT; 29 INSERT INTO t1 VALUES(1, '01'), (2, '1.0'), (3, '-0'), (4, ' 7'); 30 INSERT INTO t1 VALUES(5, '1e5'), (6, 'abc'), (7, '`9223372036854775808`'); 31 INSERT INTO t1 VALUES(8, 8), (9, NULL); 32 33 CREATE TABLE w1(k ANY PRIMARY KEY, n INT) STRICT, WITHOUT ROWID; 34 INSERT INTO w1 VALUES('007', 1), (8, 2), ('8', 3); 35 } 36 if {$bIndex} { 37 do_execsql_test 1.$tn.0.1 { 38 CREATE INDEX i1 ON t1(v); 39 CREATE INDEX w1n ON w1(n, k); 40 } 41 } 42 43 set t1_res { 44 1 text '01' 2 text '1.0' 3 text '-0' 4 text {' 7'} 45 5 text '1e5' 6 text 'abc' 7 text '`9223372036854775808`' 46 8 integer 8 9 null NULL 47 } 48 set w1_res { 49 integer 8 2 text '007' 1 text '8' 3 50 } 51 52 do_rbu_vacuum_test 1.$tn.1 1 53 54 do_execsql_test 1.$tn.2 { 55 SELECT id, typeof(v), quote(v) FROM t1 ORDER BY id; 56 } $t1_res 57 do_execsql_test 1.$tn.3 { 58 SELECT typeof(k), quote(k), n FROM w1 ORDER BY k; 59 } $w1_res 60 do_execsql_test 1.$tn.4 { 61 SELECT id FROM t1 WHERE v='01'; 62 SELECT n FROM w1 WHERE k='007'; 63 } {1 1} 64 } 65 66 #------------------------------------------------------------------------- 67 # RBU update. 68 # 69 reset_db 70 do_execsql_test 2.0 { 71 CREATE TABLE t1(id INTEGER PRIMARY KEY, v ANY) STRICT; 72 CREATE INDEX i1 ON t1(v); 73 INSERT INTO t1 VALUES(6, 'abc'), (7, NULL); 74 75 CREATE TABLE w1(k ANY PRIMARY KEY, n INT) STRICT, WITHOUT ROWID; 76 CREATE INDEX w1n ON w1(n, k); 77 INSERT INTO w1 VALUES('xyz', 1); 78 } 79 80 do_test 2.1 { 81 forcedelete rbu.db 82 sqlite3 rbu rbu.db 83 rbu eval { 84 CREATE TABLE data_t1(id, v, rbu_control); 85 INSERT INTO data_t1 VALUES(10, '0042', 0); 86 INSERT INTO data_t1 VALUES(11, '5.50', 0); 87 INSERT INTO data_t1 VALUES(12, NULL, 0); 88 INSERT INTO data_t1 VALUES(6, '007', '.x'); 89 90 CREATE TABLE data_w1(k, n, rbu_control); 91 INSERT INTO data_w1 VALUES('007', 2, 0); 92 INSERT INTO data_w1 VALUES(8, 3, 0); 93 INSERT INTO data_w1 VALUES('xyz', 4, '.x'); 94 } 95 rbu close 96 step_rbu test.db rbu.db 97 } {SQLITE_DONE} 98 99 do_execsql_test 2.2 { 100 SELECT id, typeof(v), quote(v) FROM t1 ORDER BY id; 101 } { 102 6 text '007' 7 null NULL 10 text '0042' 11 text '5.50' 12 null NULL 103 } 104 do_execsql_test 2.3 { 105 SELECT typeof(k), quote(k), n FROM w1 ORDER BY k; 106 } { 107 integer 8 3 text '007' 2 text 'xyz' 4 108 } 109 do_execsql_test 2.4 { 110 SELECT id FROM t1 WHERE v='0042'; 111 SELECT n FROM w1 WHERE k='007'; 112 PRAGMA integrity_check; 113 } {10 2 ok} 114 115 finish_test