summaryrefslogtreecommitdiffstats
path: root/test/fts3aux2.test
blob: 95540225590b1cd67069b7b8d08c782b45942a9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# 2011 January 27
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the FTS3 module.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !fts3 { finish_test ; return }
set ::testprefix fts3aux2

do_execsql_test 1.1 {
  CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=l);
  INSERT INTO t1(a, b, l) VALUES
    ('zero zero', 'zero zero', 0),
    ('one two', 'three four', 1),
    ('five six', 'seven eight', 2)
  ;
  CREATE VIRTUAL TABLE terms USING fts4aux(t1);
} {}

do_execsql_test 1.2.1 {
  SELECT term, documents, occurrences, languageid FROM terms WHERE col = '*';
} {zero 1 4 0}

do_execsql_test 1.2.2 {
  SELECT * FROM terms;
} {zero * 1 4 zero 0 1 2 zero 1 1 2}

do_execsql_test 1.2.3 {
  SELECT * FROM terms WHERE languageid='';
} {}

do_execsql_test 1.2.4 {
  SELECT * FROM terms WHERE languageid=-1;
} {}

do_execsql_test 1.2.5 {
  SELECT * FROM terms WHERE languageid=9223372036854775807;
} {}

do_execsql_test 1.2.6 {
  SELECT * FROM terms WHERE languageid=-9223372036854775808;
} {}

do_execsql_test 1.2.7 {
  SELECT * FROM terms WHERE languageid=NULL;
} {}

do_execsql_test 1.3.1 {
  SELECT term, documents, occurrences, languageid 
  FROM terms WHERE col = '*' AND languageid=1;
} {
  four 1 1 1 one 1 1 1 three 1 1 1 two 1 1 1 
}

do_execsql_test 1.3.2 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid=1;
} {
  four * 1 1 1   four 1 1 1 1 
  one * 1 1 1    one 0 1 1 1 
  three * 1 1 1  three 1 1 1 1 
  two * 1 1 1    two 0 1 1 1 
}

do_execsql_test 1.3.3 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid=1 AND term='zero'
} {
}

do_execsql_test 1.3.4 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid='1' AND term='two'
} {
  two * 1 1 1    two 0 1 1 1 
}

do_execsql_test 1.3.5 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid='+1' AND term>'four'
} {
  one * 1 1 1    one 0 1 1 1 
  three * 1 1 1  three 1 1 1 1 
  two * 1 1 1    two 0 1 1 1 
}

do_execsql_test 1.4.1 {
  SELECT term, documents, occurrences, languageid 
  FROM terms WHERE col = '*' AND languageid=2;
} {
  eight 1 1 2 five 1 1 2 seven 1 1 2 six 1 1 2
}

do_execsql_test 1.4.2 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid=2;
} {
  eight * 1 1 2    eight 1 1 1 2 
  five * 1 1 2     five 0 1 1 2 
  seven * 1 1 2    seven 1 1 1 2 
  six * 1 1 2      six 0 1 1 2
}

do_execsql_test 1.4.3 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE languageid=2 AND term='five';
} {
  five * 1 1 2     five 0 1 1 2 
}

do_execsql_test 1.4.4 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE term='five' AND languageid=2 
} {
  five * 1 1 2     five 0 1 1 2 
}

do_execsql_test 1.4.5 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE term>='seven' AND languageid=2
} {
  seven * 1 1 2    seven 1 1 1 2 
  six * 1 1 2      six 0 1 1 2
}

do_execsql_test 1.4.6 {
  SELECT term, col, documents, occurrences, languageid 
  FROM terms WHERE term>='e' AND term<'seven' AND languageid=2
} {
  eight * 1 1 2    eight 1 1 1 2 
  five * 1 1 2     five 0 1 1 2 
}

#-------------------------------------------------------------------------
do_execsql_test 2.0 {
  CREATE VIRTUAL TABLE ft USING fts3();
  INSERT INTO ft VALUES('a_234567890123456789');
  INSERT INTO ft VALUES('b_234567890123456789');
  INSERT INTO ft VALUES('c_234567890123456789');
  CREATE VIRTUAL TABLE t2 USING fts4aux(ft);
}

do_execsql_test 2.1 {
  SELECT term FROM t2 WHERE term=X'625f323334353637383930313233343536373839';
}

do_execsql_test 2.2 {
  SELECT term FROM t2 WHERE term<X'625f003334353637383930313233343536373839';
} {
  234567890123456789 234567890123456789 a a b b
}

do_execsql_test 2.3 {
  SELECT term FROM t2 WHERE term=X'625f003334353637383930313233343536373839';
}


finish_test