interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / fts5 / test / fts5rebuild.test

67 lines · 1649 bytes Raw Blame History
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
14source [file join [file dirname [info script]] fts5_common.tcl]
15set testprefix fts5rebuild
16
17# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
18ifcapable !fts5 {
19 finish_test
20 return
21}
22
23do_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
30do_execsql_test 1.2 {
31 INSERT INTO f1(f1) VALUES('integrity-check');
32} {}
33
34do_execsql_test 1.3 {
35 INSERT INTO f1(f1) VALUES('rebuild');
36} {}
37
38do_execsql_test 1.4 {
39 INSERT INTO f1(f1) VALUES('integrity-check');
40} {}
41
42sqlite3_db_config db DEFENSIVE 0
43do_execsql_test 1.5 {
44 DELETE FROM f1_data;
45} {}
46
47do_catchsql_test 1.6 {
48 INSERT INTO f1(f1) VALUES('integrity-check');
49} {/.*fts5: corrupt.*/}
50
51do_execsql_test 1.7 {
52 INSERT INTO f1(f1) VALUES('rebuild');
53 INSERT INTO f1(f1) VALUES('integrity-check');
54} {}
55
56
57#-------------------------------------------------------------------------
58# Check that 'rebuild' may not be used with a contentless table.
59#
60do_execsql_test 2.1 {
61 CREATE VIRTUAL TABLE nc USING fts5(doc, content=);
62}
63
64do_catchsql_test 2.2 {
65 INSERT INTO nc(nc) VALUES('rebuild');
66} {1 {'rebuild' may not be used with a contentless fts5 table}}
67finish_test