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. Specifically,
12 # it tests the sqlite3_index_info.colUsed variable is set correctly.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
24 register_echo_module db
27 CREATE TABLE t1(a, b, c, d, e);
28 CREATE VIRTUAL TABLE e1 USING echo(t1);
31 foreach {tn query filter} {
33 {SELECT rowid, a, b, c, d, e FROM 't1'}
35 2 {SELECT a, b FROM e1}
36 {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}
38 3 {SELECT count(*) FROM e1 GROUP BY b}
39 {SELECT rowid, NULL, b, NULL, NULL, NULL FROM 't1'}
41 4 {SELECT count(*) FROM e1 GROUP BY b HAVING a=?}
42 {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}
44 5 {SELECT a FROM e1 WHERE c=?}
45 {SELECT rowid, a, NULL, c, NULL, NULL FROM 't1'}
47 6 {SELECT a FROM e1 ORDER BY e}
48 {SELECT rowid, a, NULL, NULL, NULL, e FROM 't1'}
50 7 {SELECT a FROM e1 ORDER BY e, d}
51 {SELECT rowid, a, NULL, NULL, d, e FROM 't1'}
54 set ::echo_module [list]
56 set idx [lsearch -exact $::echo_module xFilter]
57 lindex $::echo_module [expr $idx+1]
61 #-------------------------------------------------------------------------
62 # Tests with a table with more than 64 columns.
64 proc all_col_list {} {
66 for {set i 1} {$i <= 100} {incr i} { lappend L "c$i" }
70 proc part_col_list {cols} {
72 for {set i 1} {$i <= 100} {incr i} {
74 if {[lsearch $cols $c]>=0} {
83 join [part_col_list $args] ", "
87 for {set i 64} {$i <= 100} {incr i} {
90 join [part_col_list $cols] ", "
94 execsql "CREATE TABLE t2([join [all_col_list] ,])"
95 execsql "CREATE VIRTUAL TABLE e2 USING echo(t2)"
98 foreach {tn query filter} {
99 1 {SELECT c1, c10, c20 FROM e2}
100 {SELECT rowid, [CL c1 c10 c20] FROM 't2'}
102 2 {SELECT c40, c50, c60 FROM e2}
103 {SELECT rowid, [CL c40 c50 c60] FROM 't2'}
105 3 {SELECT c7, c80, c90 FROM e2}
106 {SELECT rowid, [CLT c7] FROM 't2'}
108 4 {SELECT c64 FROM e2}
109 {SELECT rowid, [CLT c64] FROM 't2'}
111 5 {SELECT c63 FROM e2}
112 {SELECT rowid, [CL c63] FROM 't2'}
114 6 {SELECT c22 FROM e2 ORDER BY c50, c70}
115 {SELECT rowid, [CLT c22 c50] FROM 't2'}
119 set ::echo_module [list]
121 set idx [lsearch -exact $::echo_module xFilter]
122 lindex $::echo_module [expr $idx+1]