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 #***********************************************************************
12 # The tests in this file focus on testing that unrecognized file-format
13 # versions are detected and reported.
16 source [file join [file dirname [info script]] fts5_common.tcl]
17 set testprefix fts5version
19 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
27 CREATE VIRTUAL TABLE t1 USING fts5(one);
28 INSERT INTO t1 VALUES('a b c d');
32 SELECT * FROM t1_config WHERE k='version'
36 SELECT rowid FROM t1 WHERE t1 MATCH 'a';
39 sqlite3_db_config db DEFENSIVE 0
41 UPDATE t1_config set v=6 WHERE k='version';
47 catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }
48 } {1 {invalid fts5 file format (found 6, expected 4 or 5) - run 'rebuild'}}
53 catchsql { INSERT INTO t1 VALUES('x y z') }
54 } {1 {invalid fts5 file format (found 6, expected 4 or 5) - run 'rebuild'}}
57 sqlite3_db_config db DEFENSIVE 0
58 execsql { DELETE FROM t1_config WHERE k='version' }
61 catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }
62 } {1 {invalid fts5 file format (found 0, expected 4 or 5) - run 'rebuild'}}
65 sqlite3_db_config db DEFENSIVE 0
66 execsql { INSERT INTO t1_config VALUES('version', 4) }
67 execsql { INSERT INTO t1(t1, rank) VALUES('secure-delete', 1) }
70 do_execsql_test 1.10 {
71 SELECT * FROM t1_config
72 } {secure-delete 1 version 4}
74 do_execsql_test 1.11 {
75 INSERT INTO t1(rowid, one) VALUES(123, 'one two three');
76 DELETE FROM t1 WHERE rowid=123;
77 SELECT * FROM t1_config
78 } {secure-delete 1 version 5}
80 do_execsql_test 1.11 {
81 INSERT INTO t1(t1) VALUES('rebuild');
82 SELECT * FROM t1_config
83 } {secure-delete 1 version 4}
85 do_execsql_test 1.12 {
86 SELECT * FROM t1_config
87 } {secure-delete 1 version 4}
89 #-------------------------------------------------------------------------
93 CREATE VIRTUAL TABLE xyz USING fts5(x);
94 INSERT INTO xyz(rowid, x) VALUES
97 (3, 'three document'),
102 INSERT INTO xyz(xyz, rank) VALUES('secure-delete', 1);
103 SELECT v FROM xyz_config WHERE k='version';
106 do_execsql_test 2.1 {
108 INSERT INTO xyz(rowid, x) VALUES(7, 'seven document');
110 DELETE FROM xyz WHERE rowid = 4;
113 do_execsql_test 2.2 {
114 SELECT v FROM xyz_config WHERE k='version';
117 do_execsql_test 2.3 {
119 SELECT v FROM xyz_config WHERE k='version';
123 do_execsql_test 2.4 {
124 DELETE FROM xyz WHERE rowid = 3;
126 SELECT v FROM xyz_config WHERE k='version';