OLD | NEW |
1 # 2005 July 22 | 1 # 2005 July 22 |
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 execsql { | 280 execsql { |
281 INSERT INTO sqlite_stat1 VALUES('t4','xyzzy','0 1 2 3'); | 281 INSERT INTO sqlite_stat1 VALUES('t4','xyzzy','0 1 2 3'); |
282 } | 282 } |
283 db close | 283 db close |
284 sqlite3 db test.db | 284 sqlite3 db test.db |
285 execsql { | 285 execsql { |
286 SELECT * FROM t4 WHERE x=1234; | 286 SELECT * FROM t4 WHERE x=1234; |
287 } | 287 } |
288 } {} | 288 } {} |
289 | 289 |
| 290 # Verify that DROP TABLE and DROP INDEX remove entries from the |
| 291 # sqlite_stat1, sqlite_stat3 and sqlite_stat4 tables. |
| 292 # |
| 293 do_test analyze-5.0 { |
| 294 execsql { |
| 295 DELETE FROM t3; |
| 296 DELETE FROM t4; |
| 297 INSERT INTO t3 VALUES(1,2,3,4); |
| 298 INSERT INTO t3 VALUES(5,6,7,8); |
| 299 INSERT INTO t3 SELECT a+8, b+8, c+8, d+8 FROM t3; |
| 300 INSERT INTO t3 SELECT a+16, b+16, c+16, d+16 FROM t3; |
| 301 INSERT INTO t3 SELECT a+32, b+32, c+32, d+32 FROM t3; |
| 302 INSERT INTO t3 SELECT a+64, b+64, c+64, d+64 FROM t3; |
| 303 INSERT INTO t4 SELECT a, b, c FROM t3; |
| 304 ANALYZE; |
| 305 SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1; |
| 306 SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1; |
| 307 } |
| 308 } {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4} |
| 309 ifcapable stat4||stat3 { |
| 310 ifcapable stat4 {set stat sqlite_stat4} else {set stat sqlite_stat3} |
| 311 do_test analyze-5.1 { |
| 312 execsql " |
| 313 SELECT DISTINCT idx FROM $stat ORDER BY 1; |
| 314 SELECT DISTINCT tbl FROM $stat ORDER BY 1; |
| 315 " |
| 316 } {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4} |
| 317 } |
| 318 do_test analyze-5.2 { |
| 319 execsql { |
| 320 DROP INDEX t3i2; |
| 321 SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1; |
| 322 SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1; |
| 323 } |
| 324 } {t3i1 t3i3 t4i1 t4i2 t3 t4} |
| 325 ifcapable stat4||stat3 { |
| 326 do_test analyze-5.3 { |
| 327 execsql " |
| 328 SELECT DISTINCT idx FROM $stat ORDER BY 1; |
| 329 SELECT DISTINCT tbl FROM $stat ORDER BY 1; |
| 330 " |
| 331 } {t3i1 t3i3 t4i1 t4i2 t3 t4} |
| 332 } |
| 333 do_test analyze-5.4 { |
| 334 execsql { |
| 335 DROP TABLE t3; |
| 336 SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1; |
| 337 SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1; |
| 338 } |
| 339 } {t4i1 t4i2 t4} |
| 340 ifcapable stat4||stat3 { |
| 341 do_test analyze-5.5 { |
| 342 execsql " |
| 343 SELECT DISTINCT idx FROM $stat ORDER BY 1; |
| 344 SELECT DISTINCT tbl FROM $stat ORDER BY 1; |
| 345 " |
| 346 } {t4i1 t4i2 t4} |
| 347 } |
| 348 |
290 # This test corrupts the database file so it must be the last test | 349 # This test corrupts the database file so it must be the last test |
291 # in the series. | 350 # in the series. |
292 # | 351 # |
293 do_test analyze-99.1 { | 352 do_test analyze-99.1 { |
294 execsql { | 353 execsql { |
295 PRAGMA writable_schema=on; | 354 PRAGMA writable_schema=on; |
296 UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1'; | 355 UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1'; |
297 } | 356 } |
298 db close | 357 db close |
299 catch { sqlite3 db test.db } | 358 catch { sqlite3 db test.db } |
300 catchsql { | 359 catchsql { |
301 ANALYZE | 360 ANALYZE |
302 } | 361 } |
303 } {1 {malformed database schema (sqlite_stat1) - near "nonsense": syntax error}} | 362 } {1 {malformed database schema (sqlite_stat1) - near "nonsense": syntax error}} |
304 | 363 |
305 | |
306 finish_test | 364 finish_test |
OLD | NEW |