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;