github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/fts3corrupt5.test (about)

     1  # 2019 May 22
     2  #
     3  # The author disclaims copyright to this source code.  In place of
     4  # a legal notice, here is a blessing:
     5  #
     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.
     9  #
    10  #*************************************************************************
    11  #
    12  #
    13  
    14  set testdir [file dirname $argv0]
    15  source $testdir/tester.tcl
    16  source $testdir/fts3_common.tcl
    17  set testprefix fts3corrupt5
    18  
    19  # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    20  ifcapable !fts3 {
    21    finish_test
    22    return
    23  }
    24  
    25  sqlite3_fts3_may_be_corrupt 1
    26  
    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;
    32  }
    33  
    34  do_execsql_test 1.1 {
    35    SELECT * FROM ft WHERE ft MATCH 'b:one'
    36  } {one one one}
    37  
    38  do_execsql_test 1.2 {
    39    SELECT quote(root) FROM ft_segdir;
    40  } {X'00036F6E6509010201010201020200'}
    41  
    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"
    51  
    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
    57  }
    58  
    59  finish_test