A query with LEFT JOIN returns a wrong result in mariadb 5.3

Bug #943543 reported by Igor Babaev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
High
Igor Babaev

Bug Description

The following slightly modified test case for mysql bug #58456 produces a wrong result in mariadb-5.3.5

CREATE TABLE t1 (
  col_int INT,
  col_int_key INT,
  pk INT NOT NULL,
  PRIMARY KEY (pk),
  KEY col_int_key (col_int_key)
) ENGINE=InnoDB;

INSERT INTO t1 VALUES (NULL,1,1), (6,2,2), (5,3,3), (NULL,4,4);
INSERT INTO t1 VALUES (1,NULL,6), (8,5,7), (NULL,8,8), (8,NULL,5);

CREATE TABLE t2 (
  pk INT PRIMARY KEY
) ENGINE=InnoDB;

 INSERT INTO t2 VALUES (3), (8), (5);

SELECT t1.pk
FROM t2 LEFT JOIN t1 ON t2.pk = t1.col_int
WHERE t1.col_int_key BETWEEN 5 AND 6
      AND t1.pk IS NULL OR t1.pk IN (5)
ORDER BY pk;

DROP TABLE t1,t2;

The SELECT of the test case returns an empty set though the expected result is:
+----+
| pk |
+----+
| 5 |
+----+

Changed in maria:
milestone: none → 5.3
assignee: nobody → Igor Babaev (igorb-seattle)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Igor Babaev (igorb-seattle) wrote :

The problem can be reproduced with myisam tables as well.

Changed in maria:
status: Confirmed → In Progress
Revision history for this message
Igor Babaev (igorb-seattle) wrote :

The wrong result on the reported query is caused by a bug in the recently pushed patch for bug #939009.
Actually even the result of the first query in the test case for bug #939009 is incorrect.

Changed in maria:
status: In Progress → Fix Committed
Revision history for this message
Elena Stepanova (elenst) wrote :

Fix released in 5.3.6

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.