OLD | NEW |
1 # 2009 February 2 | 1 # 2009 February 2 |
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 catchsql { | 136 catchsql { |
137 alter table v1 add column d; | 137 alter table v1 add column d; |
138 } | 138 } |
139 } {1 {Cannot add a column to a view}} | 139 } {1 {Cannot add a column to a view}} |
140 } | 140 } |
141 do_test alter4-2.6 { | 141 do_test alter4-2.6 { |
142 catchsql { | 142 catchsql { |
143 alter table t1 add column d DEFAULT CURRENT_TIME; | 143 alter table t1 add column d DEFAULT CURRENT_TIME; |
144 } | 144 } |
145 } {1 {Cannot add a column with non-constant default}} | 145 } {1 {Cannot add a column with non-constant default}} |
| 146 do_test alter4-2.7 { |
| 147 catchsql { |
| 148 alter table t1 add column d default (-5+1); |
| 149 } |
| 150 } {1 {Cannot add a column with non-constant default}} |
146 do_test alter4-2.99 { | 151 do_test alter4-2.99 { |
147 execsql { | 152 execsql { |
148 DROP TABLE t1; | 153 DROP TABLE t1; |
149 } | 154 } |
150 } {} | 155 } {} |
151 | 156 |
152 do_test alter4-3.1 { | 157 do_test alter4-3.1 { |
153 execsql { | 158 execsql { |
154 CREATE TEMP TABLE t1(a, b); | 159 CREATE TEMP TABLE t1(a, b); |
155 INSERT INTO t1 VALUES(1, 100); | 160 INSERT INTO t1 VALUES(1, 100); |
(...skipping 15 matching lines...) Expand all Loading... |
171 ifcapable schema_version { | 176 ifcapable schema_version { |
172 do_test alter4-3.4 { | 177 do_test alter4-3.4 { |
173 execsql { | 178 execsql { |
174 PRAGMA schema_version; | 179 PRAGMA schema_version; |
175 } | 180 } |
176 } {10} | 181 } {10} |
177 } | 182 } |
178 | 183 |
179 do_test alter4-4.1 { | 184 do_test alter4-4.1 { |
180 db close | 185 db close |
181 file delete -force test.db | 186 forcedelete test.db |
182 set ::DB [sqlite3 db test.db] | 187 set ::DB [sqlite3 db test.db] |
183 execsql { | 188 execsql { |
184 CREATE TEMP TABLE t1(a, b); | 189 CREATE TEMP TABLE t1(a, b); |
185 INSERT INTO t1 VALUES(1, 100); | 190 INSERT INTO t1 VALUES(1, 100); |
186 INSERT INTO t1 VALUES(2, 300); | 191 INSERT INTO t1 VALUES(2, 300); |
187 SELECT * FROM t1; | 192 SELECT * FROM t1; |
188 } | 193 } |
189 } {1 100 2 300} | 194 } {1 100 2 300} |
190 do_test alter4-4.1 { | 195 do_test alter4-4.1 { |
191 execsql { | 196 execsql { |
(...skipping 14 matching lines...) Expand all Loading... |
206 } {20} | 211 } {20} |
207 } | 212 } |
208 do_test alter4-4.99 { | 213 do_test alter4-4.99 { |
209 execsql { | 214 execsql { |
210 DROP TABLE t1; | 215 DROP TABLE t1; |
211 } | 216 } |
212 } {} | 217 } {} |
213 | 218 |
214 ifcapable attach { | 219 ifcapable attach { |
215 do_test alter4-5.1 { | 220 do_test alter4-5.1 { |
216 file delete -force test2.db | 221 forcedelete test2.db |
217 file delete -force test2.db-journal | 222 forcedelete test2.db-journal |
218 execsql { | 223 execsql { |
219 CREATE TEMP TABLE t1(a, b); | 224 CREATE TEMP TABLE t1(a, b); |
220 INSERT INTO t1 VALUES(1, 'one'); | 225 INSERT INTO t1 VALUES(1, 'one'); |
221 INSERT INTO t1 VALUES(2, 'two'); | 226 INSERT INTO t1 VALUES(2, 'two'); |
222 ATTACH 'test2.db' AS aux; | 227 ATTACH 'test2.db' AS aux; |
223 CREATE TABLE aux.t1 AS SELECT * FROM t1; | 228 CREATE TABLE aux.t1 AS SELECT * FROM t1; |
224 PRAGMA aux.schema_version = 30; | 229 PRAGMA aux.schema_version = 30; |
225 SELECT sql FROM aux.sqlite_master; | 230 SELECT sql FROM aux.sqlite_master; |
226 } | 231 } |
227 } {{CREATE TABLE t1(a,b)}} | 232 } {{CREATE TABLE t1(a,b)}} |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 327 } |
323 set ::sql "CREATE TABLE t4([join $cols {, }])" | 328 set ::sql "CREATE TABLE t4([join $cols {, }])" |
324 list | 329 list |
325 } {} | 330 } {} |
326 do_test alter4-8.2 { | 331 do_test alter4-8.2 { |
327 execsql { | 332 execsql { |
328 SELECT sql FROM sqlite_temp_master WHERE name = 't4'; | 333 SELECT sql FROM sqlite_temp_master WHERE name = 't4'; |
329 } | 334 } |
330 } [list $::sql] | 335 } [list $::sql] |
331 | 336 |
| 337 |
| 338 # Test that a default value equal to -1 multipied by the smallest possible |
| 339 # 64-bit integer is correctly converted to a real. |
| 340 do_execsql_test alter4-9.1 { |
| 341 CREATE TABLE t5( |
| 342 a INTEGER DEFAULT -9223372036854775808, |
| 343 b INTEGER DEFAULT (-(-9223372036854775808)) |
| 344 ); |
| 345 INSERT INTO t5 DEFAULT VALUES; |
| 346 } |
| 347 |
| 348 do_execsql_test alter4-9.2 { SELECT typeof(a), a, typeof(b), b FROM t5; } { |
| 349 integer -9223372036854775808 |
| 350 real 9.22337203685478e+18 |
| 351 } |
| 352 |
| 353 do_execsql_test alter4-9.3 { |
| 354 ALTER TABLE t5 ADD COLUMN c INTEGER DEFAULT (-(-9223372036854775808)); |
| 355 SELECT typeof(c), c FROM t5; |
| 356 } {real 9.22337203685478e+18} |
| 357 |
332 finish_test | 358 finish_test |
OLD | NEW |