~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
--disable_warnings
2
DROP TABLE IF EXISTS t1,t2,t3;
3
--enable_warnings
4
5
CREATE TABLE t1 (
6
  a INT AUTO_INCREMENT PRIMARY KEY,
7
  message CHAR(20),
8
  FULLTEXT(message)
9
) comment = 'original testcase by sroussey@network54.com';
10
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"),
11
        ("steve"),("is"),("cool"),("steve is cool");
12
# basic MATCH
13
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve');
14
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
15
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
16
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
17
18
# MATCH + ORDER BY (with ft-ranges)
19
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
20
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
21
22
# MATCH + ORDER BY (with normal ranges) + UNIQUE
23
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC;
24
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC;
25
26
# MATCH + ORDER BY + UNIQUE (const_table)
27
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
28
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1;
29
30
# ORDER BY MATCH
31
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel;
32
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
33
34
#
35
# BUG#6635 - test_if_skip_sort_order() thought it can skip filesort
36
# for fulltext searches too
37
#
38
alter table t1 add key m (message);
39
explain SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message;
40
SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message desc;
41
42
drop table t1;
43
44
#
45
# reused boolean scan bug
46
#
47
CREATE TABLE t1 (
48
  a INT AUTO_INCREMENT PRIMARY KEY,
49
  message CHAR(20),
50
  FULLTEXT(message)
51
);
52
INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar");
53
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1;
54
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a;
55
drop table t1;
56
57
# BUG#11869
58
CREATE TABLE t1 (
59
  id int(11) NOT NULL auto_increment,
60
  thread int(11) NOT NULL default '0',
61
  beitrag longtext NOT NULL,
62
  PRIMARY KEY  (id),
63
  KEY thread (thread),
64
  FULLTEXT KEY beitrag (beitrag)
65
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ;
66
67
CREATE TABLE t2 (
68
  id int(11) NOT NULL auto_increment,
69
  text varchar(100) NOT NULL default '',
70
  PRIMARY KEY  (id),
71
  KEY text (text)
72
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ;
73
74
CREATE TABLE t3 (
75
  id int(11) NOT NULL auto_increment,
76
  forum int(11) NOT NULL default '0',
77
  betreff varchar(70) NOT NULL default '',
78
  PRIMARY KEY  (id),
79
  KEY forum (forum),
80
  FULLTEXT KEY betreff (betreff)
81
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
82
83
--error 1054
84
select a.text, b.id, b.betreff
85
from 
86
  t2 a inner join t3 b on a.id = b.forum inner join
87
  t1 c on b.id = c.thread
88
where 
89
  match(b.betreff) against ('+abc' in boolean mode)
90
group by a.text, b.id, b.betreff
91
union
92
select a.text, b.id, b.betreff
93
from 
94
  t2 a inner join t3 b on a.id = b.forum inner join
95
  t1 c on b.id = c.thread
96
where 
97
  match(c.beitrag) against ('+abc' in boolean mode)
98
group by 
99
  a.text, b.id, b.betreff
100
order by 
101
  match(b.betreff) against ('+abc' in boolean mode) desc;
102
  
103
--error 1054
104
select a.text, b.id, b.betreff
105
from 
106
  t2 a inner join t3 b on a.id = b.forum inner join
107
  t1 c on b.id = c.thread
108
where 
109
  match(b.betreff) against ('+abc' in boolean mode)
110
union
111
select a.text, b.id, b.betreff
112
from 
113
  t2 a inner join t3 b on a.id = b.forum inner join
114
  t1 c on b.id = c.thread
115
where 
116
  match(c.beitrag) against ('+abc' in boolean mode)
117
order by 
118
  match(b.betreff) against ('+abc' in boolean mode) desc;
119
120
select a.text, b.id, b.betreff
121
from 
122
  t2 a inner join t3 b on a.id = b.forum inner join
123
  t1 c on b.id = c.thread
124
where 
125
  match(b.betreff) against ('+abc' in boolean mode)
126
union
127
select a.text, b.id, b.betreff
128
from 
129
  t2 a inner join t3 b on a.id = b.forum inner join
130
  t1 c on b.id = c.thread
131
where 
132
  match(c.beitrag) against ('+abc' in boolean mode)
133
order by 
134
  match(betreff) against ('+abc' in boolean mode) desc;
135
136
# BUG#11869 part2: used table type doesn't support FULLTEXT indexes error
137
(select b.id, b.betreff from t3 b) union 
138
(select b.id, b.betreff from t3 b) 
139
order by match(betreff) against ('+abc' in boolean mode) desc;
140
141
--error 1191
142
(select b.id, b.betreff from t3 b) union 
143
(select b.id, b.betreff from t3 b) 
144
order by match(betreff) against ('+abc') desc;
145
146
select distinct b.id, b.betreff from t3 b 
147
order by match(betreff) against ('+abc' in boolean mode) desc;
148
149
select b.id, b.betreff from t3 b group by b.id+1 
150
order by match(betreff) against ('+abc' in boolean mode) desc;
151
152
drop table t1,t2,t3;
153
154
# End of 4.1 tests