sqlite/test/misc4.test
drh 234c39dff7 Progress towards getting prepared statements and CREATE and DROP to play
nicely together.  Work is incomplete.  Some tests are known to fail. (CVS 1864)

FossilOrigin-Name: 49b991492496e104f5eca620a5d465a742b7ff3a
2004-07-24 03:30:47 +00:00

83 lines
2.0 KiB
Plaintext

# 2004 Jun 27
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc4.test,v 1.4 2004/07/24 03:30:49 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Prepare a statement that will create a temporary table. Then do
# a rollback. Then try to execute the prepared statement.
#
do_test misc4-1.1 {
db close
set DB [sqlite3 db test.db]
execsql {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES(1);
}
set sql {CREATE TEMP TABLE t2 AS SELECT * FROM t1}
set stmt [sqlite3_prepare $DB $sql -1 TAIL]
execsql {
BEGIN;
CREATE TABLE t3(a,b,c);
INSERT INTO t1 SELECT * FROM t1;
ROLLBACK;
}
sqlite3_step $stmt
execsql {
SELECT * FROM temp.t2;
}
} {1}
# Drop the temporary table, then rerun the prepared statement to
# recreate it again. This recreates ticket #807.
#
do_test misc4-1.2 {
execsql {DROP TABLE t2}
sqlite3_reset $stmt
sqlite3_step $stmt
} {SQLITE_ERROR}
do_test misc4-1.3 {
sqlite3_finalize $stmt
} {SQLITE_SCHEMA}
# Prepare but do not execute various CREATE statements. Then before
# those statements are executed, try to use the tables, indices, views,
# are triggers that were created.
#
if 0 {
do_test misc4-2.1 {
set stmt [sqlite3_prepare $DB {CREATE TABLE t3(x);} -1 TAIL]
catchsql {
pragma vdbe_trace=on;
INSERT INTO t3 VALUES(1);
}
} {1 {no such table: t3}}
do_test misc4-2.2 {
sqlite3_step $stmt
} SQLITE_DONE
do_test misc4-2.3 {
sqlite3_finalize $stmt
} SQLITE_OK
do_test misc4-2.4 {
catchsql {
INSERT INTO t3 VALUES(1);
}
} {0 {}}
}
finish_test