1# 2004 Jun 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# This file implements regression tests for SQLite library. 12# 13# This file implements tests for miscellanous features that were 14# left out of other test files. 15# 16# $Id: misc4.test,v 1.4 2004/07/24 03:30:49 drh Exp $ 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21# Prepare a statement that will create a temporary table. Then do 22# a rollback. Then try to execute the prepared statement. 23# 24do_test misc4-1.1 { 25 db close 26 set DB [sqlite3 db test.db] 27 execsql { 28 CREATE TABLE t1(x); 29 INSERT INTO t1 VALUES(1); 30 } 31 set sql {CREATE TEMP TABLE t2 AS SELECT * FROM t1} 32 set stmt [sqlite3_prepare $DB $sql -1 TAIL] 33 execsql { 34 BEGIN; 35 CREATE TABLE t3(a,b,c); 36 INSERT INTO t1 SELECT * FROM t1; 37 ROLLBACK; 38 } 39 sqlite3_step $stmt 40 execsql { 41 SELECT * FROM temp.t2; 42 } 43} {1} 44 45# Drop the temporary table, then rerun the prepared statement to 46# recreate it again. This recreates ticket #807. 47# 48do_test misc4-1.2 { 49 execsql {DROP TABLE t2} 50 sqlite3_reset $stmt 51 sqlite3_step $stmt 52} {SQLITE_ERROR} 53do_test misc4-1.3 { 54 sqlite3_finalize $stmt 55} {SQLITE_SCHEMA} 56 57# Prepare but do not execute various CREATE statements. Then before 58# those statements are executed, try to use the tables, indices, views, 59# are triggers that were created. 60# 61if 0 { 62do_test misc4-2.1 { 63 set stmt [sqlite3_prepare $DB {CREATE TABLE t3(x);} -1 TAIL] 64 catchsql { 65pragma vdbe_trace=on; 66 INSERT INTO t3 VALUES(1); 67 } 68} {1 {no such table: t3}} 69do_test misc4-2.2 { 70 sqlite3_step $stmt 71} SQLITE_DONE 72do_test misc4-2.3 { 73 sqlite3_finalize $stmt 74} SQLITE_OK 75do_test misc4-2.4 { 76 catchsql { 77 INSERT INTO t3 VALUES(1); 78 } 79} {0 {}} 80} 81 82finish_test 83