1# 2008 April 27 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# Ticket #3080 13# 14# Make sure that application-defined functions are able to recursively 15# invoke SQL statements that create and drop virtual tables. 16# 17# $Id: tkt3080.test,v 1.2 2008/11/05 16:37:35 drh Exp $ 18# 19 20set testdir [file dirname $argv0] 21source $testdir/tester.tcl 22 23do_test tkt3080.1 { 24 db function execsql execsql 25 db eval { 26 SELECT execsql('CREATE TABLE t1(x)'); 27 } 28 execsql {SELECT name FROM sqlite_master} 29} {t1} 30do_test tkt3080.2 { 31 db eval { 32 INSERT INTO t1 VALUES('CREATE TABLE t2(y);'); 33 SELECT execsql(x) FROM t1; 34 } 35 db eval { 36 SELECT name FROM sqlite_master; 37 } 38} {t1 t2} 39do_test tkt3080.3 { 40 execsql { 41 INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;'); 42 } 43 catchsql { 44 SELECT execsql(x) FROM t1 WHERE rowid=2; 45 } 46} {1 {database table is locked}} 47do_test tkt3080.4 { 48 db eval { 49 SELECT name FROM sqlite_master; 50 } 51} {t1 t2 t3} 52 53ifcapable vtab { 54 register_echo_module [sqlite3_connection_pointer db] 55 do_test tkt3080.10 { 56 set sql { 57 CREATE VIRTUAL TABLE t4 USING echo(t2); 58 INSERT INTO t4 VALUES(123); 59 DROP TABLE t4; 60 } 61 execsql { 62 DELETE FROM t1; 63 INSERT INTO t1 VALUES($sql); 64 } 65 db eval { 66 SELECT execsql(x) FROM t1 67 } 68 execsql {SELECT name FROM sqlite_master} 69 } {t1 t2 t3} 70 do_test tkt3080.11 { 71 execsql {SELECT * FROM t2} 72 } {123} 73} 74 75 76 77finish_test 78