aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test
diff options
context:
space:
mode:
authordan miller2007-10-20 02:49:29 +0000
committerdan miller2007-10-20 02:49:29 +0000
commite36d23a85ebff914d74bb541558c2b6082b78edb (patch)
tree54b58fdf162e78af64055282a6035c8d2443389d /libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test
parent* Fixed an issue whereby avatar chat distances were being calculated against ... (diff)
downloadopensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.zip
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.gz
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.bz2
opensim-SC-e36d23a85ebff914d74bb541558c2b6082b78edb.tar.xz
sqlite source (unix build) added to libraries
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test138
1 files changed, 138 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test b/libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test
new file mode 100644
index 0000000..92666c6
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/fts1o.test
@@ -0,0 +1,138 @@
1# 2007 July 24
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# This file implements regression tests for SQLite library. The focus
12# of this script is testing the FTS1 module rename functionality. Mostly
13# copied from fts2o.test.
14#
15# $Id: fts1o.test,v 1.2 2007/08/30 20:01:33 shess Exp $
16#
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21# If SQLITE_ENABLE_FTS1 is not defined, omit this file.
22ifcapable !fts1 {
23 finish_test
24 return
25}
26
27db eval {
28 CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);
29 INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');
30}
31
32#---------------------------------------------------------------------
33# Test that it is possible to rename an fts1 table.
34#
35do_test fts1o-1.1 {
36 execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
37} {t1 t1_content t1_term}
38do_test fts1o-1.2 {
39 execsql { ALTER TABLE t1 RENAME to fts_t1; }
40} {}
41do_test fts1o-1.3 {
42 execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
43} {1 {one three <b>four</b>}}
44do_test fts1o-1.4 {
45 execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
46} {fts_t1 fts_t1_content fts_t1_term}
47
48# See what happens when renaming the fts1 table fails.
49#
50do_test fts1o-2.1 {
51 catchsql {
52 CREATE TABLE t1_term(a, b, c);
53 ALTER TABLE fts_t1 RENAME to t1;
54 }
55} {1 {SQL logic error or missing database}}
56do_test fts1o-2.2 {
57 execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
58} {1 {one three <b>four</b>}}
59do_test fts1o-2.3 {
60 execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
61} {fts_t1 fts_t1_content fts_t1_term t1_term}
62
63# See what happens when renaming the fts1 table fails inside a transaction.
64#
65do_test fts1o-3.1 {
66 execsql {
67 BEGIN;
68 INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');
69 }
70} {}
71do_test fts1o-3.2 {
72 catchsql {
73 ALTER TABLE fts_t1 RENAME to t1;
74 }
75} {1 {SQL logic error or missing database}}
76# NOTE(shess) rowid AS rowid to defeat caching. Otherwise, this
77# seg-faults, I suspect that there's something up with a stale
78# virtual-table reference, but I'm not quite sure how it happens here
79# but not for fts2o.test.
80do_test fts1o-3.3 {
81 execsql { SELECT rowid AS rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }
82} {1 {one three <b>four</b>}}
83do_test fts1o-3.4 {
84 execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}
85} {fts_t1 fts_t1_content fts_t1_term t1_term}
86do_test fts1o-3.5 {
87 execsql COMMIT
88 execsql {SELECT a FROM fts_t1}
89} {{one three four} {one two three}}
90do_test fts1o-3.6 {
91 execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }
92} {{one three four} {one four} {one four two}}
93
94#---------------------------------------------------------------------
95# Test that it is possible to rename an fts1 table in an attached
96# database.
97#
98file delete -force test2.db test2.db-journal
99
100do_test fts1o-4.1 {
101 execsql {
102 DROP TABLE t1_term;
103 ALTER TABLE fts_t1 RENAME to t1;
104 SELECT a, b, c FROM t1 WHERE c MATCH 'two';
105 }
106} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
107
108do_test fts1o-4.2 {
109 execsql {
110 ATTACH 'test2.db' AS aux;
111 CREATE VIRTUAL TABLE aux.t1 USING fts1(a, b, c);
112 INSERT INTO aux.t1(a, b, c) VALUES(
113 'neung song sahm', 'neung see', 'neung see song'
114 );
115 }
116} {}
117
118do_test fts1o-4.3 {
119 execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }
120} {{neung song sahm} {neung see} {neung see song}}
121
122do_test fts1o-4.4 {
123 execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
124} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
125
126do_test fts1o-4.5 {
127 execsql { ALTER TABLE aux.t1 RENAME TO t2 }
128} {}
129
130do_test fts1o-4.6 {
131 execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }
132} {{neung song sahm} {neung see} {neung see song}}
133
134do_test fts1o-4.7 {
135 execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }
136} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}
137
138finish_test