sl@0: # 2008 April 27 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # Ticket #3080 sl@0: # sl@0: # Make sure that application-defined functions are able to recursively sl@0: # invoke SQL statements that create and drop virtual tables. sl@0: # sl@0: # $Id: tkt3080.test,v 1.1 2008/04/28 17:12:11 drh Exp $ sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test tkt3080.1 { sl@0: db function execsql execsql sl@0: db eval { sl@0: SELECT execsql('CREATE TABLE t1(x)'); sl@0: } sl@0: execsql {SELECT name FROM sqlite_master} sl@0: } {t1} sl@0: do_test tkt3080.2 { sl@0: db eval { sl@0: INSERT INTO t1 VALUES('CREATE TABLE t2(y);'); sl@0: SELECT execsql(x) FROM t1; sl@0: } sl@0: db eval { sl@0: SELECT name FROM sqlite_master; sl@0: } sl@0: } {t1 t2} sl@0: do_test tkt3080.3 { sl@0: execsql { sl@0: INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;'); sl@0: } sl@0: catchsql { sl@0: SELECT execsql(x) FROM t1 WHERE rowid=2; sl@0: } sl@0: } {1 {database table is locked}} sl@0: do_test tkt3080.4 { sl@0: db eval { sl@0: SELECT name FROM sqlite_master; sl@0: } sl@0: } {t1 t2} sl@0: sl@0: ifcapable vtab { sl@0: register_echo_module [sqlite3_connection_pointer db] sl@0: do_test tkt3080.10 { sl@0: set sql { sl@0: CREATE VIRTUAL TABLE t4 USING echo(t2); sl@0: INSERT INTO t4 VALUES(123); sl@0: DROP TABLE t4; sl@0: } sl@0: execsql { sl@0: DELETE FROM t1; sl@0: INSERT INTO t1 VALUES($sql); sl@0: } sl@0: db eval { sl@0: SELECT execsql(x) FROM t1 sl@0: } sl@0: execsql {SELECT name FROM sqlite_master} sl@0: } {t1 t2} sl@0: do_test tkt3080.11 { sl@0: execsql {SELECT * FROM t2} sl@0: } {123} sl@0: } sl@0: sl@0: sl@0: sl@0: finish_test