OLD | NEW |
1 # 2009 April 20 | 1 # 2009 April 20 |
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 27 matching lines...) Expand all Loading... |
38 SELECT * FROM t1; | 38 SELECT * FROM t1; |
39 } | 39 } |
40 } {off exclusive 1} | 40 } {off exclusive 1} |
41 do_test jrnlmode3-1.2 { | 41 do_test jrnlmode3-1.2 { |
42 db eval { | 42 db eval { |
43 BEGIN; | 43 BEGIN; |
44 INSERT INTO t1 VALUES(2); | 44 INSERT INTO t1 VALUES(2); |
45 ROLLBACK; | 45 ROLLBACK; |
46 SELECT * FROM t1; | 46 SELECT * FROM t1; |
47 } | 47 } |
48 } {1 2} | 48 } {1} |
49 | 49 |
50 db close | 50 db close |
51 file delete -force test.db test.db-journal | 51 file delete -force test.db test.db-journal |
52 sqlite3 db test.db | 52 sqlite3 db test.db |
53 | 53 |
54 do_test jrnlmode3-2.1 { | 54 do_test jrnlmode3-2.1 { |
55 db eval { | 55 db eval { |
56 PRAGMA locking_mode=EXCLUSIVE; | 56 PRAGMA locking_mode=EXCLUSIVE; |
57 PRAGMA journal_mode=OFF; | 57 PRAGMA journal_mode=OFF; |
58 CREATE TABLE t1(x); | 58 CREATE TABLE t1(x); |
59 INSERT INTO t1 VALUES(1); | 59 INSERT INTO t1 VALUES(1); |
60 SELECT * FROM t1; | 60 SELECT * FROM t1; |
61 } | 61 } |
62 } {exclusive off 1} | 62 } {exclusive off 1} |
63 do_test jrnlmode3-2.2 { | 63 do_test jrnlmode3-2.2 { |
64 db eval { | 64 db eval { |
65 BEGIN; | 65 BEGIN; |
66 INSERT INTO t1 VALUES(2); | 66 INSERT INTO t1 VALUES(2); |
67 ROLLBACK; | 67 ROLLBACK; |
68 SELECT * FROM t1; | 68 SELECT * FROM t1; |
69 } | 69 } |
70 } {1 2} | 70 } {1} |
71 | 71 |
72 # Test cases to verify that we can move from any journal_mode | 72 # Test cases to verify that we can move from any journal_mode |
73 # to any other, as long as we are not in a transaction. Verify | 73 # to any other, as long as we are not in a transaction. Verify |
74 # that we cannot change journal_mode while a transaction is active. | 74 # that we cannot change journal_mode while a transaction is active. |
75 # | 75 # |
76 set all_journal_modes {delete persist truncate memory off} | 76 set all_journal_modes {delete persist truncate memory off} |
77 set cnt 0 | 77 set cnt 0 |
78 foreach fromjmode $all_journal_modes { | 78 foreach fromjmode $all_journal_modes { |
79 foreach tojmode $all_journal_modes { | 79 foreach tojmode $all_journal_modes { |
80 | 80 |
(...skipping 24 matching lines...) Expand all Loading... |
105 # | 105 # |
106 do_test jrnlmode3-3.$cnt.3 { | 106 do_test jrnlmode3-3.$cnt.3 { |
107 db eval { | 107 db eval { |
108 CREATE TABLE t1(x); | 108 CREATE TABLE t1(x); |
109 BEGIN; | 109 BEGIN; |
110 INSERT INTO t1 VALUES($cnt); | 110 INSERT INTO t1 VALUES($cnt); |
111 } | 111 } |
112 db eval "PRAGMA journal_mode=$tojmode" | 112 db eval "PRAGMA journal_mode=$tojmode" |
113 } $fromjmode | 113 } $fromjmode |
114 | 114 |
115 # Rollback the transaction. Verify that the rollback occurred | 115 # Rollback the transaction. |
116 # if journal_mode!=OFF. | |
117 # | 116 # |
118 do_test jrnlmode3-3.$cnt.4 { | 117 do_test jrnlmode3-3.$cnt.4 { |
119 db eval { | 118 db eval { |
120 ROLLBACK; | 119 ROLLBACK; |
121 SELECT * FROM t1; | 120 SELECT * FROM t1; |
122 } | 121 } |
123 } [expr {$fromjmode=="off"?$cnt:""}] | 122 } {} |
124 | 123 |
125 # Now change the journal mode again. This time the new mode | 124 # Now change the journal mode again. This time the new mode |
126 # should take. | 125 # should take. |
127 # | 126 # |
128 do_test jrnlmode3-3.$cnt.5 { | 127 do_test jrnlmode3-3.$cnt.5 { |
129 db eval "PRAGMA journal_mode=$tojmode" | 128 db eval "PRAGMA journal_mode=$tojmode" |
130 } $tojmode | 129 } $tojmode |
131 | 130 |
132 # Do a the transaction. Verify that the rollback occurred | 131 # Do a the transaction. Verify that the rollback occurred |
133 # if journal_mode!=OFF. | 132 # if journal_mode!=OFF. |
134 # | 133 # |
135 do_test jrnlmode3-3.$cnt.6 { | 134 do_test jrnlmode3-3.$cnt.6 { |
136 db eval { | 135 db eval { |
137 DROP TABLE IF EXISTS t1; | 136 DROP TABLE IF EXISTS t1; |
138 CREATE TABLE t1(x); | 137 CREATE TABLE t1(x); |
139 BEGIN; | 138 BEGIN; |
140 INSERT INTO t1 VALUES(1); | 139 INSERT INTO t1 VALUES(1); |
141 } | 140 } |
142 db eval ROLLBACK | 141 db eval ROLLBACK |
143 db eval { | 142 db eval { |
144 SELECT * FROM t1; | 143 SELECT * FROM t1; |
145 } | 144 } |
146 } [expr {$tojmode=="off"?"1":""}] | 145 } {} |
147 } | 146 } |
148 } | 147 } |
149 | 148 |
150 finish_test | 149 finish_test |
OLD | NEW |