Wrong subquery result with join_cache_level=6, even in .result files
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Igor Babaev |
Bug Description
mysql-test/
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/
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.
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 |
Igor has fixed a wrong result in mwl128 tree with this change:
=== modified file 'sql/sql_select.cc' item_equal( COND *cond, C >find_item_ equal(upper_ levels) ; sjm(item_ field);
--- 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 *upper= item_field-
Item_field *item= item_field;
TABLE_LIST *field_sjm= embedding_
+ 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).