Convert the implementation of the ".dbstat" dot-command of the command-line
[sqlite.git] / test / fts3corrupt3.test
blob6c846e9baef98170d13902b57e7f4832086ef17f
1 # 2010 October 27
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.
7 #***********************************************************************
8 # Test that the FTS3 extension does not crash when it encounters a
9 # corrupt data structure on disk.
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
16 # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
17 ifcapable !fts3 { finish_test ; return }
19 set ::testprefix fts3corrupt3
21 #-------------------------------------------------------------------------
22 # Test that fts3 does not choke on an oversized varint.
24 do_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;
33 do_execsql_test 1.1 {
34   SELECT quote(root) from t1_segdir;
35 } {X'00036F6E6509010200010200010200'}
36 do_execsql_test 1.2 {
37   UPDATE t1_segdir SET root = X'00036F6E650EFFFFFFFFFFFFFFFFFFFFFFFF0200';
39 do_catchsql_test 1.3 {
40   SELECT rowid FROM t1 WHERE t1 MATCH 'one'
41 } {0 -1}
43 #-------------------------------------------------------------------------
44 # Interior node with the prefix or suffix count of an entry set to a
45 # negative value.
47 set doc1 [string repeat "x " 600]
48 set doc2 [string repeat "y " 600]
49 set doc3 [string repeat "z " 600]
51 do_execsql_test 2.0 {
52   CREATE VIRTUAL TABLE t2 USING fts3;
53   BEGIN;
54     INSERT INTO t2 VALUES($doc1);
55     INSERT INTO t2 VALUES($doc2);
56     INSERT INTO t2 VALUES($doc3);
57   COMMIT;
59 do_execsql_test 2.1 {
60   SELECT quote(root) from t2_segdir;
61 } {X'0101017900017A'}
65 finish_test