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 #***********************************************************************
12 # Test cases for query planning decisions where one candidate index
13 # covers a proper superset of the WHERE clause terms of another
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 do_execsql_test whereH-1.1 {
21 CREATE TABLE t1(a,b,c,d);
22 CREATE INDEX t1abc ON t1(a,b,c);
23 CREATE INDEX t1bc ON t1(b,c);
26 SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
28 do_execsql_test whereH-1.2 {
30 SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
31 } {~/TEMP B-TREE FOR ORDER BY/}
33 do_execsql_test whereH-2.1 {
35 CREATE TABLE t1(a,b,c,d);
36 CREATE INDEX t1bc ON t1(b,c);
37 CREATE INDEX t1abc ON t1(a,b,c);
40 SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
42 do_execsql_test whereH-2.2 {
44 SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;
45 } {~/TEMP B-TREE FOR ORDER BY/}
47 do_execsql_test whereH-3.1 {
49 CREATE TABLE t1(a,b,c,d,e);
50 CREATE INDEX t1cd ON t1(c,d);
51 CREATE INDEX t1bcd ON t1(b,c,d);
52 CREATE INDEX t1abcd ON t1(a,b,c,d);
55 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
57 do_execsql_test whereH-3.2 {
59 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
60 } {~/TEMP B-TREE FOR ORDER BY/}
62 do_execsql_test whereH-4.1 {
64 CREATE TABLE t1(a,b,c,d,e);
65 CREATE INDEX t1cd ON t1(c,d);
66 CREATE INDEX t1abcd ON t1(a,b,c,d);
67 CREATE INDEX t1bcd ON t1(b,c,d);
70 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
72 do_execsql_test whereH-4.2 {
74 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
75 } {~/TEMP B-TREE FOR ORDER BY/}
77 do_execsql_test whereH-5.1 {
79 CREATE TABLE t1(a,b,c,d,e);
80 CREATE INDEX t1bcd ON t1(b,c,d);
81 CREATE INDEX t1cd ON t1(c,d);
82 CREATE INDEX t1abcd ON t1(a,b,c,d);
85 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
87 do_execsql_test whereH-5.2 {
89 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
90 } {~/TEMP B-TREE FOR ORDER BY/}
92 do_execsql_test whereH-6.1 {
94 CREATE TABLE t1(a,b,c,d,e);
95 CREATE INDEX t1bcd ON t1(b,c,d);
96 CREATE INDEX t1abcd ON t1(a,b,c,d);
97 CREATE INDEX t1cd ON t1(c,d);
100 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
102 do_execsql_test whereH-6.2 {
104 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
105 } {~/TEMP B-TREE FOR ORDER BY/}
107 do_execsql_test whereH-7.1 {
109 CREATE TABLE t1(a,b,c,d,e);
110 CREATE INDEX t1abcd ON t1(a,b,c,d);
111 CREATE INDEX t1bcd ON t1(b,c,d);
112 CREATE INDEX t1cd ON t1(c,d);
115 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
117 do_execsql_test whereH-7.2 {
119 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
120 } {~/TEMP B-TREE FOR ORDER BY/}
122 do_execsql_test whereH-8.1 {
124 CREATE TABLE t1(a,b,c,d,e);
125 CREATE INDEX t1abcd ON t1(a,b,c,d);
126 CREATE INDEX t1cd ON t1(c,d);
127 CREATE INDEX t1bcd ON t1(b,c,d);
130 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
132 do_execsql_test whereH-8.2 {
134 SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;
135 } {~/TEMP B-TREE FOR ORDER BY/}