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
22 register_tcl_module db
24 proc vtab_command {method args} {
27 return $::create_table_sql
37 3 {INSERT INTO t1 VALUES(5, 6)}
38 4 {CREATE INDEX i1 ON t1(a)}
39 5 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END;}
40 6 {DROP TABLE nosuchtable}
44 set ::create_table_sql $cts
45 do_catchsql_test 1.$tn {
46 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
47 } {1 {declare_vtab: syntax error}}
51 9 {CREATE TABLE xyz AS SELECT * FROM sqlite_schema}
52 10 {CREATE TABLE xyz AS SELECT 1 AS 'col'}
54 set ::create_table_sql $cts
55 do_catchsql_test 1.$tn {
56 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
57 } {1 {declare_vtab: SQL logic error}}
61 1 {CREATE TABLE IF NOT EXISTS t1(a, b)}
62 2 {CREATE TABLE ""(a, b PRIMARY KEY) WITHOUT ROWID}
64 set ::create_table_sql $cts
65 execsql { DROP TABLE IF EXISTS x1 }
66 do_execsql_test 2.$tn.1 {
67 CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);
69 do_execsql_test 2.$tn.2 {