Snapshot of upstream SQLite 3.8.4.3
[sqlcipher.git] / test / close.test
blobd5d6391ae5e58be31e669f29d753cc1d970004e5
1 # 2013 May 14
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # Test some specific circumstances to do with shared cache mode.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 set ::testprefix close
20 do_execsql_test 1.0 {
21   CREATE TABLE t1(x);
22   INSERT INTO t1 VALUES('one');
23   INSERT INTO t1 VALUES('two');
24   INSERT INTO t1 VALUES('three');
26 db close
28 do_test 1.1 {
29   set DB [sqlite3_open test.db]
30   sqlite3_close_v2 $DB
31 } {SQLITE_OK}
33 do_test 1.2.1 {
34   set DB [sqlite3_open test.db]
35   set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
36   sqlite3_close_v2 $DB
37 } {SQLITE_OK}
38 do_test 1.2.2 {
39   sqlite3_finalize $STMT
40 } {SQLITE_OK}
42 do_test 1.3.1 {
43   set DB [sqlite3_open test.db]
44   set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
45   sqlite3_step $STMT
46   sqlite3_close_v2 $DB
47 } {SQLITE_OK}
49 do_test 1.3.2 {
50   sqlite3_column_text $STMT 0
51 } {one}
53 do_test 1.3.3 {
54   sqlite3_finalize $STMT
55 } {SQLITE_OK}
57 do_test 1.4.1 {
58   set DB [sqlite3_open test.db]
59   set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
60   sqlite3_step $STMT
61   sqlite3_close_v2 $DB
62 } {SQLITE_OK}
64 do_test 1.4.2 {
65   list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0]
66 } {SQLITE_ROW two}
68 do_test 1.4.3 {
69   list [catch {
70     sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
71   } msg] $msg
72 } {1 {(21) library routine called out of sequence}}
74 do_test 1.4.4 {
75   sqlite3_finalize $STMT
76 } {SQLITE_OK}
78 finish_test