Commit a05a566c authored by Sergey Petrunya's avatar Sergey Petrunya

BUG#906357: Incorrect result with outer join and full text match

- The problem was that const-table-reading code would try to evaluate MATCH()
  before init_ftfuncs() was called. 
- Fixed by making MATCH function "expensive" so that nobody tries to evaluate it
  at optimization phase.
parent 15ea7238
......@@ -97,3 +97,17 @@ INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle');
SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE);
a b c
DROP TABLE t1, t2;
#
# BUG#906357: Incorrect result with outer join and full text match
#
CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1));
INSERT INTO t1 VALUES ('test');
CREATE TABLE t2(f2 VARCHAR(6) NOT NULL, FULLTEXT KEY(f2), UNIQUE(f2));
INSERT INTO t2 VALUES ('test');
SELECT * FROM t2 LEFT OUTER JOIN t1 ON (MATCH(f1) against (""));
f2 f1
test NULL
SELECT * FROM t1 RIGHT OUTER JOIN t2 ON (MATCH(f1) against (""));
f1 f2
NULL test
DROP table t1,t2;
......@@ -46,10 +46,10 @@ a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE)
7 1
SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel;
a rel
1 0.000000
2 0.000000
3 0.000000
1 0.000000
5 0.000000
2 0.000000
6 0.000000
7 0.895690
4 0.905873
......
......@@ -98,3 +98,16 @@ INSERT INTO t1 VALUES(1);
INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle');
SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE);
DROP TABLE t1, t2;
--echo #
--echo # BUG#906357: Incorrect result with outer join and full text match
--echo #
CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1));
INSERT INTO t1 VALUES ('test');
CREATE TABLE t2(f2 VARCHAR(6) NOT NULL, FULLTEXT KEY(f2), UNIQUE(f2));
INSERT INTO t2 VALUES ('test');
SELECT * FROM t2 LEFT OUTER JOIN t1 ON (MATCH(f1) against (""));
SELECT * FROM t1 RIGHT OUTER JOIN t2 ON (MATCH(f1) against (""));
DROP table t1,t2;
......@@ -1676,6 +1676,7 @@ public:
table= 0; // required by Item_func_match::eq()
DBUG_VOID_RETURN;
}
bool is_expensive_processor(uchar *arg) { return TRUE; }
enum Functype functype() const { return FT_FUNC; }
const char *func_name() const { return "match"; }
void update_used_tables() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment