modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5rebuild.test (about)

     1  # 2014 Dec 20
     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  source [file join [file dirname [info script]] fts5_common.tcl]
    15  set testprefix fts5rebuild
    16  
    17  # If SQLITE_ENABLE_FTS5 is defined, omit this file.
    18  ifcapable !fts5 {
    19    finish_test
    20    return
    21  }
    22  
    23  do_execsql_test 1.1 {
    24    CREATE VIRTUAL TABLE f1 USING fts5(a, b);
    25    INSERT INTO f1(a, b) VALUES('one',   'o n e');
    26    INSERT INTO f1(a, b) VALUES('two',   't w o');
    27    INSERT INTO f1(a, b) VALUES('three', 't h r e e');
    28  }
    29  
    30  do_execsql_test 1.2 {
    31    INSERT INTO f1(f1) VALUES('integrity-check');
    32  } {}
    33  
    34  do_execsql_test 1.3 {
    35    INSERT INTO f1(f1) VALUES('rebuild');
    36  } {}
    37  
    38  do_execsql_test 1.4 {
    39    INSERT INTO f1(f1) VALUES('integrity-check');
    40  } {}
    41  
    42  do_execsql_test 1.5 {
    43    DELETE FROM f1_data;
    44  } {}
    45  
    46  do_catchsql_test 1.6 {
    47    INSERT INTO f1(f1) VALUES('integrity-check');
    48  } {1 {database disk image is malformed}}
    49  
    50  do_execsql_test 1.7 {
    51    INSERT INTO f1(f1) VALUES('rebuild');
    52    INSERT INTO f1(f1) VALUES('integrity-check');
    53  } {}
    54  
    55  
    56  #-------------------------------------------------------------------------
    57  # Check that 'rebuild' may not be used with a contentless table.
    58  #
    59  do_execsql_test 2.1 {
    60    CREATE VIRTUAL TABLE nc USING fts5(doc, content=);
    61  }
    62  
    63  do_catchsql_test 2.2 {
    64    INSERT INTO nc(nc) VALUES('rebuild');
    65  } {1 {'rebuild' may not be used with a contentless fts5 table}}
    66  finish_test