Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/bestindex7.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / bestindex7.test` 82 lines ยท 2033 bytes Raw Blame History 1 # 2020-01-29 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 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 set testprefix bestindex7 16 17 ifcapable !vtab { 18 finish_test 19 return 20 } 21 22 register_tcl_module db 23 24 proc vtab_command {src method args} { 25 switch -- $method { 26 xConnect { 27 return "CREATE TABLE xxx(a)" 28 } 29 30 xBestIndex { 31 set hdl [lindex $args 0] 32 set clist [$hdl constraints] 33 set orderby [$hdl orderby] 34 set mask [$hdl mask] 35 36 set iCons 0 37 set ret [list] 38 foreach cons $clist { 39 catch { array unset C } 40 array set C $cons 41 if {$C(usable)} { 42 lappend ret use $iCons 43 } 44 incr iCons 45 } 46 return $ret 47 } 48 49 xFilter { 50 return [list sql "SELECT rowid, x FROM $src"] 51 } 52 53 } 54 55 return {} 56 } 57 58 do_execsql_test 1.0 { 59 CREATE TABLE t1(x); 60 INSERT INTO t1 VALUES(0), (2); 61 CREATE VIRTUAL TABLE vt1 USING tcl(vtab_command t1); 62 } 63 64 do_execsql_test 1.1 { select * from vt1 } {0 2} 65 do_execsql_test 1.2 { select * from vt1 WHERE a=0 } {0} 66 do_execsql_test 1.3 { select * from vt1 WHERE a=1 } {} 67 do_execsql_test 1.4 { select * from vt1 WHERE a=1 OR a=0} {0} 68 69 do_execsql_test 1.5 { 70 UPDATE t1 SET x=NULL WHERE x=2; 71 } 72 73 do_execsql_test 1.6 { select * from vt1 } {0 {}} 74 do_execsql_test 1.7 { select * from vt1 WHERE a=0 } {0} 75 do_execsql_test 1.8 { select * from vt1 WHERE a=1 } {} 76 do_execsql_test 1.9 { select * from vt1 WHERE a=1 OR a=0} {0} 77 do_execsql_test 1.10 { select * from vt1 WHERE a IN (2) } {} 78 do_execsql_test 1.10 { select * from vt1 WHERE a IN (0,1,2,3) } {0} 79 do_execsql_test 1.11 { select * from vt1 WHERE a IN (0, NULL) } {0} 80 do_execsql_test 1.12 { select * from vt1 WHERE a IN (NULL) } {} 81 82 finish_test