| 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 not 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 |
sqlite3_db_config db DEFENSIVE 0 |
| 43 |
do_execsql_test 1.5 { |
| 44 |
DELETE FROM f1_data; |
| 45 |
} {} |
| 46 |
|
| 47 |
do_catchsql_test 1.6 { |
| 48 |
INSERT INTO f1(f1) VALUES('integrity-check'); |
| 49 |
} {/.*fts5: corrupt.*/} |
| 50 |
|
| 51 |
do_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 |
# |
| 60 |
do_execsql_test 2.1 { |
| 61 |
CREATE VIRTUAL TABLE nc USING fts5(doc, content=); |
| 62 |
} |
| 63 |
|
| 64 |
do_catchsql_test 2.2 { |
| 65 |
INSERT INTO nc(nc) VALUES('rebuild'); |
| 66 |
} {1 {'rebuild' may not be used with a contentless fts5 table}} |
| 67 |
finish_test |