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 bestindexB
23 register_tcl_module db
25 proc vtab_command {method args} {
28 return "CREATE TABLE t1(a, b, c)"
32 set hdl [lindex $args 0]
33 set clist [$hdl constraints]
34 set orderby [$hdl orderby]
36 if {[info exists ::xbestindex_sql]} {
37 explain_i $::xbestindex_sql
38 set ::xbestindex_res [ execsql $::xbestindex_sql ]
41 return "cost 1000000 rows 1000000 idxnum 0 idxstr hello"
45 return "sql {SELECT 0, 1, 2, 3}"
53 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
54 CREATE TABLE y1(a, b);
55 CREATE TABLE y2(a, b);
63 INSERT INTO y1 VALUES(1, 2) RETURNING rowid;
67 CREATE TRIGGER y1tr BEFORE INSERT ON y1 BEGIN
70 INSERT INTO y1 VALUES(3, 4) RETURNING rowid;
74 # This time, rig the xBestIndex() method of the vtab to invoke an SQL
75 # statement that uses RETURNING.
76 set ::xbestindex_sql {
77 INSERT INTO y2 VALUES(NULL, NULL) RETURNING rowid;
80 INSERT INTO y1 VALUES(5, 6) RETURNING rowid;