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/test/like4.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 / test / like4.test` 251 lines ยท 6637 bytes Raw Blame History 1 # 2026-10-15 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 implements regression tests for SQLite library. 13 # 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix like4 18 19 ifcapable !like_match_blobs { 20 finish_test 21 return 22 } 23 24 do_execsql_test 1.0 { 25 CREATE TABLE t0(a, c); 26 INSERT INTO t0 VALUES(1, 'A'); 27 INSERT INTO t0 VALUES(2, 'A'); 28 INSERT INTO t0 VALUES(1, X'41'); 29 INSERT INTO t0 VALUES(2, X'41'); 30 } 31 32 foreach {tn idx} { 33 1 "" 34 2 "CREATE INDEX idx ON t0(a, c)" 35 3 "CREATE INDEX idx ON t0(c, a)" 36 } { 37 38 execsql { DROP INDEX IF EXISTS idx } 39 execsql $idx 40 41 do_execsql_test 1.$tn.1 { 42 SELECT a, count(*) FROM t0 WHERE a IN (1,2) AND c GLOB 'A' GROUP BY a; 43 } {1 2 2 2} 44 45 do_execsql_test 1.$tn.2 { 46 SELECT a, quote(c) FROM t0 WHERE a IN (1,2) AND c GLOB 'A' ORDER BY a; 47 } { 48 1 'A' 49 1 X'41' 50 2 'A' 51 2 X'41' 52 } 53 } 54 55 #------------------------------------------------------------------------- 56 reset_db 57 58 do_execsql_test 2.0 { 59 CREATE TABLE t1(a, b); 60 CREATE INDEX t1b ON t1(b); 61 62 INSERT INTO t1 VALUES(1, 'abc'); 63 INSERT INTO t1 VALUES(2, X'616263'); 64 INSERT INTO t1 VALUES(3, 'abd'); 65 INSERT INTO t1 VALUES(4, X'616264'); 66 } 67 68 do_execsql_test 2.1 { 69 SELECT a FROM t1 WHERE b GLOB 'ab*' ORDER BY b 70 } {1 3 2 4} 71 do_execsql_test 2.2 { 72 SELECT a FROM t1 WHERE b GLOB 'ab*' ORDER BY b DESC 73 } {4 2 3 1} 74 75 #------------------------------------------------------------------------- 76 reset_db 77 78 do_execsql_test 3.0 { 79 CREATE TABLE t(a, c); 80 CREATE INDEX ti ON t(a, c); 81 WITH RECURSIVE n(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM n WHERE i<100) 82 INSERT INTO t SELECT i%3, 'x'||i FROM n; 83 INSERT INTO t VALUES(2, 'A'), (1, x'41'); 84 } 85 86 do_execsql_test 3.1 { 87 SELECT a, quote(c) FROM t WHERE c GLOB 'A' ORDER BY a; 88 } { 89 1 X'41' 90 2 'A' 91 } 92 93 do_execsql_test 3.2 { 94 ANALYZE; 95 } 96 97 do_execsql_test 3.3 { 98 SELECT a, quote(c) FROM t WHERE c GLOB 'A' ORDER BY a; 99 } { 100 1 X'41' 101 2 'A' 102 } 103 104 #------------------------------------------------------------------------- 105 # Skip-scan on combined with IN(...) and the LIKE optimization. 106 # 107 reset_db 108 109 do_execsql_test 4.0 { 110 CREATE TABLE t(a, b, c); 111 CREATE INDEX ti ON t(a, b, c); 112 WITH RECURSIVE n(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM n WHERE i<300) 113 INSERT INTO t SELECT i%3, i%2, 'x'||i FROM n; 114 INSERT INTO t VALUES(2, 0, 'A'), (2, 1, x'41'); 115 INSERT INTO t VALUES(1, 1, 'A'), (1, 0, x'41'); 116 INSERT INTO t VALUES(0, 1, 'A'); 117 ANALYZE; 118 } 119 120 do_eqp_test 4.1 { 121 SELECT a, b, quote(c) FROM t WHERE b IN (0,1) AND c GLOB 'A' ORDER BY a, b; 122 } {SEARCH t USING COVERING INDEX ti (ANY(a) AND b=? AND c>? AND c? AND y