Add a test for the fixes on this branch.
[sqlite.git] / test / fts3corrupt5.test
bloba8a3b0168e616ad68bf055813151fb6aa63235cc
1 # 2019 May 22
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
6 #    May you do good and not evil.
7 #    May you find forgiveness for yourself and forgive others.
8 #    May you share freely, never taking more than you give.
10 #*************************************************************************
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 source $testdir/fts3_common.tcl
17 set testprefix fts3corrupt5
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
20 ifcapable !fts3 {
21   finish_test
22   return
25 sqlite3_fts3_may_be_corrupt 1
27 do_execsql_test 1.0 {
28   BEGIN;
29     CREATE VIRTUAL TABLE ft USING fts3(a, b, c);
30     INSERT INTO ft VALUES('one', 'one', 'one');
31   COMMIT;
34 do_execsql_test 1.1 {
35   SELECT * FROM ft WHERE ft MATCH 'b:one'
36 } {one one one}
38 do_execsql_test 1.2 {
39   SELECT quote(root) FROM ft_segdir;
40 } {X'00036F6E6509010201010201020200'}
42 breakpoint
43 foreach {tn val q bCorrupt} {
44   1 X'00036F6E650901'                   'b:one'  1
45   2 X'00036F6E6509010201010201FFFFFF'   'c:one'  1
46   3 X'00036F6E6501'                     'b:one'  1
47   4 X'00036F6E650101'                   'b:one'  1
48   5 X'00036F6E650100'                   'b:one'  0
49 } {
50   do_execsql_test 1.3.$tn.1 "UPDATE ft_segdir SET root = $val"
52   set res {0 {}}
53   if {$bCorrupt} { set res {1 {database disk image is malformed}}}
54   do_catchsql_test 1.3.$tn.2 {
55     SELECT * FROM ft WHERE ft MATCH $q
56   } $res
59 finish_test