2003-01-06 00:48:59 +01:00
--disable_warnings
2001-01-03 01:15:48 +01:00
DROP TABLE IF EXISTS t1;
2003-01-06 00:48:59 +01:00
--enable_warnings
2001-01-03 01:15:48 +01:00
CREATE TABLE t1 (
2000-12-11 14:09:31 +01:00
a INT AUTO_INCREMENT PRIMARY KEY,
message CHAR(20),
FULLTEXT(message)
2000-12-12 13:17:29 +01:00
) comment = 'original testcase by sroussey@network54.com';
2001-01-03 01:15:48 +01:00
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"),
2000-12-11 14:09:31 +01:00
("steve"),("is"),("cool"),("steve is cool");
2000-12-12 13:17:29 +01:00
# basic MATCH
2004-09-15 20:47:45 +02:00
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve');
2001-11-22 16:00:11 +01:00
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve');
2004-09-15 20:47:45 +02:00
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
2001-11-22 16:00:11 +01:00
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE);
2000-12-30 16:24:31 +01:00
2000-12-15 00:09:53 +01:00
# MATCH + ORDER BY (with ft-ranges)
2004-09-15 20:47:45 +02:00
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a;
2001-11-22 16:00:11 +01:00
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a;
2000-12-30 16:24:31 +01:00
2000-12-15 00:09:53 +01:00
# MATCH + ORDER BY (with normal ranges) + UNIQUE
2004-09-15 20:47:45 +02:00
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;
2001-11-22 16:00:11 +01:00
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;
2000-12-30 16:24:31 +01:00
2000-12-12 13:17:29 +01:00
# MATCH + ORDER BY + UNIQUE (const_table)
2004-09-15 20:47:45 +02:00
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1;
2001-11-22 16:00:11 +01:00
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;
2000-12-30 16:24:31 +01:00
2000-12-12 13:17:29 +01:00
# ORDER BY MATCH
2004-09-15 20:47:45 +02:00
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel;
2001-11-22 16:00:11 +01:00
SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel;
2001-01-03 01:15:48 +01:00
2005-03-08 19:45:55 +01:00
#
# BUG#6635 - test_if_skip_sort_order() thought it can skip filesort
# for fulltext searches too
#
alter table t1 add key m (message);
explain SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message;
SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message desc;
2001-01-03 01:15:48 +01:00
drop table t1;
2002-09-17 21:04:10 +02:00
#
# reused boolean scan bug
#
CREATE TABLE t1 (
a INT AUTO_INCREMENT PRIMARY KEY,
message CHAR(20),
FULLTEXT(message)
);
INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar");
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1;
SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a;
drop table t1;
2005-07-14 17:19:26 +02:00
# BUG#11869
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
thread int(11) NOT NULL default '0',
beitrag longtext NOT NULL,
PRIMARY KEY (id),
KEY thread (thread),
FULLTEXT KEY beitrag (beitrag)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ;
CREATE TABLE t2 (
id int(11) NOT NULL auto_increment,
text varchar(100) NOT NULL default '',
PRIMARY KEY (id),
KEY text (text)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ;
CREATE TABLE t3 (
id int(11) NOT NULL auto_increment,
forum int(11) NOT NULL default '0',
betreff varchar(70) NOT NULL default '',
PRIMARY KEY (id),
KEY forum (forum),
FULLTEXT KEY betreff (betreff)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
--error 1109
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(b.betreff) against ('+abc' in boolean mode)
group by a.text, b.id, b.betreff
union
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(c.beitrag) against ('+abc' in boolean mode)
group by
a.text, b.id, b.betreff
order by
match(b.betreff) against ('+abc' in boolean mode) desc;
--error 1109
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(b.betreff) against ('+abc' in boolean mode)
union
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(c.beitrag) against ('+abc' in boolean mode)
order by
match(b.betreff) against ('+abc' in boolean mode) desc;
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(b.betreff) against ('+abc' in boolean mode)
union
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
t1 c on b.id = c.thread
where
match(c.beitrag) against ('+abc' in boolean mode)
order by
match(betreff) against ('+abc' in boolean mode) desc;
drop table t1,t2,t3;
2005-07-28 02:22:47 +02:00
# End of 4.1 tests