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 #***********************************************************************
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set ::testprefix rowvaluevtab
23 register_echo_module db
26 CREATE TABLE t1(a, b, c);
27 CREATE INDEX t1b ON t1(b);
28 INSERT INTO t1 VALUES('one', 1, 1);
29 INSERT INTO t1 VALUES('two', 1, 2);
30 INSERT INTO t1 VALUES('three', 1, 3);
31 INSERT INTO t1 VALUES('four', 2, 1);
32 INSERT INTO t1 VALUES('five', 2, 2);
33 INSERT INTO t1 VALUES('six', 2, 3);
34 INSERT INTO t1 VALUES('seven', 3, 1);
35 INSERT INTO t1 VALUES('eight', 3, 2);
36 INSERT INTO t1 VALUES('nine', 3, 3);
39 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
40 ) INSERT INTO t1 SELECT NULL, NULL, NULL FROM s;
41 CREATE VIRTUAL TABLE e1 USING echo(t1);
44 proc do_vfilter4_test {tn sql expected} {
46 db eval "explain $sql" {
47 if {$opcode=="VFilter"} {
51 uplevel [list do_test $tn [list set {} $res] [list {*}$expected]]
55 SELECT a FROM e1 WHERE (b, c) = (2, 2)
57 do_vfilter4_test 1.1f {
58 SELECT a FROM e1 WHERE (b, c) = (?, ?)
59 } {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}}
62 SELECT a FROM e1 WHERE (b, c) > (2, 2)
63 } {six seven eight nine}
64 do_vfilter4_test 1.2f {
65 SELECT a FROM e1 WHERE (b, c) > (2, 2)
67 {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?}
71 SELECT a FROM e1 WHERE (b, c) >= (2, 2)
72 } {five six seven eight nine}
73 do_vfilter4_test 1.3f {
74 SELECT a FROM e1 WHERE (b, c) >= (2, 2)
76 {SELECT rowid, a, b, c FROM 't1' WHERE b >= ?}
80 SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3)
81 } {two three four five six}
82 do_vfilter4_test 1.3f {
83 SELECT a FROM e1 WHERE (b, c) BETWEEN (1, 2) AND (2, 3)
85 {SELECT rowid, a, b, c FROM 't1' WHERE b >= ? AND b <= ?}
89 SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) )
91 do_vfilter4_test 1.4f {
92 SELECT a FROM e1 WHERE (b, c) IN ( VALUES(2, 2) )
93 } {{SELECT rowid, a, b, c FROM 't1' WHERE b = ?}}