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 interface. | 13 # This file is devoted to testing the sqlite3_next_stmt and |
| 14 # sqlite3_stmt_readonly interfaces. |
14 # | 15 # |
15 # $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 $ |
16 # | 17 # |
17 | 18 |
18 set testdir [file dirname $argv0] | 19 set testdir [file dirname $argv0] |
19 source $testdir/tester.tcl | 20 source $testdir/tester.tcl |
20 | 21 |
21 # Create N prepared statements against database connection db | 22 # Create N prepared statements against database connection db |
22 # and return a list of all the generated prepared statements. | 23 # and return a list of all the generated prepared statements. |
23 # | 24 # |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 82 } |
82 lsort $x | 83 lsort $x |
83 } [lsort $stmtlist] | 84 } [lsort $stmtlist] |
84 do_test capi3-1.2.$i.2 { | 85 do_test capi3-1.2.$i.2 { |
85 foreach p [scramble $::stmtlist] { | 86 foreach p [scramble $::stmtlist] { |
86 sqlite3_finalize $p | 87 sqlite3_finalize $p |
87 } | 88 } |
88 sqlite3_next_stmt db 0 | 89 sqlite3_next_stmt db 0 |
89 } {} | 90 } {} |
90 } | 91 } |
91 | 92 |
| 93 # Tests for the is-read-only interface. |
| 94 # |
| 95 proc test_is_readonly {testname sql truth} { |
| 96 do_test $testname [format { |
| 97 set DB [sqlite3_connection_pointer db] |
| 98 set STMT [sqlite3_prepare $DB {%s} -1 TAIL] |
| 99 set rc [sqlite3_stmt_readonly $STMT] |
| 100 sqlite3_finalize $STMT |
| 101 set rc |
| 102 } $sql] $truth |
| 103 } |
| 104 |
| 105 test_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1 |
| 106 test_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0 |
| 107 db eval {CREATE TABLE t1(x)} |
| 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 |
| 110 test_is_readonly capi3d-2.5 {SELECT * FROM t1} 1 |
| 111 do_test capi3-2.99 { |
| 112 sqlite3_stmt_readonly 0 |
| 113 } 1 |
| 114 |
92 | 115 |
93 finish_test | 116 finish_test |
OLD | NEW |