sqlite/test/whereK.test

64 lines
1.8 KiB
Plaintext

# 2015-03-19
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix whereK
do_execsql_test 1.0 {
CREATE TABLE t1(v, w TEXT, x, PRIMARY KEY(w, x)) WITHOUT ROWID;
INSERT INTO t1 VALUES('a', 1, 1);
INSERT INTO t1 VALUES('B', 2, 2);
INSERT INTO t1 VALUES('C', 3, 3);
INSERT INTO t1 VALUES('d', 4, 4);
CREATE TABLE t2(v, w TEXT, x, PRIMARY KEY(w, x));
CREATE TABLE t3(a, b, c);
CREATE UNIQUE INDEX t3a ON t3(a);
}
do_eqp_test 1.1.1 {
SELECT v FROM t1 WHERE w IS ? AND x IS ?
} {/SEARCH TABLE t1.*(w=. AND x=.)/}
do_eqp_test 1.1.2 {
SELECT v FROM t2 WHERE w IS ? AND x IS ?
} {/SCAN TABLE t2/}
do_execsql_test 1.2.1 { SELECT v FROM t1 WHERE w IS 1 AND x IS 1 } {a}
do_execsql_test 1.2.2 { SELECT v FROM t1 WHERE w IS '2' AND x IS 2 } {B}
do_execsql_test 1.2.3 { SELECT v FROM t1 WHERE w IS 3 AND x IS '3' } {}
do_execsql_test 1.2.4 { SELECT v FROM t1 WHERE w IS '4' AND x IS '4' } {}
# IS constraints may only be used if all fields of the index are
# constrained by either "IS" or "=".
#
do_eqp_test 1.3.1 {
SELECT v FROM t1 WHERE w IS ?
} {/SCAN TABLE t1/}
do_eqp_test 1.3.2 {
SELECT v FROM t1 WHERE w IS ? AND x > ?
} {/SCAN TABLE t1/}
do_execsql_test 1.4.1 { SELECT v FROM t1 WHERE w IS 3 AND x = 3 } {C}
do_execsql_test 1.4.2 { SELECT v FROM t1 WHERE w = '4' AND x IS 4 } {d}
do_eqp_test 1.5.1 { SELECT b FROM t3 WHERE a IS ? } {/SCAN TABLE/}
do_eqp_test 1.5.2 { SELECT b FROM t3 WHERE a = ? } {/SEARCH TABLE/}
finish_test