| OLD | NEW |
| 1 # 2010 September 24 | 1 # 2010 September 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 30 matching lines...) Expand all Loading... |
| 41 # EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and | 41 # EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and |
| 42 # recreate indices from scratch. | 42 # recreate indices from scratch. |
| 43 # | 43 # |
| 44 # Test this by corrupting some database indexes, running REINDEX, and | 44 # Test this by corrupting some database indexes, running REINDEX, and |
| 45 # observing that the corruption is gone. | 45 # observing that the corruption is gone. |
| 46 # | 46 # |
| 47 do_execsql_test e_reindex-1.1 { | 47 do_execsql_test e_reindex-1.1 { |
| 48 INSERT INTO t1 VALUES(1, 2); | 48 INSERT INTO t1 VALUES(1, 2); |
| 49 INSERT INTO t1 VALUES(3, 4); | 49 INSERT INTO t1 VALUES(3, 4); |
| 50 INSERT INTO t1 VALUES(5, 6); | 50 INSERT INTO t1 VALUES(5, 6); |
| 51 |
| 52 CREATE TABLE saved(a,b,c,d,e); |
| 53 INSERT INTO saved SELECT * FROM sqlite_master WHERE type = 'index'; |
| 51 PRAGMA writable_schema = 1; | 54 PRAGMA writable_schema = 1; |
| 52 UPDATE sqlite_master SET sql = '-- ' || sql WHERE type = 'index'; | 55 DELETE FROM sqlite_master WHERE type = 'index'; |
| 53 } {} | 56 } {} |
| 54 | 57 |
| 55 db close | 58 db close |
| 56 sqlite3 db test.db | 59 sqlite3 db test.db |
| 57 do_execsql_test e_reindex-1.2 { | 60 do_execsql_test e_reindex-1.2 { |
| 58 DELETE FROM t1 WHERE a = 3; | 61 DELETE FROM t1 WHERE a = 3; |
| 59 INSERT INTO t1 VALUES(7, 8); | 62 INSERT INTO t1 VALUES(7, 8); |
| 60 INSERT INTO t1 VALUES(9, 10); | 63 INSERT INTO t1 VALUES(9, 10); |
| 61 PRAGMA writable_schema = 1; | 64 PRAGMA writable_schema = 1; |
| 62 UPDATE sqlite_master SET sql = substr(sql, 4) WHERE type = 'index'; | 65 INSERT INTO sqlite_master SELECT * FROM saved; |
| 66 DROP TABLE saved; |
| 63 } {} | 67 } {} |
| 64 | 68 |
| 65 db close | 69 db close |
| 66 sqlite3 db test.db | 70 sqlite3 db test.db |
| 67 do_execsql_test e_reindex-1.3 { | 71 do_execsql_test e_reindex-1.3 { |
| 68 PRAGMA integrity_check; | 72 PRAGMA integrity_check; |
| 69 } [list \ | 73 } [list \ |
| 70 {row 3 missing from index i2} \ | 74 {row 3 missing from index i2} \ |
| 71 {row 3 missing from index i1} \ | 75 {row 3 missing from index i1} \ |
| 72 {row 4 missing from index i2} \ | 76 {row 4 missing from index i2} \ |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 test_index 5.34 aux.t1 collA value | 258 test_index 5.34 aux.t1 collA value |
| 255 test_index 5.35 aux.t1 collB value | 259 test_index 5.35 aux.t1 collB value |
| 256 do_execsql_test e_reindex-2.5.36 "REINDEX aux.i1_a" {} | 260 do_execsql_test e_reindex-2.5.36 "REINDEX aux.i1_a" {} |
| 257 test_index 5.37 t1 collA length | 261 test_index 5.37 t1 collA length |
| 258 test_index 5.38 t1 collB value | 262 test_index 5.38 t1 collB value |
| 259 test_index 5.39 t2 collA length | 263 test_index 5.39 t2 collA length |
| 260 test_index 5.40 t2 collB value | 264 test_index 5.40 t2 collB value |
| 261 test_index 5.41 aux.t1 collA length | 265 test_index 5.41 aux.t1 collA length |
| 262 test_index 5.42 aux.t1 collB value | 266 test_index 5.42 aux.t1 collB value |
| 263 | 267 |
| 264 # EVIDENCE-OF: R-15639-02023 If no database-name is specified and there | 268 # EVIDENCE-OF: R-35892-30289 For a command of the form "REINDEX name", a |
| 265 # exists both a table or index and a collation sequence of the specified | 269 # match against collation-name takes precedence over a match against |
| 266 # name, SQLite interprets this as a request to rebuild the indices that | 270 # index-name or table-name. |
| 267 # use the named collation sequence. | |
| 268 # | 271 # |
| 269 set_collations value length | 272 set_collations value length |
| 270 do_execsql_test e_reindex-2.6.0 { | 273 do_execsql_test e_reindex-2.6.0 { |
| 271 CREATE TABLE collA(x); | 274 CREATE TABLE collA(x); |
| 272 CREATE INDEX icolla_a ON collA(x COLLATE collA); | 275 CREATE INDEX icolla_a ON collA(x COLLATE collA); |
| 273 CREATE INDEX icolla_b ON collA(x COLLATE collB); | 276 CREATE INDEX icolla_b ON collA(x COLLATE collB); |
| 274 | 277 |
| 275 INSERT INTO collA SELECT x FROM t1; | 278 INSERT INTO collA SELECT x FROM t1; |
| 276 } {} | 279 } {} |
| 277 | 280 |
| 278 test_index 6.1 collA collA value | 281 test_index 6.1 collA collA value |
| 279 test_index 6.2 collA collB length | 282 test_index 6.2 collA collB length |
| 280 | 283 |
| 281 set_collations length value | 284 set_collations length value |
| 282 do_execsql_test e_reindex-2.6.3 "REINDEX collA" {} | 285 do_execsql_test e_reindex-2.6.3 "REINDEX collA" {} |
| 283 test_index 6.4 collA collA length | 286 test_index 6.4 collA collA length |
| 284 test_index 6.5 collA collB length | 287 test_index 6.5 collA collB length |
| 285 do_execsql_test e_reindex-2.6.3 "REINDEX main.collA" {} | 288 do_execsql_test e_reindex-2.6.3 "REINDEX main.collA" {} |
| 286 test_index 6.4 collA collA length | 289 test_index 6.4 collA collA length |
| 287 test_index 6.5 collA collB value | 290 test_index 6.5 collA collB value |
| 288 | 291 |
| 289 set_collations value length | 292 set_collations value length |
| 290 do_execsql_test e_reindex-2.6.6 "REINDEX main.collA" {} | 293 do_execsql_test e_reindex-2.6.6 "REINDEX main.collA" {} |
| 291 test_index 6.7 collA collA value | 294 test_index 6.7 collA collA value |
| 292 test_index 6.8 collA collB length | 295 test_index 6.8 collA collB length |
| 293 | 296 |
| 294 finish_test | 297 finish_test |
| OLD | NEW |