OLD | NEW |
1 # 2008 June 18 | 1 # 2008 June 18 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
12 # | 12 # |
13 # This file is devoted to testing the sqlite3_next_stmt and | 13 # This file is devoted to testing the sqlite3_next_stmt and |
14 # sqlite3_stmt_readonly interfaces. | 14 # sqlite3_stmt_readonly and sqlite3_stmt_busy interfaces. |
15 # | 15 # |
16 # $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $ | 16 # $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $ |
17 # | 17 # |
18 | 18 |
19 set testdir [file dirname $argv0] | 19 set testdir [file dirname $argv0] |
20 source $testdir/tester.tcl | 20 source $testdir/tester.tcl |
21 | 21 |
22 # Create N prepared statements against database connection db | 22 # Create N prepared statements against database connection db |
23 # and return a list of all the generated prepared statements. | 23 # and return a list of all the generated prepared statements. |
24 # | 24 # |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 set rc | 101 set rc |
102 } $sql] $truth | 102 } $sql] $truth |
103 } | 103 } |
104 | 104 |
105 test_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1 | 105 test_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1 |
106 test_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0 | 106 test_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0 |
107 db eval {CREATE TABLE t1(x)} | 107 db eval {CREATE TABLE t1(x)} |
108 test_is_readonly capi3d-2.3 {INSERT INTO t1 VALUES(5)} 0 | 108 test_is_readonly capi3d-2.3 {INSERT INTO t1 VALUES(5)} 0 |
109 test_is_readonly capi3d-2.4 {UPDATE t1 SET x=x+1 WHERE x<0} 0 | 109 test_is_readonly capi3d-2.4 {UPDATE t1 SET x=x+1 WHERE x<0} 0 |
110 test_is_readonly capi3d-2.5 {SELECT * FROM t1} 1 | 110 test_is_readonly capi3d-2.5 {SELECT * FROM t1} 1 |
| 111 ifcapable wal { |
| 112 test_is_readonly capi3d-2.6 {PRAGMA journal_mode=WAL} 0 |
| 113 test_is_readonly capi3d-2.7 {PRAGMA wal_checkpoint} 0 |
| 114 } |
| 115 test_is_readonly capi3d-2.8 {PRAGMA application_id=1234} 0 |
| 116 test_is_readonly capi3d-2.9 {VACUUM} 0 |
| 117 test_is_readonly capi3d-2.10 {PRAGMA integrity_check} 1 |
111 do_test capi3-2.99 { | 118 do_test capi3-2.99 { |
112 sqlite3_stmt_readonly 0 | 119 sqlite3_stmt_readonly 0 |
113 } 1 | 120 } 1 |
114 | 121 |
| 122 # Tests for sqlite3_stmt_busy |
| 123 # |
| 124 do_test capi3d-3.1 { |
| 125 db eval {INSERT INTO t1 VALUES(6); INSERT INTO t1 VALUES(7);} |
| 126 set STMT [sqlite3_prepare db {SELECT * FROM t1} -1 TAIL] |
| 127 sqlite3_stmt_busy $STMT |
| 128 } {0} |
| 129 do_test capi3d-3.2 { |
| 130 sqlite3_step $STMT |
| 131 sqlite3_stmt_busy $STMT |
| 132 } {1} |
| 133 do_test capi3d-3.3 { |
| 134 sqlite3_step $STMT |
| 135 sqlite3_stmt_busy $STMT |
| 136 } {1} |
| 137 do_test capi3d-3.4 { |
| 138 sqlite3_reset $STMT |
| 139 sqlite3_stmt_busy $STMT |
| 140 } {0} |
| 141 |
| 142 do_test capi3d-3.99 { |
| 143 sqlite3_finalize $STMT |
| 144 sqlite3_stmt_busy 0 |
| 145 } {0} |
| 146 |
| 147 #-------------------------------------------------------------------------- |
| 148 # Test the sqlite3_stmt_busy() function with ROLLBACK statements. |
| 149 # |
| 150 reset_db |
| 151 |
| 152 do_execsql_test capi3d-4.1 { |
| 153 CREATE TABLE t4(x,y); |
| 154 BEGIN; |
| 155 } |
| 156 |
| 157 do_test capi3d-4.2.1 { |
| 158 breakpoint |
| 159 set ::s1 [sqlite3_prepare_v2 db "ROLLBACK" -1 notused] |
| 160 sqlite3_step $::s1 |
| 161 } {SQLITE_DONE} |
| 162 |
| 163 do_test capi3d-4.2.2 { |
| 164 sqlite3_stmt_busy $::s1 |
| 165 } {1} |
| 166 |
| 167 do_catchsql_test capi3d-4.2.3 { |
| 168 VACUUM |
| 169 } {1 {cannot VACUUM - SQL statements in progress}} |
| 170 |
| 171 do_test capi3d-4.2.4 { |
| 172 sqlite3_reset $::s1 |
| 173 } {SQLITE_OK} |
| 174 |
| 175 do_catchsql_test capi3d-4.2.5 { |
| 176 VACUUM |
| 177 } {0 {}} |
| 178 |
| 179 do_test capi3d-4.2.6 { |
| 180 sqlite3_finalize $::s1 |
| 181 } {SQLITE_OK} |
| 182 |
115 | 183 |
116 finish_test | 184 finish_test |
OLD | NEW |