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 # The tests in this file were used while developing the SQLite 4 code.
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix tkt-385a5b56b9
18 CREATE TABLE t1(x, y);
19 INSERT INTO t1 VALUES(1, NULL);
20 INSERT INTO t1 VALUES(2, NULL);
21 INSERT INTO t1 VALUES(1, NULL);
24 do_execsql_test 1.1 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}
25 do_execsql_test 1.2 { CREATE UNIQUE INDEX i1 ON t1(x, y) }
26 do_execsql_test 1.3 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}
29 #-------------------------------------------------------------------------
32 CREATE TABLE t2(x, y NOT NULL);
33 CREATE UNIQUE INDEX t2x ON t2(x);
34 CREATE UNIQUE INDEX t2y ON t2(y);
37 do_eqp_test 2.1 { SELECT DISTINCT x FROM t2 } {
38 0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2x}
41 do_eqp_test 2.2 { SELECT DISTINCT y FROM t2 } {
42 0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2y}
45 do_eqp_test 2.3 { SELECT DISTINCT x, y FROM t2 WHERE y=10 } {
46 0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?)}
49 do_eqp_test 2.4 { SELECT DISTINCT x, y FROM t2 WHERE x=10 } {
50 0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x=?)}