OLD | NEW |
1 # 2007 April 24 | 1 # 2007 April 24 |
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 #*********************************************************************** |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 # Create a database. | 26 # Create a database. |
27 # | 27 # |
28 do_test rdonly-1.1 { | 28 do_test rdonly-1.1 { |
29 execsql { | 29 execsql { |
30 CREATE TABLE t1(x); | 30 CREATE TABLE t1(x); |
31 INSERT INTO t1 VALUES(1); | 31 INSERT INTO t1 VALUES(1); |
32 SELECT * FROM t1; | 32 SELECT * FROM t1; |
33 } | 33 } |
34 } {1} | 34 } {1} |
| 35 do_test rdonly-1.1.1 { |
| 36 sqlite3_db_readonly db main |
| 37 } {0} |
35 | 38 |
36 # Changes the write version from 1 to 3. Verify that the database | 39 # Changes the write version from 1 to 3. Verify that the database |
37 # can be read but not written. | 40 # can be read but not written. |
38 # | 41 # |
39 do_test rdonly-1.2 { | 42 do_test rdonly-1.2 { |
40 db close | 43 db close |
41 hexio_get_int [hexio_read test.db 18 1] | 44 hexio_get_int [hexio_read test.db 18 1] |
42 } 1 | 45 } 1 |
43 do_test rdonly-1.3 { | 46 do_test rdonly-1.3 { |
44 hexio_write test.db 18 03 | 47 hexio_write test.db 18 03 |
45 sqlite3 db test.db | 48 sqlite3 db test.db |
46 execsql { | 49 execsql { |
47 SELECT * FROM t1; | 50 SELECT * FROM t1; |
48 } | 51 } |
49 } {1} | 52 } {1} |
| 53 do_test rdonly-1.3.1 { |
| 54 sqlite3_db_readonly db main |
| 55 } {1} |
50 do_test rdonly-1.4 { | 56 do_test rdonly-1.4 { |
51 catchsql { | 57 catchsql { |
52 INSERT INTO t1 VALUES(2) | 58 INSERT INTO t1 VALUES(2) |
53 } | 59 } |
54 } {1 {attempt to write a readonly database}} | 60 } {1 {attempt to write a readonly database}} |
55 | 61 |
56 # Change the write version back to 1. Verify that the database | 62 # Change the write version back to 1. Verify that the database |
57 # is read-write again. | 63 # is read-write again. |
58 # | 64 # |
59 do_test rdonly-1.5 { | 65 do_test rdonly-1.5 { |
(...skipping 15 matching lines...) Expand all Loading... |
75 ifcapable wal { set ro_version 03 } | 81 ifcapable wal { set ro_version 03 } |
76 do_test rdonly-1.6 { | 82 do_test rdonly-1.6 { |
77 hexio_write test.db 18 $ro_version ; # write-version | 83 hexio_write test.db 18 $ro_version ; # write-version |
78 hexio_write test.db 24 11223344 ; # change-counter | 84 hexio_write test.db 24 11223344 ; # change-counter |
79 catchsql { | 85 catchsql { |
80 INSERT INTO t1 VALUES(2); | 86 INSERT INTO t1 VALUES(2); |
81 } | 87 } |
82 } {1 {attempt to write a readonly database}} | 88 } {1 {attempt to write a readonly database}} |
83 | 89 |
84 finish_test | 90 finish_test |
OLD | NEW |