Wrong subquery result with join_cache_level=6, even in .result files

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

Bug Description

mysql-test/r/subselect3.result shows:

explain select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
2 SUBQUERY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer
select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
a b c
256 67 NULL

while
mysql-test/r/subselect3_jcl6.result shows:

explain select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY subselect2 ALL unique_key NULL NULL NULL 8 Using temporary; Using filesort
1 PRIMARY t21 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
1 PRIMARY t22 ALL NULL NULL NULL NULL 26 Using where; Using join buffer
2 SUBQUERY t11 ALL NULL NULL NULL NULL 8 Using where
2 SUBQUERY t12 ALL NULL NULL NULL NULL 8 Using where; Using join buffer
select t21.* from t21,t22 where t21.a = t22.a and
t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a;
a b c
256 67 NULL
256 67 NULL

That is, the _jcl6 variant produces two records instead of one.

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

Igor has fixed a wrong result in mwl128 tree with this change:

=== modified file 'sql/sql_select.cc'
--- sql/sql_select.cc 2010-10-18 08:55:26 +0000
+++ sql/sql_select.cc 2010-10-21 16:14:41 +0000
@@ -9315,6 +9315,11 @@ Item *eliminate_item_equal(COND *cond, C
     Item_equal *upper= item_field->find_item_equal(upper_levels);
     Item_field *item= item_field;
     TABLE_LIST *field_sjm= embedding_sjm(item_field);
+ if (!field_sjm)
+ {
+ current_sjm= NULL;
+ current_sjm_head= NULL;
+ }

     /*
       Check if "item_field=head" equality is already guaranteed to be true

However, applying this patch to 5.3-main doesn't cause the right query result to be produced.

Perhaps, wrong result in 5.3 is due to a different problem then one in mwl128 tree, as MWL#128 tree has a different plan for the query (for an unknown reason).

Changed in maria:
assignee: nobody → Sergey Petrunia (sergefp)
Changed in maria:
status: New → Confirmed
importance: Undecided → High
assignee: Sergey Petrunia (sergefp) → Igor Babaev (igorb-seattle)
status: Confirmed → In Progress
Changed in maria:
milestone: none → 5.3
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.