1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tempdb.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,55 @@
1.4 +# 2008 April 14
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 +# This file implements regression tests for SQLite library.
1.15 +# The focus of this file is in making sure that rolling back
1.16 +# a statement journal works correctly.
1.17 +#
1.18 +# $Id: tempdb.test,v 1.1 2008/04/15 00:02:00 drh Exp $
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +# Use a temporary database.
1.24 +#
1.25 +db close
1.26 +sqlite3 db {}
1.27 +
1.28 +# Force a statement journal rollback on a database file that
1.29 +# has never been opened.
1.30 +#
1.31 +do_test tempdb-1.1 {
1.32 + execsql {
1.33 + BEGIN;
1.34 + CREATE TABLE t1(x UNIQUE);
1.35 + CREATE TABLE t2(y);
1.36 + INSERT INTO t2 VALUES('hello');
1.37 + INSERT INTO t2 VALUES(NULL);
1.38 + }
1.39 + # Because of the transaction, the temporary database file
1.40 + # has not even been opened yet. The following statement
1.41 + # will cause a statement journal rollback on this non-existant
1.42 + # file.
1.43 + catchsql {
1.44 + INSERT INTO t1
1.45 + SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END
1.46 + FROM t2;
1.47 + }
1.48 +} {1 oops}
1.49 +
1.50 +# Verify that no writes occurred in t1.
1.51 +#
1.52 +do_test tempdb-1.2 {
1.53 + execsql {
1.54 + SELECT * FROM t1
1.55 + }
1.56 +} {}
1.57 +
1.58 +finish_test