/ Check-in [34190449]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add extra tests for RBU and FTS3/4.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3419044967258e3ed65f71528e06952ee102dcc7
User & Date: dan 2015-08-01 18:18:21
Context
2015-08-03
13:44
Allow a VIEW to reference undefined tables and functions when initially created. The error report is deferred until the VIEW is used. This allows views to be created before subviews and tables that the view references. check-in: 70b57daf user: drh tags: trunk
2015-08-01
18:18
Add extra tests for RBU and FTS3/4. check-in: 34190449 user: dan tags: trunk
2015-07-31
19:52
Add support for "fossil deltas" to RBU and "sqldiff --rbu". check-in: e26ef165 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rbu/rbufts.test.

    30     30       set rc [rbu step]
    31     31       rbu close
    32     32       if {$rc != "SQLITE_OK"} break
    33     33     }
    34     34     set rc
    35     35   }
    36     36   
    37         -do_execsql_test 1.0 {
           37  +proc apply_rbu_update {target sql} {
           38  +  forcedelete rbu.db
           39  +  sqlite3 dbrbu rbu.db
           40  +  execsql $sql dbrbu
           41  +  dbrbu close
           42  +
           43  +  step_rbu $target rbu.db
           44  +}
           45  +
           46  +do_execsql_test 1.1.0 {
    38     47     CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);
    39     48     CREATE VIRTUAL TABLE xx USING fts4(content=t1, a, b);
    40     49     INSERT INTO t1(rowid, a, b) VALUES(10, 'a b c', 'c b a');
    41     50     INSERT INTO t1(rowid, a, b) VALUES(20, 'a b c', 'd e f');
    42     51     INSERT INTO t1(rowid, a, b) VALUES(30, 'd e f', 'a b c');
    43     52     INSERT INTO t1(rowid, a, b) VALUES(40, 'd e f', 'd e f');
    44     53   }
    45     54   
    46         -do_execsql_test 1.1 {
           55  +do_execsql_test 1.1.1 {
    47     56     INSERT INTO xx(xx) VALUES('rebuild');
    48     57     INSERT INTO xx(xx) VALUES('integrity-check');
    49     58   }
    50     59   
    51         -forcedelete rbu.db
    52         -do_test 2.0 {
    53         -  sqlite3 dbrbu rbu.db
    54         -  dbrbu eval {
           60  +do_test 1.1.2 {
           61  +  apply_rbu_update test.db {
    55     62       CREATE TABLE data_t1(i, a, b, rbu_control);
    56     63       INSERT INTO data_t1 VALUES(20, NULL, NULL, 1);        -- delete
    57     64       INSERT INTO data_t1 VALUES(30, 'x y z', NULL, '.x.'); -- update
    58     65       INSERT INTO data_t1 VALUES(50, '1 2 3', 'x y z', 0);  -- insert
    59     66   
    60     67       CREATE VIEW data0_xx AS 
    61     68       SELECT i AS rbu_rowid, a, b, 
    62     69       CASE WHEN rbu_control IN (0, 1) 
    63     70       THEN rbu_control ELSE substr(rbu_control, 2) END AS rbu_control
    64     71       FROM data_t1;
    65         -
    66     72     }
    67         -  dbrbu close
    68         -
    69         -  step_rbu test.db rbu.db
    70     73   } {SQLITE_DONE}
    71     74   
    72         -do_execsql_test 2.1 {
           75  +do_execsql_test 1.1.3 {
    73     76     INSERT INTO xx(xx) VALUES('integrity-check');
    74     77   }
    75     78   
           79  +reset_db
           80  +do_execsql_test 1.2.1 {
           81  +  CREATE TABLE ccc(addr, text);
           82  +  CREATE VIRTUAL TABLE ccc_fts USING fts4(addr, text, content=ccc);
           83  +  INSERT INTO ccc VALUES('a b c', 'd e f');
           84  +  INSERT INTO ccc VALUES('a b c', 'd e f');
           85  +  INSERT INTO ccc_fts(ccc_fts) VALUES('rebuild');
           86  +  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');
           87  +}
           88  +
           89  +do_test 1.2.2 {
           90  +  apply_rbu_update test.db {
           91  +    CREATE TABLE data_ccc(addr, text, rbu_rowid, rbu_control);
           92  +    CREATE VIEW data0_ccc_fts AS SELECT * FROM data_ccc;
           93  +    INSERT INTO data_ccc VALUES(NULL, NULL, 1, 1);
           94  +    INSERT INTO data_ccc VALUES('x y z', NULL, 2, 'x.');
           95  +    INSERT INTO data_ccc VALUES('y y y', '1 1 1', 3, 0);
           96  +  }
           97  +} {SQLITE_DONE}
           98  +
           99  +do_execsql_test 1.2.3 {
          100  +  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');
          101  +}
          102  +do_execsql_test 1.2.4 {
          103  +  SELECT rowid, * FROM ccc_fts;
          104  +} {2 {x y z} {d e f} 3 {y y y} {1 1 1}}
          105  +
          106  +#-------------------------------------------------------------------------
          107  +# Test the outcome of attempting to delete or update a row within a 
          108  +# contentless FTS table using RBU. An error.
          109  +#
          110  +reset_db
          111  +do_execsql_test 3.1 {
          112  +  CREATE VIRTUAL TABLE ft USING fts4(x, content=);
          113  +  INSERT INTO ft(rowid, x) VALUES(1, '1 2 3');
          114  +  INSERT INTO ft(rowid, x) VALUES(2, '4 5 6');
          115  +}
          116  +
          117  +do_test 3.2 {
          118  +  list [catch { apply_rbu_update test.db {
          119  +    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);
          120  +    INSERT INTO data_ft VALUES(NULL, 2, 1);
          121  +  } } msg] $msg]
          122  +} {1 {SQLITE_ERROR - SQL logic error or missing database]}}
          123  +
          124  +do_test 3.3 {
          125  +  list [catch { apply_rbu_update test.db {
          126  +    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);
          127  +    INSERT INTO data_ft VALUES('7 8 9', 1, 'x');
          128  +  } } msg] $msg]
          129  +} {1 {SQLITE_ERROR - SQL logic error or missing database]}}
    76    130   
    77    131   
    78    132   
    79    133   finish_test
    80    134