~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/fulltext_order_by.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 ER_CANT_USE_OPTION_HERE
 
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 ER_CANT_USE_OPTION_HERE
 
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
--error ER_CANT_USE_OPTION_HERE
 
121
select a.text, b.id, b.betreff
 
122
from 
 
123
  t2 a inner join t3 b on a.id = b.forum inner join
 
124
  t1 c on b.id = c.thread
 
125
where 
 
126
  match(b.betreff) against ('+abc' in boolean mode)
 
127
union
 
128
select a.text, b.id, b.betreff
 
129
from 
 
130
  t2 a inner join t3 b on a.id = b.forum inner join
 
131
  t1 c on b.id = c.thread
 
132
where 
 
133
  match(c.beitrag) against ('+abc' in boolean mode)
 
134
order by 
 
135
  match(betreff) against ('+abc' in boolean mode) desc;
 
136
 
 
137
# BUG#11869 part2: used table type doesn't support FULLTEXT indexes error
 
138
(select b.id, b.betreff from t3 b) union 
 
139
(select b.id, b.betreff from t3 b) 
 
140
order by match(betreff) against ('+abc' in boolean mode) desc;
 
141
 
 
142
--error 1191
 
143
(select b.id, b.betreff from t3 b) union 
 
144
(select b.id, b.betreff from t3 b) 
 
145
order by match(betreff) against ('+abc') desc;
 
146
 
 
147
select distinct b.id, b.betreff from t3 b 
 
148
order by match(betreff) against ('+abc' in boolean mode) desc;
 
149
 
 
150
select b.id, b.betreff from t3 b group by b.id+1 
 
151
order by match(betreff) against ('+abc' in boolean mode) desc;
 
152
 
 
153
drop table t1,t2,t3;
 
154
 
 
155
# End of 4.1 tests