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.5 2004/07/24 14:35:59 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} {} 32do_test misc4-1.2 { 33 set sql {CREATE TEMP TABLE t2 AS SELECT * FROM t1} 34 set stmt [sqlite3_prepare $DB $sql -1 TAIL] 35 execsql { 36 BEGIN; 37 CREATE TABLE t3(a,b,c); 38 INSERT INTO t1 SELECT * FROM t1; 39 ROLLBACK; 40 } 41} {} 42do_test misc4-1.3 { 43 sqlite3_step $stmt 44} SQLITE_DONE 45do_test misc4-1.4 { 46 execsql { 47 SELECT * FROM temp.t2; 48 } 49} {1} 50 51# Drop the temporary table, then rerun the prepared statement to 52# recreate it again. This recreates ticket #807. 53# 54do_test misc4-1.5 { 55 execsql {DROP TABLE t2} 56 sqlite3_reset $stmt 57 sqlite3_step $stmt 58} {SQLITE_ERROR} 59do_test misc4-1.6 { 60 sqlite3_finalize $stmt 61} {SQLITE_SCHEMA} 62 63# Prepare but do not execute various CREATE statements. Then before 64# those statements are executed, try to use the tables, indices, views, 65# are triggers that were created. 66# 67if 0 { 68do_test misc4-2.1 { 69 set stmt [sqlite3_prepare $DB {CREATE TABLE t3(x);} -1 TAIL] 70 catchsql { 71pragma vdbe_trace=on; 72 INSERT INTO t3 VALUES(1); 73 } 74} {1 {no such table: t3}} 75do_test misc4-2.2 { 76 sqlite3_step $stmt 77} SQLITE_DONE 78do_test misc4-2.3 { 79 sqlite3_finalize $stmt 80} SQLITE_OK 81do_test misc4-2.4 { 82 catchsql { 83 INSERT INTO t3 VALUES(1); 84 } 85} {0 {}} 86} 87 88finish_test 89