1
by brian
clean slate |
1 |
#
|
2 |
# test of new fulltext search features
|
|
3 |
#
|
|
4 |
||
5 |
#
|
|
6 |
# two-level tree
|
|
7 |
#
|
|
8 |
||
9 |
--disable_warnings |
|
10 |
DROP TABLE IF EXISTS t1; |
|
11 |
--enable_warnings |
|
12 |
||
13 |
CREATE TABLE t1 ( |
|
14 |
i int(10) unsigned not null auto_increment primary key, |
|
15 |
a varchar(255) not null, |
|
16 |
FULLTEXT KEY (a) |
|
17 |
) ENGINE=MyISAM; |
|
18 |
||
19 |
# two-level entry, second-level tree with depth 2
|
|
20 |
--disable_query_log |
|
21 |
let $1=260; |
|
22 |
while ($1) |
|
23 |
{
|
|
24 |
eval insert t1 (a) values ('aaaxxx'); |
|
25 |
dec $1; |
|
26 |
}
|
|
27 |
||
28 |
# two-level entry, second-level tree has only one page
|
|
29 |
let $1=255; |
|
30 |
while ($1) |
|
31 |
{
|
|
32 |
eval insert t1 (a) values ('aaazzz'); |
|
33 |
dec $1; |
|
34 |
}
|
|
35 |
||
36 |
# one-level entry (entries)
|
|
37 |
let $1=250; |
|
38 |
while ($1) |
|
39 |
{
|
|
40 |
eval insert t1 (a) values ('aaayyy'); |
|
41 |
dec $1; |
|
42 |
}
|
|
43 |
--enable_query_log |
|
44 |
||
45 |
# converting to two-level
|
|
46 |
repair table t1 quick; |
|
47 |
check table t1; |
|
48 |
optimize table t1; # BUG#5327 - mi_sort_index() of 2-level tree |
|
49 |
check table t1; |
|
50 |
||
51 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
52 |
select count(*) from t1 where match a against ('aaayyy'); |
|
53 |
select count(*) from t1 where match a against ('aaazzz'); |
|
54 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
55 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
56 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
57 |
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); |
|
58 |
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); |
|
59 |
||
60 |
select count(*) from t1 where match a against ('aaax*' in boolean mode); |
|
61 |
select count(*) from t1 where match a against ('aaay*' in boolean mode); |
|
62 |
select count(*) from t1 where match a against ('aaa*' in boolean mode); |
|
63 |
||
64 |
# mi_write:
|
|
65 |
||
66 |
insert t1 (a) values ('aaaxxx'),('aaayyy'); |
|
67 |
# call to enlarge_root() below
|
|
68 |
insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); |
|
69 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
70 |
select count(*) from t1 where match a against ('aaayyy'); |
|
71 |
select count(*) from t1 where match a against ('aaazzz'); |
|
72 |
||
73 |
# mi_delete
|
|
74 |
insert t1 (a) values ('aaaxxx 000000'); |
|
75 |
select count(*) from t1 where match a against ('000000'); |
|
76 |
delete from t1 where match a against ('000000'); |
|
77 |
select count(*) from t1 where match a against ('000000'); |
|
78 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
79 |
delete from t1 where match a against ('aaazzz'); |
|
80 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
81 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
82 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
83 |
# double-check without index
|
|
84 |
select count(*) from t1 where a = 'aaaxxx'; |
|
85 |
select count(*) from t1 where a = 'aaayyy'; |
|
86 |
select count(*) from t1 where a = 'aaazzz'; |
|
87 |
||
88 |
# update
|
|
89 |
insert t1 (a) values ('aaaxxx 000000'); |
|
90 |
select count(*) from t1 where match a against ('000000'); |
|
91 |
update t1 set a='aaazzz' where match a against ('000000'); |
|
92 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
93 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
94 |
update t1 set a='aaazzz' where a = 'aaaxxx'; |
|
95 |
update t1 set a='aaaxxx' where a = 'aaayyy'; |
|
96 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
97 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
98 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
99 |
||
100 |
drop table t1; |
|
101 |
||
102 |
CREATE TABLE t1 ( |
|
103 |
i int(10) unsigned not null auto_increment primary key, |
|
104 |
a varchar(255) not null, |
|
105 |
FULLTEXT KEY (a) |
|
106 |
) ENGINE=MyISAM; |
|
107 |
||
108 |
#
|
|
109 |
# now same as about but w/o repair table
|
|
110 |
# 2-level tree created by mi_write
|
|
111 |
#
|
|
112 |
||
113 |
# two-level entry, second-level tree with depth 2
|
|
114 |
--disable_query_log |
|
115 |
let $1=260; |
|
116 |
while ($1) |
|
117 |
{
|
|
118 |
eval insert t1 (a) values ('aaaxxx'); |
|
119 |
dec $1; |
|
120 |
}
|
|
121 |
let $1=255; |
|
122 |
while ($1) |
|
123 |
{
|
|
124 |
eval insert t1 (a) values ('aaazzz'); |
|
125 |
dec $1; |
|
126 |
}
|
|
127 |
let $1=250; |
|
128 |
while ($1) |
|
129 |
{
|
|
130 |
eval insert t1 (a) values ('aaayyy'); |
|
131 |
dec $1; |
|
132 |
}
|
|
133 |
--enable_query_log |
|
134 |
||
135 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
136 |
select count(*) from t1 where match a against ('aaayyy'); |
|
137 |
select count(*) from t1 where match a against ('aaazzz'); |
|
138 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
139 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
140 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
141 |
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); |
|
142 |
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); |
|
143 |
||
144 |
select count(*) from t1 where match a against ('aaax*' in boolean mode); |
|
145 |
select count(*) from t1 where match a against ('aaay*' in boolean mode); |
|
146 |
select count(*) from t1 where match a against ('aaa*' in boolean mode); |
|
147 |
||
148 |
# mi_write:
|
|
149 |
||
150 |
insert t1 (a) values ('aaaxxx'),('aaayyy'); |
|
151 |
insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); |
|
152 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
153 |
select count(*) from t1 where match a against ('aaayyy'); |
|
154 |
select count(*) from t1 where match a against ('aaazzz'); |
|
155 |
||
156 |
# mi_delete
|
|
157 |
insert t1 (a) values ('aaaxxx 000000'); |
|
158 |
select count(*) from t1 where match a against ('000000'); |
|
159 |
delete from t1 where match a against ('000000'); |
|
160 |
select count(*) from t1 where match a against ('000000'); |
|
161 |
select count(*) from t1 where match a against ('aaaxxx'); |
|
162 |
delete from t1 where match a against ('aaazzz'); |
|
163 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
164 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
165 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
166 |
# double-check without index
|
|
167 |
select count(*) from t1 where a = 'aaaxxx'; |
|
168 |
select count(*) from t1 where a = 'aaayyy'; |
|
169 |
select count(*) from t1 where a = 'aaazzz'; |
|
170 |
||
171 |
# update
|
|
172 |
insert t1 (a) values ('aaaxxx 000000'); |
|
173 |
select count(*) from t1 where match a against ('000000'); |
|
174 |
update t1 set a='aaazzz' where match a against ('000000'); |
|
175 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
176 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
177 |
update t1 set a='aaazzz' where a = 'aaaxxx'; |
|
178 |
update t1 set a='aaaxxx' where a = 'aaayyy'; |
|
179 |
select count(*) from t1 where match a against ('aaaxxx' in boolean mode); |
|
180 |
select count(*) from t1 where match a against ('aaayyy' in boolean mode); |
|
181 |
select count(*) from t1 where match a against ('aaazzz' in boolean mode); |
|
182 |
drop table t1; |
|
183 |
||
184 |
#
|
|
185 |
# BUG#11336
|
|
186 |
#
|
|
187 |
# for uca collation isalnum and strnncollsp don't agree on whether
|
|
188 |
# 0xC2A0 is a space (strnncollsp is right, isalnum is wrong).
|
|
189 |
#
|
|
190 |
# they still don't, the bug was fixed by avoiding strnncollsp
|
|
191 |
#
|
|
192 |
||
193 |
set names utf8; |
|
194 |
create table t1(a text,fulltext(a)) collate=utf8_swedish_ci; |
|
195 |
insert into t1 values('test test '),('test'),('test'),('test'), |
|
196 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
197 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
198 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
199 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
200 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
201 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
202 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
203 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
204 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
205 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
206 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
207 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
208 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
209 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), |
|
210 |
('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'); |
|
211 |
delete from t1 limit 1; |
|
212 |
||
213 |
#
|
|
214 |
# BUG#16489: utf8 + fulltext leads to corrupt index file.
|
|
215 |
#
|
|
216 |
truncate table t1; |
|
217 |
insert into t1 values('ab c d'); |
|
218 |
update t1 set a='ab c d'; |
|
219 |
select * from t1 where match a against('ab c' in boolean mode); |
|
220 |
drop table t1; |
|
221 |
set names latin1; |
|
222 |
||
223 |
# End of 4.1 tests
|
|
224 |
||
225 |
#
|
|
226 |
# BUG#19580 - FULLTEXT search produces wrong results on UTF-8 columns
|
|
227 |
#
|
|
228 |
SET NAMES utf8; |
|
229 |
CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE=MyISAM DEFAULT CHARSET=utf8; |
|
230 |
INSERT INTO t1 VALUES('„MySQL“'); |
|
231 |
SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE); |
|
232 |
DROP TABLE t1; |
|
233 |
SET NAMES latin1; |