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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix bestindexA
23 proc vtab_command {method args} {
26 return "CREATE TABLE x(a, b, c)"
30 set hdl [lindex $args 0]
31 set clist [$hdl constraints]
34 lappend ::vtab_constraints [list $C(op) $C(column)]
44 foreach {nArg name} $args {}
45 if {$nArg==2 && $name=="even"} {
56 register_tcl_module db
58 CREATE VIRTUAL TABLE t1 USING tcl(vtab_command);
61 proc do_xbestindex_test {tn sql res} {
64 set ::vtab_constraints
67 uplevel [list do_test $tn $script [list {*}$res]]
68 set ::vtab_constraints [list]
71 do_xbestindex_test 1.1 {
72 SELECT * FROM t1 WHERE a=?
77 do_xbestindex_test 1.2 {
78 SELECT * FROM t1 WHERE a=? LIMIT 10
84 do_xbestindex_test 1.3 {
85 SELECT * FROM t1 WHERE a=? AND (b+1)=? LIMIT 10
90 proc error_function {args} { error "not a function!" }
91 db function even error_function
93 do_xbestindex_test 1.4 {
94 SELECT * FROM t1 WHERE even(a, ?)
99 do_xbestindex_test 1.5 {
100 SELECT * FROM t1 WHERE b=10 AND even(a, ?)
106 do_xbestindex_test 1.6 {
107 SELECT * FROM t1 WHERE b=10 LIMIT 10
113 do_xbestindex_test 1.7 {
114 SELECT * FROM t1 WHERE even(b,?) LIMIT 10
120 do_xbestindex_test 1.8 {
121 SELECT * FROM t1 WHERE b!=? LIMIT 10
127 do_xbestindex_test 1.9 {
128 SELECT * FROM t1 WHERE ?=a LIMIT 10