xref: /sqlite-3.40.0/test/close.test (revision e464802d)
1617dc860Sdan# 2013 May 14
2617dc860Sdan#
3617dc860Sdan# The author disclaims copyright to this source code.  In place of
4617dc860Sdan# a legal notice, here is a blessing:
5617dc860Sdan#
6617dc860Sdan#    May you do good and not evil.
7617dc860Sdan#    May you find forgiveness for yourself and forgive others.
8617dc860Sdan#    May you share freely, never taking more than you give.
9617dc860Sdan#
10617dc860Sdan#***********************************************************************
11617dc860Sdan#
12617dc860Sdan# Test some specific circumstances to do with shared cache mode.
13617dc860Sdan#
14617dc860Sdan
15617dc860Sdan
16617dc860Sdanset testdir [file dirname $argv0]
17617dc860Sdansource $testdir/tester.tcl
18617dc860Sdanset ::testprefix close
19617dc860Sdan
20af3906a7Sdrh# This module bypasses the "-key" logic in tester.tcl, so it cannot run
21af3906a7Sdrh# with the codec enabled.
22af3906a7Sdrhdo_not_use_codec
23af3906a7Sdrh
24617dc860Sdando_execsql_test 1.0 {
25617dc860Sdan  CREATE TABLE t1(x);
26617dc860Sdan  INSERT INTO t1 VALUES('one');
27617dc860Sdan  INSERT INTO t1 VALUES('two');
28617dc860Sdan  INSERT INTO t1 VALUES('three');
29617dc860Sdan}
30617dc860Sdandb close
31617dc860Sdan
32617dc860Sdando_test 1.1 {
33617dc860Sdan  set DB [sqlite3_open test.db]
34617dc860Sdan  sqlite3_close_v2 $DB
35617dc860Sdan} {SQLITE_OK}
36617dc860Sdan
37617dc860Sdando_test 1.2.1 {
38617dc860Sdan  set DB [sqlite3_open test.db]
39617dc860Sdan  set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
40617dc860Sdan  sqlite3_close_v2 $DB
41617dc860Sdan} {SQLITE_OK}
42617dc860Sdando_test 1.2.2 {
43617dc860Sdan  sqlite3_finalize $STMT
44617dc860Sdan} {SQLITE_OK}
45617dc860Sdan
46617dc860Sdando_test 1.3.1 {
47617dc860Sdan  set DB [sqlite3_open test.db]
48617dc860Sdan  set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
49617dc860Sdan  sqlite3_step $STMT
50617dc860Sdan  sqlite3_close_v2 $DB
51617dc860Sdan} {SQLITE_OK}
52617dc860Sdan
53617dc860Sdando_test 1.3.2 {
54617dc860Sdan  sqlite3_column_text $STMT 0
55617dc860Sdan} {one}
56617dc860Sdan
57617dc860Sdando_test 1.3.3 {
58617dc860Sdan  sqlite3_finalize $STMT
59617dc860Sdan} {SQLITE_OK}
60617dc860Sdan
61617dc860Sdando_test 1.4.1 {
62617dc860Sdan  set DB [sqlite3_open test.db]
63617dc860Sdan  set STMT [sqlite3_prepare $DB "SELECT * FROM t1" -1 dummy]
64617dc860Sdan  sqlite3_step $STMT
65617dc860Sdan  sqlite3_close_v2 $DB
66617dc860Sdan} {SQLITE_OK}
67617dc860Sdan
68617dc860Sdando_test 1.4.2 {
69617dc860Sdan  list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0]
70617dc860Sdan} {SQLITE_ROW two}
71617dc860Sdan
72617dc860Sdando_test 1.4.3 {
73617dc860Sdan  list [catch {
74617dc860Sdan    sqlite3_prepare $DB "SELECT * FROM sqlite_master" -1 dummy
75617dc860Sdan  } msg] $msg
76ff4fa772Sdrh} {1 {(21) bad parameter or other API misuse}}
77617dc860Sdan
78617dc860Sdando_test 1.4.4 {
79617dc860Sdan  sqlite3_finalize $STMT
80617dc860Sdan} {SQLITE_OK}
81617dc860Sdan
82*e464802dSdando_test 1.5 {
83*e464802dSdan  set DB [sqlite3_open test.db]
84*e464802dSdan  sqlite3_blob_open $DB main t1 x 2 0 BLOB
85*e464802dSdan  sqlite3_close_v2 $DB
86*e464802dSdan  sqlite3_blob_close $BLOB
87*e464802dSdan} {}
88*e464802dSdan
89617dc860Sdanfinish_test
90