SQLite

Check-in [3419044967]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3419044967258e3ed65f71528e06952ee102dcc7
User & Date: dan 2015-08-01 18:18:21.762
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: 70b57dafb3 user: drh tags: trunk)
2015-08-01
18:18
Add extra tests for RBU and FTS3/4. (check-in: 3419044967 user: dan tags: trunk)
2015-07-31
19:52
Add support for "fossil deltas" to RBU and "sqldiff --rbu". (check-in: e26ef165fe user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to ext/rbu/rbufts.test.
30
31
32
33
34
35
36









37

38
39
40
41
42
43
44
45
46

47
48
49
50
51
52

53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

























70
71
72
73


74



75
























76
77
78
79
80
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54

55
56
57
58
59


60


61
62
63
64
65
66
67
68
69
70
71





72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134







+
+
+
+
+
+
+
+
+
-
+








-
+




-
-
+
-
-
+










-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
-
+
+

+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





    set rc [rbu step]
    rbu close
    if {$rc != "SQLITE_OK"} break
  }
  set rc
}

proc apply_rbu_update {target sql} {
  forcedelete rbu.db
  sqlite3 dbrbu rbu.db
  execsql $sql dbrbu
  dbrbu close

  step_rbu $target rbu.db
}

do_execsql_test 1.0 {
do_execsql_test 1.1.0 {
  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);
  CREATE VIRTUAL TABLE xx USING fts4(content=t1, a, b);
  INSERT INTO t1(rowid, a, b) VALUES(10, 'a b c', 'c b a');
  INSERT INTO t1(rowid, a, b) VALUES(20, 'a b c', 'd e f');
  INSERT INTO t1(rowid, a, b) VALUES(30, 'd e f', 'a b c');
  INSERT INTO t1(rowid, a, b) VALUES(40, 'd e f', 'd e f');
}

do_execsql_test 1.1 {
do_execsql_test 1.1.1 {
  INSERT INTO xx(xx) VALUES('rebuild');
  INSERT INTO xx(xx) VALUES('integrity-check');
}

forcedelete rbu.db
do_test 2.0 {
do_test 1.1.2 {
  sqlite3 dbrbu rbu.db
  dbrbu eval {
  apply_rbu_update test.db {
    CREATE TABLE data_t1(i, a, b, rbu_control);
    INSERT INTO data_t1 VALUES(20, NULL, NULL, 1);        -- delete
    INSERT INTO data_t1 VALUES(30, 'x y z', NULL, '.x.'); -- update
    INSERT INTO data_t1 VALUES(50, '1 2 3', 'x y z', 0);  -- insert

    CREATE VIEW data0_xx AS 
    SELECT i AS rbu_rowid, a, b, 
    CASE WHEN rbu_control IN (0, 1) 
    THEN rbu_control ELSE substr(rbu_control, 2) END AS rbu_control
    FROM data_t1;

  }
  dbrbu close

  step_rbu test.db rbu.db
  }
} {SQLITE_DONE}

do_execsql_test 1.1.3 {
  INSERT INTO xx(xx) VALUES('integrity-check');
}

reset_db
do_execsql_test 1.2.1 {
  CREATE TABLE ccc(addr, text);
  CREATE VIRTUAL TABLE ccc_fts USING fts4(addr, text, content=ccc);
  INSERT INTO ccc VALUES('a b c', 'd e f');
  INSERT INTO ccc VALUES('a b c', 'd e f');
  INSERT INTO ccc_fts(ccc_fts) VALUES('rebuild');
  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');
}

do_test 1.2.2 {
  apply_rbu_update test.db {
    CREATE TABLE data_ccc(addr, text, rbu_rowid, rbu_control);
    CREATE VIEW data0_ccc_fts AS SELECT * FROM data_ccc;
    INSERT INTO data_ccc VALUES(NULL, NULL, 1, 1);
    INSERT INTO data_ccc VALUES('x y z', NULL, 2, 'x.');
    INSERT INTO data_ccc VALUES('y y y', '1 1 1', 3, 0);
  }
} {SQLITE_DONE}

do_execsql_test 2.1 {
  INSERT INTO xx(xx) VALUES('integrity-check');
do_execsql_test 1.2.3 {
  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');
}
do_execsql_test 1.2.4 {
  SELECT rowid, * FROM ccc_fts;
} {2 {x y z} {d e f} 3 {y y y} {1 1 1}}

#-------------------------------------------------------------------------
# Test the outcome of attempting to delete or update a row within a 
# contentless FTS table using RBU. An error.
#
reset_db
do_execsql_test 3.1 {
  CREATE VIRTUAL TABLE ft USING fts4(x, content=);
  INSERT INTO ft(rowid, x) VALUES(1, '1 2 3');
  INSERT INTO ft(rowid, x) VALUES(2, '4 5 6');
}

do_test 3.2 {
  list [catch { apply_rbu_update test.db {
    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);
    INSERT INTO data_ft VALUES(NULL, 2, 1);
  } } msg] $msg]
} {1 {SQLITE_ERROR - SQL logic error or missing database]}}

do_test 3.3 {
  list [catch { apply_rbu_update test.db {
    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);
    INSERT INTO data_ft VALUES('7 8 9', 1, 'x');
  } } msg] $msg]
} {1 {SQLITE_ERROR - SQL logic error or missing database]}}



finish_test