-
Roy Lyseng authored
This problem is caused by lack of support for view reference fields in Item_ref::resolved_used_tables(). We have a query fragment like this: select 1 from v2 where 1 = (select 1 from t1 group by v2.a) This fragment is part of a subquery that is transformed into a semi-join. During that transformation, fix_after_pullout() is called, which calls upon resolved_used_tables() to re-calculate used tables information for the scalar subquery. v2.a is a reference to a const value in the view definition. However, Item_ref::resolved_used_tables() expects to see a FIELD_ITEM, and asserts when it does not. The fix for this problem is to accept that Item_direct_view_ref may reference other expressions than just fields and call resolved_used_tables() on the referenced expression. sql/item.cc In Item_ref::resolved_used_tables(), noticed that the referenced item's type need not be a FIELD_ITEM when item is Item_direct_view_ref. sql/item.h Moved resolved_used_tables() from class Item_ident to class Item, and let the default implementation call used_tables(). Emphasized that resolved_used_tables() behaves like used_tables() except for fields, and that Item::resolved_used_tables() is for internal use.
Roy Lyseng authoredThis problem is caused by lack of support for view reference fields in Item_ref::resolved_used_tables(). We have a query fragment like this: select 1 from v2 where 1 = (select 1 from t1 group by v2.a) This fragment is part of a subquery that is transformed into a semi-join. During that transformation, fix_after_pullout() is called, which calls upon resolved_used_tables() to re-calculate used tables information for the scalar subquery. v2.a is a reference to a const value in the view definition. However, Item_ref::resolved_used_tables() expects to see a FIELD_ITEM, and asserts when it does not. The fix for this problem is to accept that Item_direct_view_ref may reference other expressions than just fields and call resolved_used_tables() on the referenced expression. sql/item.cc In Item_ref::resolved_used_tables(), noticed that the referenced item's type need not be a FIELD_ITEM when item is Item_direct_view_ref. sql/item.h Moved resolved_used_tables() from class Item_ident to class Item, and let the default implementation call used_tables(). Emphasized that resolved_used_tables() behaves like used_tables() except for fields, and that Item::resolved_used_tables() is for internal use.
Loading