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/rbupartial.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 / rbupartial.test` 98 lines ยท 2690 bytes Raw Blame History 1 # 2019 April 11 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 rbupartial 16 17 db close 18 19 foreach {tn without_rowid a b c d} { 20 1 "" a b c d 21 2 "WITHOUT ROWID" aaa bbb ccc ddd 22 3 "WITHOUT ROWID" "\"hello\"" {"one'two"} {[c]} ddd 23 4 "WITHOUT ROWID" {`a b`} {"one'two"} {[c c c]} ddd 24 5 "" a b c {"d""d"} 25 6 "" {'one''two'} b {"c""c"} {"d""d"} 26 } { 27 eval [string map [list \ 28 %WITHOUT_ROWID% $without_rowid %A% $a %B% $b %C% $c %D% $d 29 ] { 30 reset_db 31 do_execsql_test $tn.1.0 { 32 CREATE TABLE t1(%A% PRIMARY KEY, %B%, %C%, %D%) %WITHOUT_ROWID% ; 33 CREATE INDEX i1b ON t1(%B%); 34 CREATE INDEX i1b2 ON t1(%B%) WHERE %C%<5; 35 CREATE INDEX i1b3 ON t1(%B%) WHERE %C%>=5; 36 37 CREATE INDEX i1c ON t1(%C%); 38 CREATE INDEX i1c2 ON t1(%C%) WHERE %C% IS NULL; 39 CREATE INDEX i1c3 ON t1(%C%) WHERE %C% IS NOT NULL; 40 41 CREATE INDEX i1c4 ON t1(%C%) WHERE %D% < 'd'; 42 CREATE INDEX i1c5 ON t1( 43 %C% -- for (c = ... expressions 44 ) WHERE %D% < 'd'; 45 CREATE INDEX i1c6 ON t1( 46 %C% /* Again, for (c=... expr */, %D% 47 ) WHERE %D% < 'd'; 48 49 CREATE INDEX i1c7 ON t1( 50 %C% /* As before, for (c=... "expr */) WHERE %D% < 'd'; 51 } 52 53 do_execsql_test $tn.1.1 { 54 INSERT INTO t1 VALUES(0, NULL, NULL, 'a'); 55 INSERT INTO t1 VALUES(1, 2, 3, 'b'); 56 INSERT INTO t1 VALUES(4, 5, 6, 'c'); 57 INSERT INTO t1 VALUES(7, 8, 9, 'd'); 58 } 59 60 forcedelete rbu.db 61 do_test $tn.1.2 { 62 sqlite3 rbu rbu.db 63 rbu eval { 64 CREATE TABLE data_t1(%A%, %B%, %C%, %D%, rbu_control); 65 66 INSERT INTO data_t1 VALUES(10, 11, 12, 'e', 0); 67 INSERT INTO data_t1 VALUES(13, 14, NULL, 'f', 0); 68 69 INSERT INTO data_t1 VALUES(0, NULL, NULL, NULL, 1); 70 INSERT INTO data_t1 VALUES(4, NULL, NULL, NULL, 1); 71 72 INSERT INTO data_t1 VALUES(7, NULL, 4, NULL, '..x.'); 73 INSERT INTO data_t1 VALUES(1, 10, NULL, NULL, '.xx.'); 74 } 75 rbu close 76 } {} 77 78 do_test $tn.1.3 { 79 run_rbu test.db rbu.db 80 execsql { PRAGMA integrity_check } 81 } {ok} 82 83 do_execsql_test $tn.1.4 { 84 SELECT * FROM t1 ORDER BY %A%; 85 } { 86 1 10 {} b 7 8 4 d 10 11 12 e 13 14 {} f 87 } 88 89 set step 0 90 do_rbu_vacuum_test $tn.1.5 0 91 92 do_test $tn.1.6 { 93 execsql { PRAGMA integrity_check } 94 } {ok} 95 }] 96 } 97 98 finish_test