Incorrect result with outer join and full text match

Bug #906357 reported by Timour Katchaounov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Medium
Sergey Petrunia

Bug Description

The following test case derived from fulltext.test produces wrong result:

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');

-- Correct result: the ON predicate is FALSE
SELECT * FROM t2 LEFT OUTER JOIN t1 ON (f1 = "");
+------+------+
| f2 | f1 |
+------+------+
| test | NULL |
+------+------+

SELECT * FROM t1 RIGHT OUTER JOIN t2 ON (f1 = "");
+------+------+
| f1 | f2 |
+------+------+
| NULL | test |
+------+------+

-- Wrong result: the ON predicate is FALSE as above, but the result is different:
SELECT * FROM t2 LEFT OUTER JOIN t1 ON (MATCH(f1) against (""));
+------+------+
| f2 | f1 |
+------+------+
| test | test |
+------+------+

SELECT * FROM t1 RIGHT OUTER JOIN t2 ON (MATCH(f1) against (""));
+------+------+
| f1 | f2 |
+------+------+
| test | test |
+------+------+

Revision history for this message
Timour Katchaounov (timour) wrote :

The above wrong result is part of a more complicated query from the
patch below. After fixing this bug, please check the complete test case
for MySQL Bug#54484 in fulltext.test.

------------------------------------------------------------
revno: 2502.1086.9
committer: Sergey Glukhov <email address hidden>
branch nick: mysql-5.1-security
timestamp: Mon 2010-10-18 14:47:26 +0400
message:
  Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine
  Subquery executes twice, at top level JOIN::optimize and ::execute stages.
  At first execution create_sort_index() function is called and
  FT_SELECT object is created and destroyed. HANDLER::ft_handler is cleaned up
  in the object destructor and at second execution FT_SELECT::get_next() method
  returns error.
  The fix is to reinit HANDLER::ft_handler field before re-execution of subquery.

Changed in maria:
milestone: none → 5.2
assignee: nobody → Igor Babaev (igorb-seattle)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Sergey Petrunia (sergefp) wrote :

Repeatable in MySQL 5.5

Revision history for this message
Sergey Petrunia (sergefp) wrote :

The fix is in commits@. I did not push it because I doubt it is important for the release.

Revision history for this message
Sergey Petrunia (sergefp) wrote :

This was fixed in MariaDB 5.3.3

Changed in maria:
assignee: Igor Babaev (igorb-seattle) → Sergey Petrunia (sergefp)
milestone: 5.2 → 5.3
status: Confirmed → Fix Committed
Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.