blob: fb877737f4ef88b20fb995c0c5a9d74d410fee29 [file] [log] [blame]
dan16690ed2011-02-03 10:56:00 +00001# 2011 February 3
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
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15set ::testprefix fts3fault2
16
dan60939d02011-03-29 15:40:55 +000017# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
18ifcapable !fts3 { finish_test ; return }
19
dan16690ed2011-02-03 10:56:00 +000020do_test 1.0 {
21 execsql {
22 CREATE VIRTUAL TABLE t1 USING fts4(x);
23 INSERT INTO t1 VALUES('a b c');
24 INSERT INTO t1 VALUES('c d e');
25 CREATE VIRTUAL TABLE terms USING fts4aux(t1);
26 }
27 faultsim_save_and_close
28} {}
29
30do_faultsim_test 1.1 -prep {
31 faultsim_restore_and_reopen
32 db eval {SELECT * FROM sqlite_master}
33} -body {
34 execsql "CREATE VIRTUAL TABLE terms2 USING fts4aux(t1)"
35} -test {
36 faultsim_test_result {0 {}}
37}
38
39do_faultsim_test 1.2 -prep {
40 faultsim_restore_and_reopen
41 db eval {SELECT * FROM sqlite_master}
42} -body {
43 execsql "SELECT * FROM terms"
44} -test {
danbb7e77c2011-02-05 14:37:57 +000045 faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 2 2 c 0 2 2 d * 1 1 d 0 1 1 e * 1 1 e 0 1 1}}
dan16690ed2011-02-03 10:56:00 +000046}
47
48do_faultsim_test 1.3 -prep {
49 faultsim_restore_and_reopen
50 db eval {SELECT * FROM sqlite_master}
51} -body {
52 execsql "SELECT * FROM terms WHERE term>'a' AND TERM < 'd'"
53} -test {
danbb7e77c2011-02-05 14:37:57 +000054 faultsim_test_result {0 {b * 1 1 b 0 1 1 c * 2 2 c 0 2 2}}
dan16690ed2011-02-03 10:56:00 +000055}
56
57do_faultsim_test 1.4 -prep {
58 faultsim_restore_and_reopen
59 db eval {SELECT * FROM sqlite_master}
60} -body {
61 execsql "SELECT * FROM terms WHERE term='c'"
62} -test {
danbb7e77c2011-02-05 14:37:57 +000063 faultsim_test_result {0 {c * 2 2 c 0 2 2}}
dan16690ed2011-02-03 10:56:00 +000064}
65
danbb7e77c2011-02-05 14:37:57 +000066do_test 2.0 {
67 faultsim_delete_and_reopen
68 execsql {
69 CREATE VIRTUAL TABLE tx USING fts4(a, b);
70 INSERT INTO tx VALUES('a b c', 'x y z');
71 CREATE VIRTUAL TABLE terms2 USING fts4aux(tx);
72 }
73 faultsim_save_and_close
74} {}
dan16690ed2011-02-03 10:56:00 +000075
danbb7e77c2011-02-05 14:37:57 +000076do_faultsim_test 2.1 -prep {
77 faultsim_restore_and_reopen
78 db eval {SELECT * FROM sqlite_master}
79} -body {
80 execsql "SELECT * FROM terms2"
81} -test {
82 faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}}
83}
dan16690ed2011-02-03 10:56:00 +000084
85finish_test