MySQL 8.4.3
Source Code Documentation
|
Checks for queries which have GROUP BY or aggregate functions. More...
#include <aggregate_check.h>
Public Member Functions | |
Group_check (Query_block *select_arg, MEM_ROOT *root) | |
~Group_check () | |
Group_check (const Group_check &)=delete | |
Group_check & | operator= (const Group_check &)=delete |
bool | check_query (THD *thd) |
Rejects the query if it does aggregation or grouping, and expressions in its SELECT list, ORDER BY clause, HAVING condition, or window functions may vary inside a group (are not "group-invariant"). More... | |
void | to_opt_trace (THD *thd) |
Writes "check information" to the optimizer trace. More... | |
Private Types | |
enum | enum_ident_check { CHECK_GROUP , CHECK_STRONG_SIDE_COLUMN , CHECK_COLUMN } |
Enum for argument of do_ident_check() More... | |
Private Member Functions | |
bool | is_fd_on_source (Item *item) |
Tells if 'item' is functionally dependent ("FD") on source columns. More... | |
bool | is_child () const |
Group_check (Query_block *select_arg, MEM_ROOT *root, Table_ref *table_arg) | |
Private ctor, for a Group_check to build a child Group_check. More... | |
bool | check_expression (THD *thd, Item *expr, bool in_select_list) |
Validates one expression (this forms one step of check_query()). More... | |
bool | local_column (Item *item) const |
Shortcut for common use of Item::local_column() More... | |
void | add_to_fd (Item *item, bool local_column, bool add_to_mat_table=true) |
void | add_to_fd (table_map m) |
void | add_to_source_of_mat_table (Item_field *item_field, Table_ref *tl) |
If we just added a column of a materialized table to 'fd', we record this fact in a new Group_check (mat_gc) for the query expression underlying that table. More... | |
bool | is_in_fd (Item *item) |
is_in_fd() is low-level compared to is_fd_on_source(). More... | |
bool | is_in_fd_of_underlying (Item_ident *item) |
See if we can derive a FD from a column which has an underlying expression. More... | |
Item * | get_fd_equal (Item *item) |
void | analyze_conjunct (Item *cond, Item *conjunct, table_map weak_tables, bool weak_side_upwards) |
Searches for equality-based functional dependences in an AND-ed part of a condition (a conjunct). More... | |
void | analyze_scalar_eq (Item *cond, Item *left_item, Item *right_item, table_map weak_tables, bool weak_side_upwards) |
Helper function. More... | |
void | find_fd_in_cond (Item *cond, table_map weak_tables, bool weak_side_upwards) |
Searches for equality-based functional dependencies in a condition. More... | |
void | find_fd_in_joined_table (mem_root_deque< Table_ref * > *join_list) |
Searches for equality-based functional dependencies in the condition of a join nest, and recursively in all contained join nests. More... | |
void | to_opt_trace2 (Opt_trace_context *ctx, Opt_trace_object *parent) |
Utility function for to_opt_trace(), as we need recursion in children Group_checks. More... | |
void | find_group_in_fd (Item *item) |
This function must be called every time we discover an item which is FD on source columns, or add a bit to whole_tables_fd; it maintains group_in_fd. More... | |
Item * | select_expression (uint idx) |
bool | do_ident_check (Item_ident *i, table_map tm, enum enum_ident_check type) |
Does one low-level check on one Item_ident. More... | |
Private Attributes | |
Query_block *const | select |
Query block which we are validating. More... | |
bool | search_in_underlying |
"Underlying" == expressions which are underlying in an identifier. More... | |
bool | non_null_in_source |
This member is readable only if this is a child Group_check. More... | |
Table_ref *const | table |
The Group_check employed to validate one query block, the one on which check_query() runs, is named the "master". More... | |
ulonglong | group_in_fd |
Bit N is set if the N-th expression of GROUP BY is functionally dependent on source columns. More... | |
MEM_ROOT *const | m_root |
Memory for allocations (like of 'fd') More... | |
Mem_root_array< Item_ident * > | fd |
Columns which are local to 'select' and functionally dependent on an initial set of "source" columns defined like this: More... | |
table_map | whole_tables_fd |
Map of tables for which all columns can be considered part of 'fd'. More... | |
table_map | recheck_nullable_keys |
Map of tables for which we discovered known-not-nullable columns. More... | |
Mem_root_array< Group_check * > | mat_tables |
Children Group_checks of 'this'. More... | |
Item_ident * | failed_ident |
Identifier which triggered an error. More... | |
SQL_I_List< ORDER > | m_added_by_transform |
GROUP BY list non single column expressions entries added by transform. More... | |
Friends | |
bool | Item_ident::aggregate_check_group (uchar *arg) |
Just because we need to go through Item::walk() to reach all items to validate, some work must be delegated to "Item processors" (members of Item); this work conceptually belongs to Group_check, and needs privileged access to it. More... | |
bool | Item_sum::aggregate_check_group (uchar *arg) |
bool | Item_func_any_value::aggregate_check_group (uchar *arg) |
bool | Item_ident::is_strong_side_column_not_in_fd (uchar *arg) |
bool | Item_ident::is_column_not_in_fd (uchar *arg) |
bool | Item_func_grouping::aggregate_check_group (uchar *arg) |
Additional Inherited Members | |
Protected Member Functions inherited from Item_tree_walker | |
Item_tree_walker () | |
~Item_tree_walker () | |
Item_tree_walker (const Item_tree_walker &)=delete | |
Item_tree_walker & | operator= (const Item_tree_walker &)=delete |
void | stop_at (const Item *i) |
Stops walking children of this item. More... | |
bool | is_stopped (const Item *i) |
Checks for queries which have GROUP BY or aggregate functions.
|
private |
|
inline |
|
inline |
|
delete |
|
inlineprivate |
Private ctor, for a Group_check to build a child Group_check.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Shortcut for common use of Item::local_column()
|
delete |
|
friend |
|
friend |
|
friend |
Just because we need to go through Item::walk() to reach all items to validate, some work must be delegated to "Item processors" (members of Item); this work conceptually belongs to Group_check, and needs privileged access to it.
|
friend |
|
friend |
|
friend |
|
private |
Identifier which triggered an error.
|
private |
Columns which are local to 'select' and functionally dependent on an initial set of "source" columns defined like this:
|
private |
Bit N is set if the N-th expression of GROUP BY is functionally dependent on source columns.
It serves to find FDs in the query expression of a materialized table having GROUP BY. For a non-child Group-check, all bits are turned on from the start. Currently limited to 64 bits => max 64 GROUP expressions; should probably be MY_BITMAP.
|
private |
GROUP BY list non single column expressions entries added by transform.
|
private |
Memory for allocations (like of 'fd')
|
private |
Children Group_checks of 'this'.
|
private |
This member is readable only if this is a child Group_check.
Is true if one expression of the SELECT list of this->select is non-nullable.
|
private |
Map of tables for which we discovered known-not-nullable columns.
|
private |
"Underlying" == expressions which are underlying in an identifier.
The identifier can be a column of a view or derived table, both merged or materialized, or a generated column: all of those have an underlying expression. "Materialized table (mat table)" == view or derived table, materialized. If this is true, is_in_fd() will look for FDs in underlying expressions of columns.
|
private |
Query block which we are validating.
|
private |
The Group_check employed to validate one query block, the one on which check_query() runs, is named the "master".
If the query block references a materialized table, the master may create a child Group_check, whose job is to discover FDs in the query expression of the mat table (with the ultimate goal of deducing from them some FDs in the mat table and thus in the parent Group_check). A child may have children itself. If this Group_check is a child, 'table' points to the materialized table, otherwise it is NULL.
|
private |
Map of tables for which all columns can be considered part of 'fd'.