3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the LIKE and GLOB operators and
13 # in particular the optimizations that occur to help those operators
16 # $Id: like.test,v 1.13 2009/06/07 23:45:11 drh Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 # Create some sample data to work with.
25 CREATE TABLE t1(x TEXT);
43 db eval {INSERT INTO t1 VALUES(:str)}
46 SELECT count(*) FROM t1;
50 # Test that both case sensitive and insensitive version of LIKE work.
54 SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
59 SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;
64 SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;
69 SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;
73 # Use sqlite3_exec() to verify fix for ticket [25ee81271091] 2011-06-26
74 sqlite3_exec db {PRAGMA case_sensitive_like=on}
78 SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
83 PRAGMA case_sensitive_like; -- no argument; does not change setting
84 SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
89 SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;
94 SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;
99 SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;
104 PRAGMA case_sensitive_like=off;
105 SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
110 PRAGMA case_sensitive_like; -- No argument, does not change setting.
111 SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;
115 # Tests of the REGEXP operator
118 proc test_regexp {a b} {
119 return [regexp $a $b]
121 db function regexp -argcount 2 test_regexp
123 SELECT x FROM t1 WHERE x REGEXP 'abc' ORDER BY 1;
125 } {{ABC abc xyz} abc abcd}
128 SELECT x FROM t1 WHERE x REGEXP '^abc' ORDER BY 1;
132 # Tests of the MATCH operator
135 proc test_match {a b} {
136 return [string match $a $b]
138 db function match -argcount 2 test_match
140 SELECT x FROM t1 WHERE x MATCH '*abc*' ORDER BY 1;
142 } {{ABC abc xyz} abc abcd}
145 SELECT x FROM t1 WHERE x MATCH 'abc*' ORDER BY 1;
149 # For the remaining tests, we need to have the like optimizations
152 ifcapable !like_opt {
157 # This procedure executes the SQL. Then it appends to the result the
158 # "sort" or "nosort" keyword (as in the cksort procedure above) then
159 # it appends the names of the table and index used.
161 proc queryplan {sql} {
162 set ::sqlite_sort_count 0
163 set data [execsql $sql]
164 if {$::sqlite_sort_count} {set x sort} {set x nosort}
166 set eqp [execsql "EXPLAIN QUERY PLAN $sql"]
168 foreach {a b c x} $eqp {
169 if {[regexp { TABLE (\w+ AS )?(\w+) USING COVERING INDEX (\w+)\y} \
170 $x all as tab idx]} {
172 } elseif {[regexp { TABLE (\w+ AS )?(\w+) USING.* INDEX (\w+)\y} \
173 $x all as tab idx]} {
174 lappend data $tab $idx
175 } elseif {[regexp { TABLE (\w+ AS )?(\w+)\y} $x all as tab]} {
182 # Perform tests on the like optimization.
184 # With no index on t1.x and with case sensitivity turned off, no optimization
188 set sqlite_like_count 0
190 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
192 } {ABC {ABC abc xyz} abc abcd sort t1 *}
194 set sqlite_like_count
197 # With an index on t1.x and case sensitivity on, optimize completely.
200 set sqlite_like_count 0
202 PRAGMA case_sensitive_like=on;
203 CREATE INDEX i1 ON t1(x);
206 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
208 } {abc abcd nosort {} i1}
210 set sqlite_like_count
213 # The LIKE optimization still works when the RHS is a string with no
214 # wildcard. Ticket [e090183531fc2747]
218 SELECT x FROM t1 WHERE x LIKE 'a' ORDER BY 1;
223 SELECT x FROM t1 WHERE x LIKE 'ab' ORDER BY 1;
228 SELECT x FROM t1 WHERE x LIKE 'abcd' ORDER BY 1;
230 } {abcd nosort {} i1}
233 SELECT x FROM t1 WHERE x LIKE 'abcde' ORDER BY 1;
238 # Partial optimization when the pattern does not end in '%'
241 set sqlite_like_count 0
243 SELECT x FROM t1 WHERE x LIKE 'a_c' ORDER BY 1;
247 set sqlite_like_count
250 set sqlite_like_count 0
252 SELECT x FROM t1 WHERE x LIKE 'ab%d' ORDER BY 1;
254 } {abcd abd nosort {} i1}
256 set sqlite_like_count
259 set sqlite_like_count 0
261 SELECT x FROM t1 WHERE x LIKE 'a_c%' ORDER BY 1;
263 } {abc abcd nosort {} i1}
265 set sqlite_like_count
268 # No optimization when the pattern begins with a wildcard.
269 # Note that the index is still used but only for sorting.
272 set sqlite_like_count 0
274 SELECT x FROM t1 WHERE x LIKE '%bcd' ORDER BY 1;
276 } {abcd bcd nosort {} i1}
278 set sqlite_like_count
281 # No optimization for case insensitive LIKE
284 set sqlite_like_count 0
285 db eval {PRAGMA case_sensitive_like=off;}
287 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
289 } {ABC {ABC abc xyz} abc abcd nosort {} i1}
291 set sqlite_like_count
294 # No optimization without an index.
297 set sqlite_like_count 0
299 PRAGMA case_sensitive_like=on;
303 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;
305 } {abc abcd sort t1 *}
307 set sqlite_like_count
310 # No GLOB optimization without an index.
313 set sqlite_like_count 0
315 SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
317 } {abc abcd sort t1 *}
319 set sqlite_like_count
322 # GLOB is optimized regardless of the case_sensitive_like setting.
325 set sqlite_like_count 0
326 db eval {CREATE INDEX i1 ON t1(x);}
328 SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
330 } {abc abcd nosort {} i1}
332 set sqlite_like_count
335 set sqlite_like_count 0
336 db eval {PRAGMA case_sensitive_like=on;}
338 SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
340 } {abc abcd nosort {} i1}
342 set sqlite_like_count
345 set sqlite_like_count 0
346 db eval {PRAGMA case_sensitive_like=off;}
348 SELECT x FROM t1 WHERE x GLOB 'a[bc]d' ORDER BY 1;
350 } {abd acd nosort {} i1}
352 set sqlite_like_count
355 # GLOB optimization when there is no wildcard. Ticket [e090183531fc2747]
359 SELECT x FROM t1 WHERE x GLOB 'a' ORDER BY 1;
364 SELECT x FROM t1 WHERE x GLOB 'abcd' ORDER BY 1;
366 } {abcd nosort {} i1}
369 SELECT x FROM t1 WHERE x GLOB 'abcde' ORDER BY 1;
375 # No optimization if the LHS of the LIKE is not a column name or
376 # if the RHS is not a string.
379 execsql {PRAGMA case_sensitive_like=on}
380 set sqlite_like_count 0
382 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1
384 } {abc abcd nosort {} i1}
386 set sqlite_like_count
389 set sqlite_like_count 0
391 SELECT x FROM t1 WHERE +x LIKE 'abc%' ORDER BY 1
393 } {abc abcd nosort {} i1}
395 set sqlite_like_count
398 set sqlite_like_count 0
400 SELECT x FROM t1 WHERE x LIKE ('ab' || 'c%') ORDER BY 1
402 } {abc abcd nosort {} i1}
404 set sqlite_like_count
407 # Collating sequences on the index disable the LIKE optimization.
408 # Or if the NOCASE collating sequence is used, the LIKE optimization
409 # is enabled when case_sensitive_like is OFF.
412 execsql {PRAGMA case_sensitive_like=off}
413 set sqlite_like_count 0
415 SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1
417 } {ABC {ABC abc xyz} abc abcd nosort {} i1}
419 set sqlite_like_count
423 CREATE TABLE t2(x TEXT COLLATE NOCASE);
424 INSERT INTO t2 SELECT * FROM t1 ORDER BY rowid;
425 CREATE INDEX i2 ON t2(x COLLATE NOCASE);
427 set sqlite_like_count 0
429 SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1
431 } {abc ABC {ABC abc xyz} abcd nosort {} i2}
433 set sqlite_like_count
437 PRAGMA case_sensitive_like=on;
439 set sqlite_like_count 0
441 SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1
443 } {abc abcd nosort {} i2}
445 set sqlite_like_count
449 PRAGMA case_sensitive_like=off;
451 set sqlite_like_count 0
453 SELECT x FROM t2 WHERE x GLOB 'abc*' ORDER BY 1
455 } {abc abcd nosort {} i2}
457 set sqlite_like_count
460 execsql {PRAGMA case_sensitive_like=off}
461 set sqlite_like_count 0
463 SELECT x FROM t1 WHERE x LIKE 'ABC%' ORDER BY 1
465 } {ABC {ABC abc xyz} abc abcd nosort {} i1}
467 set sqlite_like_count
470 set sqlite_like_count 0
472 SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1
474 } {abc ABC {ABC abc xyz} abcd nosort {} i2}
476 set sqlite_like_count
480 PRAGMA case_sensitive_like=on;
482 set sqlite_like_count 0
484 SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1
486 } {ABC {ABC abc xyz} nosort {} i2}
488 set sqlite_like_count
492 PRAGMA case_sensitive_like=off;
494 set sqlite_like_count 0
496 SELECT x FROM t2 WHERE x GLOB 'ABC*' ORDER BY 1
498 } {ABC {ABC abc xyz} nosort {} i2}
500 set sqlite_like_count
503 # Boundary case. The prefix for a LIKE comparison is rounded up
504 # when constructing the comparison. Example: "ab" becomes "ac".
505 # In other words, the last character is increased by one.
507 # Make sure this happens correctly when the last character is a
508 # "z" and we are doing case-insensitive comparisons.
514 PRAGMA case_sensitive_like=off;
515 INSERT INTO t2 VALUES('ZZ-upper-upper');
516 INSERT INTO t2 VALUES('zZ-lower-upper');
517 INSERT INTO t2 VALUES('Zz-upper-lower');
518 INSERT INTO t2 VALUES('zz-lower-lower');
521 SELECT x FROM t2 WHERE x LIKE 'zz%';
523 } {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
526 SELECT x FROM t2 WHERE x LIKE 'zZ%';
528 } {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
531 SELECT x FROM t2 WHERE x LIKE 'Zz%';
533 } {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
536 SELECT x FROM t2 WHERE x LIKE 'ZZ%';
538 } {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
541 PRAGMA case_sensitive_like=on;
542 CREATE TABLE t3(x TEXT);
543 CREATE INDEX i3 ON t3(x);
544 INSERT INTO t3 VALUES('ZZ-upper-upper');
545 INSERT INTO t3 VALUES('zZ-lower-upper');
546 INSERT INTO t3 VALUES('Zz-upper-lower');
547 INSERT INTO t3 VALUES('zz-lower-lower');
550 SELECT x FROM t3 WHERE x LIKE 'zz%';
552 } {zz-lower-lower nosort {} i3}
555 SELECT x FROM t3 WHERE x LIKE 'zZ%';
557 } {zZ-lower-upper nosort {} i3}
560 SELECT x FROM t3 WHERE x LIKE 'Zz%';
562 } {Zz-upper-lower nosort {} i3}
565 SELECT x FROM t3 WHERE x LIKE 'ZZ%';
567 } {ZZ-upper-upper nosort {} i3}
572 # Make sure the LIKE prefix optimization does not strip off leading
573 # characters of the like pattern that happen to be quote characters.
576 foreach x { 'abc 'bcd 'def 'ax } {
577 set x2 '[string map {' ''} $x]'
578 db eval "INSERT INTO t2 VALUES($x2)"
581 SELECT * FROM t2 WHERE x LIKE '''a%'
587 SELECT rowid, * FROM t1 WHERE rowid GLOB '1*' ORDER BY rowid;
589 } {1 a 10 ABC 11 CDE 12 {ABC abc xyz}}
593 # Overloading the LIKE function with -1 for the number of arguments
594 # will overload both the 2-argument and the 3-argument LIKE.
599 INSERT INTO t8 VALUES('abcdef');
600 INSERT INTO t8 VALUES('ghijkl');
601 INSERT INTO t8 VALUES('mnopqr');
602 SELECT 1, x FROM t8 WHERE x LIKE '%h%';
603 SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
605 } {1 ghijkl 2 ghijkl}
607 proc newlike {args} {return 1} ;# Alternative LIKE is always return TRUE
608 db function like newlike ;# Uses -1 for nArg in sqlite3_create_function
611 SELECT 1, x FROM t8 WHERE x LIKE '%h%';
612 SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
614 } {1 ghijkl 2 ghijkl}
616 db function like -argcount 2 newlike
618 SELECT 1, x FROM t8 WHERE x LIKE '%h%';
619 SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
621 } {1 abcdef 1 ghijkl 1 mnopqr 2 ghijkl}
623 db function like -argcount 3 newlike
625 SELECT 1, x FROM t8 WHERE x LIKE '%h%';
626 SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';
628 } {1 abcdef 1 ghijkl 1 mnopqr 2 abcdef 2 ghijkl 2 mnopqr}
631 ifcapable like_opt&&!icu {
632 # Evaluate SQL. Return the result set followed by the
633 # and the number of full-scan steps.
637 proc count_steps {sql} {
639 lappend r scan [db status step] sort [db status sort]
643 SELECT x FROM t2 WHERE x LIKE 'x%'
645 } {xyz scan 0 sort 0}
648 SELECT x FROM t2 WHERE x LIKE '_y%'
650 } {xyz scan 19 sort 0}
652 set res [sqlite3_exec_hex db {
653 SELECT x FROM t2 WHERE x LIKE '%78%25'
658 set res [sqlite3_exec_hex db {
659 EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%78%25'
661 regexp {INDEX i2} $res
665 sqlite3_exec_hex db {INSERT INTO t2 VALUES('%ffhello')}
666 set res [sqlite3_exec_hex db {
667 SELECT substr(x,2) AS x FROM t2 WHERE +x LIKE '%ff%25'
671 set res [sqlite3_exec_hex db {
672 SELECT substr(x,2) AS x FROM t2 WHERE x LIKE '%ff%25'
677 set res [sqlite3_exec_hex db {
678 EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%ff%25'
680 regexp {SCAN TABLE t2} $res
684 set res [sqlite3_exec_hex db {
685 SELECT x FROM t2 WHERE x LIKE '%fe%25'
690 set res [sqlite3_exec_hex db {
691 EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25'
693 regexp {INDEX i2} $res
697 # Do an SQL statement. Append the search count to the end of the result.
700 set ::sqlite_search_count 0
701 set ::sqlite_like_count 0
702 return [concat [execsql $sql] scan $::sqlite_search_count \
703 like $::sqlite_like_count]
706 # The LIKE and GLOB optimizations do not work on columns with
707 # affinity other than TEXT.
715 a INTEGER PRIMARY KEY,
716 b INTEGER COLLATE nocase UNIQUE,
717 c NUMBER COLLATE nocase UNIQUE,
718 d BLOB COLLATE nocase UNIQUE,
719 e COLLATE nocase UNIQUE,
720 f TEXT COLLATE nocase UNIQUE
722 INSERT INTO t10 VALUES(1,1,1,1,1,1);
723 INSERT INTO t10 VALUES(12,12,12,12,12,12);
724 INSERT INTO t10 VALUES(123,123,123,123,123,123);
725 INSERT INTO t10 VALUES(234,234,234,234,234,234);
726 INSERT INTO t10 VALUES(345,345,345,345,345,345);
727 INSERT INTO t10 VALUES(45,45,45,45,45,45);
730 SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY +a;
732 } {12 123 scan 5 like 6}
735 SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY +a;
737 } {12 123 scan 5 like 6}
740 SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY +a;
742 } {12 123 scan 5 like 6}
745 SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY +a;
747 } {12 123 scan 5 like 6}
750 SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a;
752 } {12 123 scan 3 like 0}
755 SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY +a;
757 } {12 123 scan 5 like 6}
761 a INTEGER PRIMARY KEY,
768 INSERT INTO t10b SELECT * FROM t10;
771 SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY +a;
773 } {12 123 scan 5 like 6}
776 SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY +a;
778 } {12 123 scan 5 like 6}
781 SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY +a;
783 } {12 123 scan 5 like 6}
786 SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY +a;
788 } {12 123 scan 5 like 6}
791 SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a;
793 } {12 123 scan 3 like 0}
796 SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY +a;
798 } {12 123 scan 5 like 6}
801 # LIKE and GLOB where the default collating sequence is not appropriate
802 # but an index with the appropriate collating sequence exists.
807 a INTEGER PRIMARY KEY,
808 b TEXT COLLATE nocase,
809 c TEXT COLLATE binary
811 INSERT INTO t11 VALUES(1, 'a','a');
812 INSERT INTO t11 VALUES(2, 'ab','ab');
813 INSERT INTO t11 VALUES(3, 'abc','abc');
814 INSERT INTO t11 VALUES(4, 'abcd','abcd');
815 INSERT INTO t11 VALUES(5, 'A','A');
816 INSERT INTO t11 VALUES(6, 'AB','AB');
817 INSERT INTO t11 VALUES(7, 'ABC','ABC');
818 INSERT INTO t11 VALUES(8, 'ABCD','ABCD');
819 INSERT INTO t11 VALUES(9, 'x','x');
820 INSERT INTO t11 VALUES(10, 'yz','yz');
821 INSERT INTO t11 VALUES(11, 'X','X');
822 INSERT INTO t11 VALUES(12, 'YZ','YZ');
823 SELECT count(*) FROM t11;
827 db eval {PRAGMA case_sensitive_like=OFF;}
829 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
831 } {abc abcd ABC ABCD nosort t11 *}
833 db eval {PRAGMA case_sensitive_like=ON;}
835 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
837 } {abc abcd nosort t11 *}
840 PRAGMA case_sensitive_like=OFF;
841 CREATE INDEX t11b ON t11(b);
844 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
846 } {abc abcd ABC ABCD sort {} t11b}
848 db eval {PRAGMA case_sensitive_like=ON;}
850 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;
852 } {abc abcd nosort t11 *}
855 PRAGMA case_sensitive_like=OFF;
857 CREATE INDEX t11bnc ON t11(b COLLATE nocase);
860 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
862 } {abc abcd ABC ABCD sort {} t11bnc}
864 db eval {CREATE INDEX t11bb ON t11(b COLLATE binary);}
866 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
868 } {abc abcd ABC ABCD sort {} t11bnc}
870 db eval {PRAGMA case_sensitive_like=ON;}
872 SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;
874 } {abc abcd sort {} t11bb}
876 db eval {PRAGMA case_sensitive_like=OFF;}
878 SELECT b FROM t11 WHERE b GLOB 'abc*' ORDER BY +a;
880 } {abc abcd sort {} t11bb}
883 CREATE INDEX t11cnc ON t11(c COLLATE nocase);
884 CREATE INDEX t11cb ON t11(c COLLATE binary);
887 SELECT c FROM t11 WHERE c LIKE 'abc%' ORDER BY +a;
889 } {abc abcd ABC ABCD sort {} t11cnc}
892 SELECT c FROM t11 WHERE c GLOB 'abc*' ORDER BY +a;
894 } {abc abcd sort {} t11cb}
896 # A COLLATE clause on the pattern does not change the result of a
899 do_execsql_test like-12.1 {
900 CREATE TABLE t12nc(id INTEGER, x TEXT UNIQUE COLLATE nocase);
901 INSERT INTO t12nc VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');
902 CREATE TABLE t12b(id INTEGER, x TEXT UNIQUE COLLATE binary);
903 INSERT INTO t12b VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');
904 SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;
906 do_execsql_test like-12.2 {
907 SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;
909 do_execsql_test like-12.3 {
910 SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
912 do_execsql_test like-12.4 {
913 SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
915 do_execsql_test like-12.5 {
916 SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
918 do_execsql_test like-12.6 {
919 SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
922 # Adding a COLLATE clause to the pattern of a LIKE operator does nothing
923 # to change the suitability of using an index to satisfy that LIKE
926 do_execsql_test like-12.11 {
928 SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;
930 do_execsql_test like-12.12 {
932 SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;
934 do_execsql_test like-12.13 {
936 SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
938 do_execsql_test like-12.14 {
940 SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;
942 do_execsql_test like-12.15 {
944 SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;
946 do_execsql_test like-12.16 {
948 SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;