1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt3080.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,77 @@
1.4 +# 2008 April 27
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +#
1.15 +# Ticket #3080
1.16 +#
1.17 +# Make sure that application-defined functions are able to recursively
1.18 +# invoke SQL statements that create and drop virtual tables.
1.19 +#
1.20 +# $Id: tkt3080.test,v 1.1 2008/04/28 17:12:11 drh Exp $
1.21 +#
1.22 +
1.23 +set testdir [file dirname $argv0]
1.24 +source $testdir/tester.tcl
1.25 +
1.26 +do_test tkt3080.1 {
1.27 + db function execsql execsql
1.28 + db eval {
1.29 + SELECT execsql('CREATE TABLE t1(x)');
1.30 + }
1.31 + execsql {SELECT name FROM sqlite_master}
1.32 +} {t1}
1.33 +do_test tkt3080.2 {
1.34 + db eval {
1.35 + INSERT INTO t1 VALUES('CREATE TABLE t2(y);');
1.36 + SELECT execsql(x) FROM t1;
1.37 + }
1.38 + db eval {
1.39 + SELECT name FROM sqlite_master;
1.40 + }
1.41 +} {t1 t2}
1.42 +do_test tkt3080.3 {
1.43 + execsql {
1.44 + INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;');
1.45 + }
1.46 + catchsql {
1.47 + SELECT execsql(x) FROM t1 WHERE rowid=2;
1.48 + }
1.49 +} {1 {database table is locked}}
1.50 +do_test tkt3080.4 {
1.51 + db eval {
1.52 + SELECT name FROM sqlite_master;
1.53 + }
1.54 +} {t1 t2}
1.55 +
1.56 +ifcapable vtab {
1.57 + register_echo_module [sqlite3_connection_pointer db]
1.58 + do_test tkt3080.10 {
1.59 + set sql {
1.60 + CREATE VIRTUAL TABLE t4 USING echo(t2);
1.61 + INSERT INTO t4 VALUES(123);
1.62 + DROP TABLE t4;
1.63 + }
1.64 + execsql {
1.65 + DELETE FROM t1;
1.66 + INSERT INTO t1 VALUES($sql);
1.67 + }
1.68 + db eval {
1.69 + SELECT execsql(x) FROM t1
1.70 + }
1.71 + execsql {SELECT name FROM sqlite_master}
1.72 + } {t1 t2}
1.73 + do_test tkt3080.11 {
1.74 + execsql {SELECT * FROM t2}
1.75 + } {123}
1.76 +}
1.77 +
1.78 +
1.79 +
1.80 +finish_test