Wrong result with outer join + subquery in ON clause in maria-5.3

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

Bug Description

Not repeatable with maria-5.3, mysql 5.1 . Not influenced by optimizer switches. The following query:

SELECT t3.b FROM t2 LEFT JOIN t3 ON ( 6 ) IN ( SELECT a FROM t1 );

returns t3.b = 0 even though the ON clause is FALSE and therefore there are no records to be joined between the two tables.

explain:

| 1 | PRIMARY | t2 | system | NULL | NULL | NULL | NULL | 1 | |
| 1 | PRIMARY | t3 | system | NULL | NULL | NULL | NULL | 1 | |
| 2 | DEPENDENT SUBQUERY | t1 | ALL | NULL | NULL | NULL | NULL | 2 | Using where |

actual result:

mysql> SELECT t3.b FROM t2 LEFT JOIN t3 ON ( 6 ) IN ( SELECT a FROM t1 );
+------+
| b |
+------+
| 0 |
+------+

expected result:

 SELECT t3.b FROM t2 LEFT JOIN t3 ON ( 6 ) IN ( SELECT a FROM t1 );
+------+
| b |
+------+
| NULL |
+------+

test case:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a int);
INSERT INTO t1 VALUES (0),(0);

DROP TABLE IF EXISTS t2;
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (0);

DROP TABLE IF EXISTS t3;
CREATE TABLE t3 (b int);
INSERT INTO t3 VALUES (0);

SELECT t3.b FROM t2 LEFT JOIN t3 ON ( 6 ) IN ( SELECT a FROM t1 );

bzr version-info

revision-id: <email address hidden>
date: 2011-07-20 11:56:28 +0400
build-date: 2011-07-20 14:25:55 +0300
revno: 3123
branch-nick: maria-5.3

optimizer switch in effect:

index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on

Changed in maria:
milestone: none → 5.3
assignee: nobody → Timour Katchaounov (timour)
Revision history for this message
Timour Katchaounov (timour) wrote :

Not repeatable with maria-5.2, mysql.

Changed in maria:
status: New → Confirmed
importance: Undecided → High
Changed in maria:
assignee: Timour Katchaounov (timour) → Igor Babaev (igorb-seattle)
status: Confirmed → In Progress
Changed in maria:
status: In Progress → 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.