1# 2016 February 19 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 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. 9# 10#*********************************************************************** 11# 12# 13 14set testdir [file dirname $argv0] 15source $testdir/tester.tcl 16set testprefix bestindex1 17 18register_tcl_module db 19 20proc vtab_command {method args} { 21 switch -- $method { 22 xConnect { 23 return "CREATE TABLE t1(a, b, c)" 24 } 25 26 xBestIndex { 27 set clist [lindex $args 0] 28 if {[llength $clist]!=1} { error "unexpected constraint list" } 29 catch { array unset C } 30 array set C [lindex $clist 0] 31 if {$C(usable)} { 32 return "use 0 cost 0 rows 1 idxnum 555 idxstr eq!" 33 } else { 34 return "cost 1000000 rows 0 idxnum 0 idxstr scan..." 35 } 36 } 37 38 } 39 40 return {} 41} 42 43do_execsql_test 1.0 { 44 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command); 45} {} 46 47do_eqp_test 1.1 { 48 SELECT * FROM x1 WHERE a = 'abc' 49} { 50 0 0 0 {SCAN TABLE x1 VIRTUAL TABLE INDEX 555:eq!} 51} 52 53#set sqlite_where_trace 0x3ff 54do_eqp_test 1.2 { 55 SELECT * FROM x1 WHERE a IN ('abc', 'def'); 56} { 57 0 0 0 {SCAN TABLE x1 VIRTUAL TABLE INDEX 555:eq!} 58} 59 60finish_test 61 62