Skip to content

Commit db50d3c

Browse files
author
Sreeharsha Ramanavarapu
committed
Bug #26432173: INCORRECT SUBQUERY OPTIMIZATION WITH
LEFT JOIN(SUBQUERY) AND ORDER BY Post-push fix to address failures in funcs_1.innodb_views and funcs_1.memory_views The call to const_for_execution (in trunk) and const_item (in 5.7) has been replaced by their respective content to avoid multiple and recursive calls to used_tables. This can create a problem when Views are created using other views
1 parent 9123faf commit db50d3c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

sql/item.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,17 +4312,33 @@ class Item_direct_view_ref :public Item_direct_ref
43124312

43134313
bool fix_fields(THD *, Item **);
43144314

4315-
/*
4315+
/**
43164316
Takes into account whether an Item in a derived table / view is part of an
43174317
inner table of an outer join.
4318-
*/
4318+
4319+
1) If the field is an outer reference, return OUTER_TABLE_REF_BIT.
4320+
2) Else
4321+
2a) If the field is const_item and the field is used in the
4322+
inner part of an outer join, return the inner tables of the outer
4323+
join. (A 'const' field that depends on the inner table of an outer
4324+
join shouldn't be interpreted as const.)
4325+
2b) Else return the used_tables info of the underlying field.
4326+
4327+
@note The call to const_item has been replaced by
4328+
"(inner_map == 0)" to avoid multiple and recursive
4329+
calls to used_tables. This can create a problem when Views are
4330+
created using other views
4331+
*/
43194332
table_map used_tables() const
43204333
{
4321-
return depended_from ?
4322-
OUTER_REF_TABLE_BIT :
4323-
(*ref)->const_item() && first_inner_table != NULL ?
4334+
if (depended_from != NULL)
4335+
return OUTER_REF_TABLE_BIT;
4336+
4337+
table_map inner_map= (*ref)->used_tables();
4338+
return
4339+
(inner_map == 0) && first_inner_table != NULL ?
43244340
first_inner_table->map() :
4325-
(*ref)->used_tables();
4341+
inner_map;
43264342
}
43274343

43284344
bool eq(const Item *item, bool binary_cmp) const;

0 commit comments

Comments
 (0)