-
Roy Lyseng authored
Complete patch. See sql/aggregate_check.h or the WL for design. Moreover, this contains changes (not written in the WL page): 1) Item_ident::alias_name_used used to convey the two pieces of information below; it's removed and replaced with: * m_alias_of_expr tells if this is a reference, through an alias, to a SELECTed expression which has "AS alias" * to know if this is a reference to a column of an aliased table, we consult table->alias_name_used 2) only_full_group_by checks are now done after simplify_joins(); the latter function may convert outer joins to inner joins, and inner joins allow more functional dependency detection; so with this change we can allow more queries. 3) moved JOIN::outer_join to SELECT_LEX::outer_join; indeed, this is constant through executions, and we now need it for FD detection so computing this variable at optimization time was too late. 4) in trunk we eliminate DISTINCT if all group expressions are in the select list, but we do it at optimization stage; in this WL we do it at preparation stage. This makes only_full_group_by distinct-related checks to allow more queries, like SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); (which otherwise would yield the new error ER_AGGREGATE_IN_ORDER_NOT_SELECT): and it allows the optimizer in general to choose better plans (see the change in group_min_max.result). 5) a new class Bool3 for holding true/false/unknown values.
Roy Lyseng authoredComplete patch. See sql/aggregate_check.h or the WL for design. Moreover, this contains changes (not written in the WL page): 1) Item_ident::alias_name_used used to convey the two pieces of information below; it's removed and replaced with: * m_alias_of_expr tells if this is a reference, through an alias, to a SELECTed expression which has "AS alias" * to know if this is a reference to a column of an aliased table, we consult table->alias_name_used 2) only_full_group_by checks are now done after simplify_joins(); the latter function may convert outer joins to inner joins, and inner joins allow more functional dependency detection; so with this change we can allow more queries. 3) moved JOIN::outer_join to SELECT_LEX::outer_join; indeed, this is constant through executions, and we now need it for FD detection so computing this variable at optimization time was too late. 4) in trunk we eliminate DISTINCT if all group expressions are in the select list, but we do it at optimization stage; in this WL we do it at preparation stage. This makes only_full_group_by distinct-related checks to allow more queries, like SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); (which otherwise would yield the new error ER_AGGREGATE_IN_ORDER_NOT_SELECT): and it allows the optimizer in general to choose better plans (see the change in group_min_max.result). 5) a new class Bool3 for holding true/false/unknown values.
Loading