| OLD | NEW |
| 1 # 2015 Apr 24 | 1 # 2015 Apr 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 19 matching lines...) Expand all Loading... |
| 30 expr srand(0) | 30 expr srand(0) |
| 31 db func rnddoc fts5_rnddoc | 31 db func rnddoc fts5_rnddoc |
| 32 do_execsql_test 1.0 { | 32 do_execsql_test 1.0 { |
| 33 CREATE VIRTUAL TABLE t1 USING fts5(x); | 33 CREATE VIRTUAL TABLE t1 USING fts5(x); |
| 34 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); | 34 INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
| 35 WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100) | 35 WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100) |
| 36 INSERT INTO t1 SELECT rnddoc(10) FROM ii; | 36 INSERT INTO t1 SELECT rnddoc(10) FROM ii; |
| 37 } | 37 } |
| 38 set mask [expr 31 << 31] | 38 set mask [expr 31 << 31] |
| 39 | 39 |
| 40 if 1 { | 40 if 0 { |
| 41 | 41 |
| 42 # Test 1: | 42 # Test 1: |
| 43 # | 43 # |
| 44 # For each page in the t1_data table, open a transaction and DELETE | 44 # For each page in the t1_data table, open a transaction and DELETE |
| 45 # the t1_data entry. Then run: | 45 # the t1_data entry. Then run: |
| 46 # | 46 # |
| 47 # * an integrity-check, and | 47 # * an integrity-check, and |
| 48 # * unless the deleted block was a b-tree node, a query for "t1 MATCH 'x*'" | 48 # * unless the deleted block was a b-tree node, a query for "t1 MATCH 'x*'" |
| 49 # | 49 # |
| 50 # and check that the corruption is detected in both cases. The | 50 # and check that the corruption is detected in both cases. The |
| (...skipping 26 matching lines...) Expand all Loading... |
| 77 } {1 {database disk image is malformed}} | 77 } {1 {database disk image is malformed}} |
| 78 } | 78 } |
| 79 | 79 |
| 80 do_execsql_test 1.$tno.$tn.3.$rowid { | 80 do_execsql_test 1.$tno.$tn.3.$rowid { |
| 81 ROLLBACK; | 81 ROLLBACK; |
| 82 INSERT INTO t1(t1) VALUES('integrity-check'); | 82 INSERT INTO t1(t1) VALUES('integrity-check'); |
| 83 } {} | 83 } {} |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 } |
| 88 |
| 87 # Using the same database as the 1.* tests. | 89 # Using the same database as the 1.* tests. |
| 88 # | 90 # |
| 89 # Run N-1 tests, where N is the number of bytes in the rightmost leaf page | 91 # Run N-1 tests, where N is the number of bytes in the rightmost leaf page |
| 90 # of the fts index. For test $i, truncate the rightmost leafpage to $i | 92 # of the fts index. For test $i, truncate the rightmost leafpage to $i |
| 91 # bytes. Then test both the integrity-check detects the corruption. | 93 # bytes. Then test both the integrity-check detects the corruption. |
| 92 # | 94 # |
| 93 # Also tested is that "MATCH 'x*'" does not crash and sometimes reports | 95 # Also tested is that "MATCH 'x*'" does not crash and sometimes reports |
| 94 # corruption. It may not report the db as corrupt because truncating the | 96 # corruption. It may not report the db as corrupt because truncating the |
| 95 # final leaf to some sizes may create a valid leaf page. | 97 # final leaf to some sizes may create a valid leaf page. |
| 96 # | 98 # |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if {$res == "1 {database disk image is malformed}"} {incr nCorrupt} | 207 if {$res == "1 {database disk image is malformed}"} {incr nCorrupt} |
| 206 set {} 1 | 208 set {} 1 |
| 207 } {1} | 209 } {1} |
| 208 | 210 |
| 209 execsql ROLLBACK | 211 execsql ROLLBACK |
| 210 } | 212 } |
| 211 | 213 |
| 212 # do_test 4.$tn.x { expr $nCorrupt>0 } 1 | 214 # do_test 4.$tn.x { expr $nCorrupt>0 } 1 |
| 213 } | 215 } |
| 214 | 216 |
| 215 } | |
| 216 | |
| 217 set doc [string repeat "A B C " 1000] | 217 set doc [string repeat "A B C " 1000] |
| 218 do_execsql_test 5.0 { | 218 do_execsql_test 5.0 { |
| 219 CREATE VIRTUAL TABLE x5 USING fts5(tt); | 219 CREATE VIRTUAL TABLE x5 USING fts5(tt); |
| 220 INSERT INTO x5(x5, rank) VALUES('pgsz', 32); | 220 INSERT INTO x5(x5, rank) VALUES('pgsz', 32); |
| 221 WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10) | 221 WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10) |
| 222 INSERT INTO x5 SELECT $doc FROM ii; | 222 INSERT INTO x5 SELECT $doc FROM ii; |
| 223 } | 223 } |
| 224 | 224 |
| 225 foreach {tn hdr} { | 225 foreach {tn hdr} { |
| 226 1 "\x00\x01" | 226 1 "\x00\x01" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 sqlite3_fts5_create_function db colsize colsize | 263 sqlite3_fts5_create_function db colsize colsize |
| 264 | 264 |
| 265 do_catchsql_test 6.2 { | 265 do_catchsql_test 6.2 { |
| 266 SELECT colsize(x5, 0) FROM x5 WHERE x5 MATCH 'a' | 266 SELECT colsize(x5, 0) FROM x5 WHERE x5 MATCH 'a' |
| 267 } {1 SQLITE_CORRUPT_VTAB} | 267 } {1 SQLITE_CORRUPT_VTAB} |
| 268 | 268 |
| 269 | 269 |
| 270 sqlite3_fts5_may_be_corrupt 0 | 270 sqlite3_fts5_may_be_corrupt 0 |
| 271 finish_test | 271 finish_test |
| 272 | 272 |
| OLD | NEW |