summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-12-20 00:55:32 +0400
committerSergey Petrunya <psergey@askmonty.org>2011-12-20 00:55:32 +0400
commita05a566cf0f14bb71740ea7f54f371b4df4f9604 (patch)
tree2a7da6428c30ae1845906c75e5924ccf95e748a8
parent15ea7238e42ea62da32c926c0a1667802f7646d9 (diff)
downloadmariadb-git-a05a566cf0f14bb71740ea7f54f371b4df4f9604.tar.gz
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.
-rw-r--r--mysql-test/r/fulltext_left_join.result14
-rw-r--r--mysql-test/r/fulltext_order_by.result4
-rw-r--r--mysql-test/t/fulltext_left_join.test13
-rw-r--r--sql/item_func.h1
4 files changed, 30 insertions, 2 deletions
diff --git a/mysql-test/r/fulltext_left_join.result b/mysql-test/r/fulltext_left_join.result
index ea4cacf2fab..d5373037538 100644
--- a/mysql-test/r/fulltext_left_join.result
+++ b/mysql-test/r/fulltext_left_join.result
@@ -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;
diff --git a/mysql-test/r/fulltext_order_by.result b/mysql-test/r/fulltext_order_by.result
index bd3e79ec5c2..58ed6aac6f9 100644
--- a/mysql-test/r/fulltext_order_by.result
+++ b/mysql-test/r/fulltext_order_by.result
@@ -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
diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test
index 8c13ae5cad9..3a81c1a5d1b 100644
--- a/mysql-test/t/fulltext_left_join.test
+++ b/mysql-test/t/fulltext_left_join.test
@@ -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;
diff --git a/sql/item_func.h b/sql/item_func.h
index 54635bf21f7..abaf07c51d5 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -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() {}