AryaWu/sqlite
0
1# 2010 October 272#3# May you do good and not evil.4# May you find forgiveness for yourself and forgive others.5# May you share freely, never taking more than you give.6#7#***********************************************************************8# Test that the FTS3 extension does not crash when it encounters a9# corrupt data structure on disk.10#11 12 13set testdir [file dirname $argv0]14source $testdir/tester.tcl15 16# If SQLITE_ENABLE_FTS3 is not defined, omit this file.17ifcapable !fts3 { finish_test ; return }18 19set ::testprefix fts3corrupt320 21#-------------------------------------------------------------------------22# Test that fts3 does not choke on an oversized varint.23#24do_execsql_test 1.0 {25 PRAGMA page_size = 512;26 CREATE VIRTUAL TABLE t1 USING fts3;27 BEGIN;28 INSERT INTO t1 VALUES('one');29 INSERT INTO t1 VALUES('one');30 INSERT INTO t1 VALUES('one');31 COMMIT;32}33do_execsql_test 1.1 {34 SELECT quote(root) from t1_segdir;35} {X'00036F6E6509010200010200010200'}36sqlite3_db_config db DEFENSIVE 037do_execsql_test 1.2 {38 UPDATE t1_segdir SET root = X'00036F6E650EFFFFFFFFFFFFFFFFFFFFFFFF0200';39}40do_catchsql_test 1.3 {41 SELECT rowid FROM t1 WHERE t1 MATCH 'one'42} {0 -1}43 44#-------------------------------------------------------------------------45# Interior node with the prefix or suffix count of an entry set to a46# negative value.47#48set doc1 [string repeat "x " 600]49set doc2 [string repeat "y " 600]50set doc3 [string repeat "z " 600]51 52do_execsql_test 2.0 {53 CREATE VIRTUAL TABLE t2 USING fts3;54 BEGIN;55 INSERT INTO t2 VALUES($doc1);56 INSERT INTO t2 VALUES($doc2);57 INSERT INTO t2 VALUES($doc3);58 COMMIT;59}60do_execsql_test 2.1 {61 SELECT quote(root) from t2_segdir;62} {X'0101017900017A'}63 64 65 66finish_test67 