MySQL 8.4.2
Source Code Documentation
|
#include <table.h>
Public Types | |
enum | { OPEN_NORMAL = 0 , OPEN_IF_EXISTS , OPEN_FOR_CREATE , OPEN_STUB } |
Indicates that if Table_ref object corresponds to the table/view which requires special handling. More... | |
Public Member Functions | |
Table_ref ()=default | |
Table_ref (TABLE *table_arg) | |
Only to be used by legacy code that temporarily needs a Table_ref, more specifically: Query_result_create::binlog_show_create_table(). More... | |
Table_ref (const char *db_name, const char *table_name, enum thr_lock_type lock_type) | |
Constructor that can be used when the strings are null terminated. More... | |
Table_ref (TABLE *table_arg, const char *db_name_arg, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, const char *alias_arg, enum thr_lock_type lock_type_arg) | |
Creates a Table_ref object with pre-allocated strings for database, table and alias. More... | |
Table_ref (const char *db_name, const char *table_name, const char *alias, enum thr_lock_type lock_type) | |
Constructor that can be used when the strings are null terminated. More... | |
Table_ref (TABLE *table_arg, const char *alias_arg) | |
This constructor can be used when a Table_ref is needed for an existing temporary table. More... | |
Table_ref (TABLE *table_arg, const char *alias_arg, enum_mdl_type mdl_type) | |
Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor. More... | |
Table_ref (const char *db_name, const char *table_name_arg, enum thr_lock_type lock_type_arg, enum enum_mdl_type mdl_request_type) | |
Table_ref (const char *db_name, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, enum thr_lock_type lock_type_arg, enum enum_mdl_type mdl_request_type) | |
Table_ref (const char *db_name, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, enum thr_lock_type lock_type_arg) | |
Table_ref (const char *db_name, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, const char *alias_arg, enum enum_mdl_type mdl_request_type) | |
Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor. More... | |
Table_ref (const char *db_name, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, const char *alias_arg, enum thr_lock_type lock_type_arg, enum enum_mdl_type mdl_request_type) | |
Table_ref (const char *db_name_arg, size_t db_length_arg, const char *table_name_arg, size_t table_name_length_arg, const char *alias_arg, enum thr_lock_type lock_type_arg) | |
Item ** | join_cond_ref () |
Item * | join_cond () const |
void | set_join_cond (Item *val) |
Item * | join_cond_optim () const |
void | set_join_cond_optim (Item *cond) |
Item ** | join_cond_optim_ref () |
bool | is_sj_nest () const |
bool | is_aj_nest () const |
bool | is_sj_or_aj_nest () const |
void | set_sj_or_aj_nest () |
Makes the next a semi/antijoin nest. More... | |
bool | merge_underlying_tables (Query_block *select) |
Merge tables from a query block into a nested join structure. More... | |
void | reset () |
Reset table. More... | |
int | view_check_option (THD *thd) const |
Evaluate the check option of a view. More... | |
void | print (const THD *thd, String *str, enum_query_type query_type) const |
Produce a textual identification of this object. More... | |
bool | check_single_table (Table_ref **table_ref, table_map map) |
Check which single table inside a view that matches a table map. More... | |
bool | set_insert_values (MEM_ROOT *mem_root) |
Allocate a buffer for inserted column values. More... | |
Table_ref * | first_leaf_for_name_resolution () |
Retrieve the first (left-most) leaf in a nested join tree with respect to name resolution. More... | |
Table_ref * | last_leaf_for_name_resolution () |
Retrieve the last (right-most) leaf in a nested join tree with respect to name resolution. More... | |
bool | is_leaf_for_name_resolution () const |
Test if this is a leaf with respect to name resolution. More... | |
const Table_ref * | top_table () const |
Return the outermost view this table belongs to, or itself. More... | |
Table_ref * | top_table () |
bool | prepare_check_option (THD *thd, bool is_cascaded=false) |
Prepare check option for a view. More... | |
bool | merge_where (THD *thd) |
Merge WHERE condition of view or derived table into outer query. More... | |
bool | prepare_replace_filter (THD *thd) |
Prepare replace filter for a view (used for REPLACE command) More... | |
bool | is_view () const |
Return true if this represents a named view. More... | |
bool | is_derived () const |
Return true if this represents a derived table (an unnamed view) More... | |
bool | is_view_or_derived () const |
Return true if this represents a named view or a derived table. More... | |
bool | is_table_function () const |
Return true if this represents a table function. More... | |
bool | is_recursive_reference () const |
bool | is_base_table () const |
bool | set_recursive_reference () |
bool | is_internal () const |
bool | is_placeholder () const |
bool | is_mergeable () const |
Return true if view or derived table and can be merged. More... | |
bool | materializable_is_const () const |
Checks if this is a table that contains zero rows or one row, and that can be materialized during optimization. More... | |
bool | is_merged () const |
Return true if this is a derived table or view that is merged. More... | |
void | set_merged () |
Set table to be merged. More... | |
bool | uses_materialization () const |
Return true if this is a materializable derived table/view. More... | |
void | set_uses_materialization () |
Set table to be materialized. More... | |
bool | is_updatable () const |
Return true if table is updatable. More... | |
void | set_updatable () |
Set table as updatable. (per default, a table is non-updatable) More... | |
bool | is_insertable () const |
Return true if table is insertable-into. More... | |
void | set_insertable () |
Set table as insertable-into. (per default, a table is not insertable) More... | |
bool | is_updated () const |
Return true if table is being updated. More... | |
void | set_updated () |
Set table and all referencing views as being updated. More... | |
bool | is_inserted () const |
Return true if table is being inserted into. More... | |
void | set_inserted () |
Set table and all referencing views as being inserted into. More... | |
bool | is_deleted () const |
Return true if table is being deleted from. More... | |
void | set_deleted () |
Set table and all referencing views as being deleted from. More... | |
void | set_fulltext_searched () |
Set table as full-text search (default is not fulltext searched) More... | |
bool | is_fulltext_searched () const |
Returns true if a MATCH function references this table. More... | |
bool | is_external () const |
Is this table only available in an external storage engine? More... | |
void | set_readonly () |
Set table as readonly, ie it is neither updatable, insertable nor deletable during this statement. More... | |
bool | is_multiple_tables () const |
Return true if this is a view or derived table that is defined over more than one base table, and false otherwise. More... | |
uint | leaf_tables_count () const |
Return no. of base tables a merged view or derived table is defined over. More... | |
Table_ref * | first_leaf_table () |
Return first leaf table of a base table or a view/derived table. More... | |
Table_ref * | any_outer_leaf_table () |
Return any leaf table that is not an inner table of an outer join. More... | |
void | set_view_query (LEX *lex) |
Set the LEX object of a view (will also define this as a view). More... | |
LEX * | view_query () const |
Return the valid LEX object for a view. More... | |
void | set_derived_query_expression (Query_expression *query_expr) |
Set the query expression of a derived table or view. More... | |
Query_expression * | derived_query_expression () const |
Return the query expression of a derived table or view. More... | |
bool | resolve_derived (THD *thd, bool apply_semijoin) |
Resolve a derived table or view reference. More... | |
bool | optimize_derived (THD *thd) |
Optimize the query expression representing a derived table/view. More... | |
bool | create_materialized_table (THD *thd) |
Create result table for a materialized derived table/view. More... | |
bool | materialize_derived (THD *thd) |
Materialize derived table. More... | |
bool | can_push_condition_to_derived (THD *thd) |
Check if we can push outer where condition to this derived table. More... | |
uint | get_hidden_field_count_for_derived () const |
Return the number of hidden fields added for the temporary table created for this derived table. More... | |
bool | prepare_security (THD *thd) |
Prepare security context for a view. More... | |
Security_context * | find_view_security_context (THD *thd) |
Find security context of current view. More... | |
bool | prepare_view_security_context (THD *thd) |
Load security context information for this view. More... | |
bool | process_index_hints (const THD *thd, TABLE *table) |
Compiles the tagged hints list and fills up TABLE::keys_in_use_for_query, TABLE::keys_in_use_for_group_by, TABLE::keys_in_use_for_order_by, TABLE::force_index and TABLE::covering_keys. More... | |
bool | is_table_ref_id_equal (TABLE_SHARE *s) const |
Compare the version of metadata from the previous execution (if any) with values obtained from the current table definition cache element. More... | |
void | set_table_ref_id (TABLE_SHARE *s) |
Record the value of metadata version of the corresponding table definition cache element in this parse tree node. More... | |
void | set_table_ref_id (enum_table_ref_type table_ref_type_arg, ulonglong table_ref_version_arg) |
uint | query_block_id () const |
If a derived table, returns query block id of first underlying query block. More... | |
uint | query_block_id_for_explain () const |
This is for showing in EXPLAIN. More... | |
const char * | get_db_name () const |
Returns the name of the database that the referenced table belongs to. More... | |
const char * | get_table_name () const |
Returns the name of the table that this Table_ref represents. More... | |
int | fetch_number_of_rows (ha_rows fallback_estimate=PLACEHOLDER_TABLE_ROW_ESTIMATE) |
Retrieve number of rows in the table. More... | |
bool | update_derived_keys (THD *, Field *, Item **, uint, bool *) |
Update derived table's list of possible keys. More... | |
bool | generate_keys () |
Generate keys for a materialized derived table/view. More... | |
bool | setup_materialized_derived (THD *thd) |
Setup a derived table to use materialization. More... | |
bool | setup_materialized_derived_tmp_table (THD *thd) |
Sets up the tmp table to contain the derived table's rows. More... | |
bool | setup_table_function (THD *thd) |
Setup a table function to use materialization. More... | |
bool | create_field_translation (THD *thd) |
Create field translation for merged derived table/view. More... | |
Table_ref * | outer_join_nest () const |
Returns the outer join nest that this Table_ref belongs to, if any. More... | |
bool | is_inner_table_of_outer_join () const |
Return true if this table is an inner table of some outer join. More... | |
const Table_ref * | updatable_base_table () const |
Return the base table entry of an updatable table. More... | |
Table_ref * | updatable_base_table () |
void | add_join_natural (Table_ref *b) |
Mark that there is a NATURAL JOIN or JOIN ... USING between two tables. More... | |
void | set_privileges (Access_bitmask privilege) |
Set granted privileges for a table. More... | |
bool | save_properties () |
Save persistent properties from TABLE into Table_ref. More... | |
void | restore_properties () |
Restore persistent properties into TABLE from Table_ref. More... | |
void | set_lock (const Lock_descriptor &descriptor) |
const Lock_descriptor & | lock_descriptor () const |
bool | is_derived_unfinished_materialization () const |
void | set_tablesample (tablesample_type sampling_type_arg, Item *sampling_percentage_arg) |
bool | has_tablesample () const |
bool | update_sampling_percentage () |
double | get_sampling_percentage () const |
bool | validate_tablesample_clause (THD *thd) |
tablesample_type | get_sampling_type () const |
void | set_tableno (uint tableno) |
Set table number. More... | |
uint | tableno () const |
Return table number. More... | |
table_map | map () const |
Return table map derived from table number. More... | |
Common_table_expr * | common_table_expr () const |
If non-NULL, the CTE which this table is derived from. More... | |
void | set_common_table_expr (Common_table_expr *c) |
const Create_col_name_list * | derived_column_names () const |
void | set_derived_column_names (const Create_col_name_list *d) |
Static Public Member Functions | |
static Table_ref * | new_nested_join (MEM_ROOT *allocator, const char *alias, Table_ref *embedding, mem_root_deque< Table_ref * > *belongs_to, Query_block *select) |
Create a Table_ref object representing a nested join. More... | |
Public Attributes | |
Table_ref * | next_local {nullptr} |
Table_ref * | next_global {nullptr} |
Table_ref ** | prev_global {nullptr} |
const char * | db {nullptr} |
const char * | table_name {nullptr} |
const char * | alias {nullptr} |
LEX_CSTRING | target_tablespace_name {nullptr, 0} |
char * | option {nullptr} |
Opt_hints_table * | opt_hints_table {nullptr} |
Table level optimizer hints for this table. More... | |
Opt_hints_qb * | opt_hints_qb {nullptr} |
table_map | sj_inner_tables {0} |
Table_ref * | natural_join {nullptr} |
bool | is_natural_join {false} |
List< String > * | join_using_fields {nullptr} |
List< Natural_join_column > * | join_columns {nullptr} |
bool | is_join_columns_complete {false} |
Table_ref * | next_name_resolution_table {nullptr} |
List< Index_hint > * | index_hints {nullptr} |
TABLE * | table {nullptr} |
mysql::binlog::event::Table_id | table_id {} |
Query_result_union * | derived_result {nullptr} |
Table_ref * | correspondent_table {nullptr} |
Table_function * | table_function {nullptr} |
AccessPath * | access_path_for_derived {nullptr} |
If we've previously made an access path for “derived”, it is cached here. More... | |
Item * | sampling_percentage {nullptr} |
ST_SCHEMA_TABLE * | schema_table {nullptr} |
Query_block * | schema_query_block {nullptr} |
bool | schema_table_reformed {false} |
Query_block * | query_block {nullptr} |
Field_translator * | field_translation {nullptr} |
Array of selected expressions from a derived table or view. More... | |
Field_translator * | field_translation_end {nullptr} |
pointer to element after last one in translation table above More... | |
Table_ref * | merge_underlying_list {nullptr} |
mem_root_deque< Table_ref * > * | view_tables {nullptr} |
Table_ref * | belong_to_view {nullptr} |
Table_ref * | referencing_view {nullptr} |
Table_ref * | parent_l {nullptr} |
Security_context * | security_ctx {nullptr} |
Security_context * | view_sctx {nullptr} |
Table_ref * | next_leaf {nullptr} |
Item * | derived_where_cond {nullptr} |
WHERE condition from derived table. More... | |
Item * | check_option {nullptr} |
WITH CHECK OPTION condition. More... | |
Item * | replace_filter {nullptr} |
Filter for REPLACE command. More... | |
LEX_STRING | select_stmt {nullptr, 0} |
text of (CREATE/SELECT) statement More... | |
LEX_STRING | source {nullptr, 0} |
source of CREATE VIEW More... | |
LEX_STRING | timestamp {nullptr, 0} |
GMT time stamp of last operation. More... | |
LEX_USER | definer |
definer of view More... | |
ulonglong | updatable_view {0} |
VIEW can be updated. More... | |
ulonglong | algorithm {0} |
The declared algorithm, if this is a view. More... | |
ulonglong | view_suid {0} |
view is suid (true by default) More... | |
ulonglong | with_check {0} |
WITH CHECK OPTION. More... | |
GRANT_INFO | grant |
bool | outer_join {false} |
True if right argument of LEFT JOIN; false in other cases (i.e. More... | |
bool | join_order_swapped {false} |
True if was originally the left argument of a RIGHT JOIN, before we made it the right argument of a LEFT JOIN. More... | |
uint | shared {0} |
size_t | db_length {0} |
size_t | table_name_length {0} |
bool | straight {false} |
bool | updating {false} |
True for tables and views being changed in a data change statement. More... | |
bool | ignore_leaves {false} |
preload only non-leaf nodes (IS THIS USED???) More... | |
table_map | dep_tables {0} |
The set of tables in the query block that this table depends on. More... | |
table_map | join_cond_dep_tables {0} |
The outer tables that an outer join's join condition depends on. More... | |
NESTED_JOIN * | nested_join {nullptr} |
Is non-NULL if this table reference is a nested join, ie it represents the inner tables of an outer join, the tables contained in the parentheses of an inner join (eliminated during resolving), the tables referenced in a derived table or view, in a semi-join nest, the tables from the subquery. More... | |
Table_ref * | embedding {nullptr} |
The nested join containing this table reference. More... | |
mem_root_deque< Table_ref * > * | join_list {nullptr} |
The join list immediately containing this table reference. More... | |
bool | cacheable_table {false} |
stop PS caching More... | |
enum_open_type | open_type {OT_TEMPORARY_OR_BASE} |
Specifies which kind of table should be open for this element of table list. More... | |
bool | contain_auto_increment {false} |
bool | check_option_processed {false} |
true <=> VIEW CHECK OPTION condition is processed (also for prep. stmts) More... | |
bool | replace_filter_processed {false} |
true <=> Filter condition is processed More... | |
dd::enum_table_type | required_type {} |
char | timestamp_buffer [20] {0} |
bool | prelocking_placeholder {false} |
enum Table_ref:: { ... } | OPEN_NORMAL |
Indicates that if Table_ref object corresponds to the table/view which requires special handling. More... | |
bool | internal_tmp_table {false} |
bool | is_alias {false} |
true if an alias for this table was specified in the SQL. More... | |
bool | is_fqtn {false} |
true if the table is referred to in the statement using a fully qualified name (<db_name>. More... | |
bool | m_was_scalar_subquery {false} |
If true, this table is a derived (materialized) table which was created from a scalar subquery, cf. More... | |
View_creation_ctx * | view_creation_ctx {nullptr} |
LEX_CSTRING | view_client_cs_name {nullptr, 0} |
LEX_CSTRING | view_connection_cl_name {nullptr, 0} |
LEX_STRING | view_body_utf8 {nullptr, 0} |
bool | is_system_view {false} |
bool | is_dd_ctx_table {false} |
List< Derived_key > | derived_key_list |
uint8 | trg_event_map {0} |
Indicates what triggers we need to pre-load for this Table_ref when opening an associated TABLE. More... | |
bool | schema_table_filled {false} |
MDL_request | mdl_request |
bool | view_no_explain {false} |
if true, EXPLAIN can't explain view due to insufficient rights. More... | |
List< String > * | partition_names {nullptr} |
COND_EQUAL * | cond_equal {nullptr} |
Used with outer join. More... | |
bool | optimized_away {false} |
true <=> this table is a const one and was optimized away. More... | |
bool | derived_keys_ready {false} |
true <=> all possible keys for a derived table were collected and could be re-used while statement re-execution. More... | |
Private Attributes | |
uint | m_tableno {0} |
The members below must be kept aligned so that (1 << m_tableno) == m_map. More... | |
table_map | m_map {0} |
Table map, derived from m_tableno. More... | |
Item * | m_join_cond {nullptr} |
If this table or join nest is the Y in "X [LEFT] JOIN Y ON C", this member points to C. More... | |
bool | m_is_sj_or_aj_nest {false} |
tablesample_type | sampling_type |
Sampling information. More... | |
double | sampling_percentage_val {0} |
Query_expression * | derived {nullptr} |
This field is set to non-null for derived tables and views. More... | |
Common_table_expr * | m_common_table_expr {nullptr} |
If non-NULL, the CTE which this table is derived from. More... | |
const Create_col_name_list * | m_derived_column_names {nullptr} |
If the user has specified column names with the syntaxes "table name
parenthesis column names": WITH qn(column names) AS (select...) or FROM (select...) dt(column names) or CREATE VIEW v(column_names) AS ... then this points to the list of column names. More... | |
LEX * | view {nullptr} |
enum_view_algorithm | effective_algorithm {VIEW_ALGORITHM_UNDEFINED} |
The view algorithm that is actually used, if this is a view. More... | |
Lock_descriptor | m_lock_descriptor |
bool | m_updatable {false} |
True if VIEW/TABLE is updatable, based on analysis of query (SQL rules). More... | |
bool | m_insertable {false} |
True if VIEW/TABLE is insertable, based on analysis of query (SQL rules). More... | |
bool | m_updated {false} |
True if table is target of UPDATE statement, or updated in IODKU stmt. More... | |
bool | m_inserted {false} |
True if table is target of INSERT statement. More... | |
bool | m_deleted {false} |
True if table is target of DELETE statement, or deleted in REPLACE stmt. More... | |
bool | m_fulltext_searched {false} |
True if fulltext searched. More... | |
Item * | m_join_cond_optim {nullptr} |
Optimized copy of m_join_cond (valid for one single execution). More... | |
bool | m_is_recursive_reference {false} |
If a recursive reference inside the definition of a CTE. More... | |
enum_table_ref_type | m_table_ref_type {TABLE_REF_NULL} |
See comments for set_metadata_id() More... | |
ulonglong | m_table_ref_version {0} |
See comments for TABLE_SHARE::get_table_ref_version() More... | |
Key_map | covering_keys_saved |
Key_map | merge_keys_saved |
Key_map | keys_in_use_for_query_saved |
Key_map | keys_in_use_for_group_by_saved |
Key_map | keys_in_use_for_order_by_saved |
bool | nullable_saved {false} |
bool | force_index_saved {false} |
bool | force_index_order_saved {false} |
bool | force_index_group_saved {false} |
MY_BITMAP | lock_partitions_saved |
MY_BITMAP | read_set_saved |
MY_BITMAP | write_set_saved |
MY_BITMAP | read_set_internal_saved |
anonymous enum |
|
default |
|
inlineexplicit |
Only to be used by legacy code that temporarily needs a Table_ref, more specifically: Query_result_create::binlog_show_create_table().
|
inline |
Constructor that can be used when the strings are null terminated.
|
inline |
Creates a Table_ref object with pre-allocated strings for database, table and alias.
|
inline |
Constructor that can be used when the strings are null terminated.
|
inline |
This constructor can be used when a Table_ref is needed for an existing temporary table.
These typically have very long table names, since it is a fully qualified path. For this reason, the table is set to the alias. The database name is left blank. The lock descriptor is set to TL_READ.
|
inline |
Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor.
|
inline |
|
inline |
|
inline |
|
inline |
Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor.
|
inline |
|
inline |
|
inline |
Mark that there is a NATURAL JOIN or JOIN ... USING between two tables.
This function marks that table b should be joined with a either via a NATURAL JOIN or via JOIN ... USING. Both join types are special cases of each other, so we treat them together. The function setup_conds() creates a list of equal condition between all fields of the same name for NATURAL JOIN or the fields in Table_ref::join_using_fields for JOIN ... USING. The list of equality conditions is stored either in b->join_cond(), or in JOIN::conds, depending on whether there was an outer join.
EXAMPLE
SELECT * FROM t1 NATURAL LEFT JOIN t2 <=> SELECT * FROM t1 LEFT JOIN t2 ON (t1.i=t2.i and t1.j=t2.j ... ) SELECT * FROM t1 NATURAL JOIN t2 WHERE <some_cond> <=> SELECT * FROM t1, t2 WHERE (t1.i=t2.i and t1.j=t2.j and <some_cond>) SELECT * FROM t1 JOIN t2 USING(j) WHERE <some_cond> <=> SELECT * FROM t1, t2 WHERE (t1.j=t2.j and <some_cond>)
b | Right join argument. |
|
inline |
Return any leaf table that is not an inner table of an outer join.
bool Table_ref::can_push_condition_to_derived | ( | THD * | thd | ) |
Check if we can push outer where condition to this derived table.
Returns true if a condition can be pushed down to derived table based on some constraints.
A condition cannot be pushed down to derived table if any of the following holds true:
Check which single table inside a view that matches a table map.
Find table in underlying tables by map and check that only this table belong to given map.
[out] | table_ref | reference to found table (must be set to NULL by caller) |
map | bit mask of tables |
false | table not found or found only one (table_ref is non-NULL) |
true | found several tables |
|
inline |
If non-NULL, the CTE which this table is derived from.
bool Table_ref::create_field_translation | ( | THD * | thd | ) |
Create field translation for merged derived table/view.
thd | Thread handle |
bool Table_ref::create_materialized_table | ( | THD * | thd | ) |
Create result table for a materialized derived table/view.
Create result table for a materialized derived table/view/table function.
thd | thread handle |
This function actually creates the result table for given 'derived' table/view, but it doesn't fill it.
|
inline |
|
inline |
Return the query expression of a derived table or view.
int Table_ref::fetch_number_of_rows | ( | ha_rows | fallback_estimate = PLACEHOLDER_TABLE_ROW_ESTIMATE | ) |
Retrieve number of rows in the table.
Retrieve number of rows in the table referred by this Table_ref and store it in the table's stats.records variable. If this Table_ref refers to a materialized derived table/view, then the estimated number of rows of the derived table/view is used instead.
fallback_estimate | A fallback row estimate to use if the storage engine doesn't provide one for us. The old optimizer uses PLACEHOLDER_TABLE_ROW_ESTIMATE, which is 2. The hypergraph optimizer uses a more pessimistic estimate of 1000 rows. |
Security_context * Table_ref::find_view_security_context | ( | THD * | thd | ) |
Find security context of current view.
thd | thread handler |
Table_ref * Table_ref::first_leaf_for_name_resolution | ( | ) |
Retrieve the first (left-most) leaf in a nested join tree with respect to name resolution.
Given that 'this' is a nested table reference, recursively walk down the left-most children of 'this' until we reach a leaf table reference with respect to name resolution.
The left-most child of a nested table reference is the last element in the list of children because the children are inserted in reverse order.
If | 'this' is a nested table reference - the left-most child of |
the | tree rooted in 'this', else return 'this' |
|
inline |
Return first leaf table of a base table or a view/derived table.
bool Table_ref::generate_keys | ( | ) |
Generate keys for a materialized derived table/view.
This function adds keys to the result table by walking over the list of possible keys for this derived table/view and calling the TABLE::add_tmp_key to actually add keys. A name <auto_keyN>, where N is a sequential number, is given to each key to ease debugging.
|
inline |
Returns the name of the database that the referenced table belongs to.
uint Table_ref::get_hidden_field_count_for_derived | ( | ) | const |
Return the number of hidden fields added for the temporary table created for this derived table.
double Table_ref::get_sampling_percentage | ( | ) | const |
|
inline |
|
inline |
Returns the name of the table that this Table_ref represents.
The unqualified table name or view name for a table or view, respectively.
|
inline |
|
inline |
|
inline |
|
inline |
Return true if table is being deleted from.
|
inline |
Return true if this represents a derived table (an unnamed view)
bool Table_ref::is_derived_unfinished_materialization | ( | ) | const |
bool Table_ref::is_external | ( | ) | const |
Is this table only available in an external storage engine?
|
inline |
Returns true if a MATCH function references this table.
|
inline |
Return true if this table is an inner table of some outer join.
Examine all the embedding join nests of the table.
|
inline |
Return true if table is insertable-into.
|
inline |
Return true if table is being inserted into.
|
inline |
bool Table_ref::is_leaf_for_name_resolution | ( | ) | const |
Test if this is a leaf with respect to name resolution.
A table reference is a leaf with respect to name resolution if it is either a leaf node in a nested join tree (table, view, schema table, subquery), or an inner node that represents a NATURAL/USING join, or a nested join with materialized join columns.
true | if a leaf, false otherwise. |
bool Table_ref::is_mergeable | ( | ) | const |
Return true if view or derived table and can be merged.
|
inline |
Return true if this is a derived table or view that is merged.
|
inline |
Return true if this is a view or derived table that is defined over more than one base table, and false otherwise.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return true if this represents a table function.
|
inline |
Compare the version of metadata from the previous execution (if any) with values obtained from the current table definition cache element.
|
inline |
Return true if table is updatable.
|
inline |
Return true if table is being updated.
|
inline |
Return true if this represents a named view.
|
inline |
Return true if this represents a named view or a derived table.
|
inline |
|
inline |
|
inline |
|
inline |
Table_ref * Table_ref::last_leaf_for_name_resolution | ( | ) |
Retrieve the last (right-most) leaf in a nested join tree with respect to name resolution.
Given that 'this' is a nested table reference, recursively walk down the right-most children of 'this' until we reach a leaf table reference with respect to name resolution.
The right-most child of a nested table reference is the first element in the list of children because the children are inserted in reverse order.
uint Table_ref::leaf_tables_count | ( | ) | const |
Return no. of base tables a merged view or derived table is defined over.
Return the number of leaf tables for a merged view.
|
inline |
|
inline |
Return table map derived from table number.
bool Table_ref::materializable_is_const | ( | ) | const |
Checks if this is a table that contains zero rows or one row, and that can be materialized during optimization.
Returning true, if the hypergraph optimizer is not active, implies that the table is materialized during optimization, so it need not be optimized during execution. The hypergraph optimizer does not care about const tables, so such tables are not executed during optimization time when it is active.
bool Table_ref::materialize_derived | ( | THD * | thd | ) |
Materialize derived table.
thd | Thread handle |
Derived table is resolved with temporary table. It is created based on the queries defined. After temporary table is materialized, if this is not EXPLAIN, then the entire unit / node is deleted. unit is deleted if UNION is used for derived table and node is deleted is it is a simple SELECT. If you use this function, make sure it's not called at prepare. Due to evaluation of LIMIT clause it can not be used at prepared stage.
bool Table_ref::merge_underlying_tables | ( | Query_block * | select | ) |
Merge tables from a query block into a nested join structure.
select | Query block containing tables to be merged into nested join |
bool Table_ref::merge_where | ( | THD * | thd | ) |
Merge WHERE condition of view or derived table into outer query.
If the derived table is on the inner side of an outer join, its WHERE condition is merged into the respective join operation's join condition, otherwise the WHERE condition is merged with the derived table's join condition.
thd | thread handler |
|
static |
Create a Table_ref object representing a nested join.
allocator | Mem root allocator that object is created from. |
alias | Name of nested join object |
embedding | Pointer to embedding join nest (or NULL if top-most) |
belongs_to | List of tables this nest belongs to (never NULL). |
select | The query block that this join nest belongs within. |
bool Table_ref::optimize_derived | ( | THD * | thd | ) |
Optimize the query expression representing a derived table/view.
thd | thread handle |
|
inline |
Returns the outer join nest that this Table_ref belongs to, if any.
There are two kinds of join nests, outer-join nests and semi-join nests. This function returns non-NULL in the following cases:
simplify_joins()
). Note: This function assumes that simplify_joins()
has been performed. Before that, join nests will be present for all types of join.bool Table_ref::prepare_check_option | ( | THD * | thd, |
bool | is_cascaded = false |
||
) |
Prepare check option for a view.
Prepare check option expression of table.
thd | thread handler |
is_cascaded | True if parent view requests that this view's filtering condition be treated as WITH CASCADED CHECK OPTION; this is for recursive calls; user code should omit this argument. |
This function builds check option condition for use in regular execution or subsequent SP/PS executions.
This function must be called after the WHERE clause and join condition of this and all underlying derived tables/views have been resolved.
The function will always call itself recursively for all underlying views and base tables.
On first invocation, the check option condition is built bottom-up in statement mem_root, and check_option_processed is set true.
On subsequent executions, check_option_processed is true and no expression building is necessary. However, the function needs to assure that the expression is resolved by calling fix_fields() on it.
bool Table_ref::prepare_replace_filter | ( | THD * | thd | ) |
Prepare replace filter for a view (used for REPLACE command)
Prepare replace filter for a table that is inserted into via a view.
Used with REPLACE command to filter out rows that should not be deleted. Concatenate WHERE clauses from multiple views into one permanent field: TABLE::replace_filter.
Since REPLACE is not possible against a join view, there is no need to process join conditions, only WHERE clause is needed. But we still call merge_join_conditions() since this is a general function that handles both join conditions (if any) and the original WHERE clause.
thd | thread handler |
bool Table_ref::prepare_security | ( | THD * | thd | ) |
Prepare security context for a view.
Prepare security context and load underlying tables privileges for view.
thd | thread handler |
false | OK |
true | Error |
bool Table_ref::prepare_view_security_context | ( | THD * | thd | ) |
Load security context information for this view.
thd | thread handler |
false | OK |
true | Error |
void Table_ref::print | ( | const THD * | thd, |
String * | str, | ||
enum_query_type | query_type | ||
) | const |
Produce a textual identification of this object.
Compiles the tagged hints list and fills up TABLE::keys_in_use_for_query, TABLE::keys_in_use_for_group_by, TABLE::keys_in_use_for_order_by, TABLE::force_index and TABLE::covering_keys.
Compiles the tagged hints list and fills up the bitmasks.
thd | The current session. |
tbl | the TABLE to operate on. |
The parser collects the index hints for each table in a "tagged list" (Table_ref::index_hints). Using the information in this tagged list this function sets the members st_table::keys_in_use_for_query, st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by, st_table::force_index, st_table::force_index_order, st_table::force_index_group and st_table::covering_keys.
Current implementation of the runtime does not allow mixing FORCE INDEX and USE INDEX, so this is checked here. Then the FORCE INDEX list (if non-empty) is appended to the USE INDEX list and a flag is set.
Multiple hints of the same kind are processed so that each clause is applied to what is computed in the previous clause. For example: USE INDEX (i1) USE INDEX (i2) is equivalent to USE INDEX (i1,i2) and means "consider only i1 and i2".
Similarly USE INDEX () USE INDEX (i1) is equivalent to USE INDEX (i1) and means "consider only the index i1"
It is OK to have the same index several times, e.g. "USE INDEX (i1,i1)" is not an error.
Different kind of hints (USE/FORCE/IGNORE) are processed in the following order:
e.g. "USE INDEX i1, IGNORE INDEX i1, USE INDEX i1" will not use i1 at all as if we had "USE INDEX i1, USE INDEX i1, IGNORE INDEX i1".
false | No errors found. |
true | Found and reported an error. |
uint Table_ref::query_block_id | ( | ) | const |
If a derived table, returns query block id of first underlying query block.
Zero if not derived.
uint Table_ref::query_block_id_for_explain | ( | ) | const |
This is for showing in EXPLAIN.
If a derived table, returns query block id of first underlying query block of first materialized Table_ref instance. Zero if not derived.
void Table_ref::reset | ( | void | ) |
Reset table.
Reset a table reference after preparation or execution, before (re-)execution.
bool Table_ref::resolve_derived | ( | THD * | thd, |
bool | apply_semijoin | ||
) |
Resolve a derived table or view reference.
Resolve a derived table or view reference, including recursively resolving contained subqueries.
thd | thread handle |
apply_semijoin | Apply possible semi-join transforms if this is true |
Give the unit to the result (the other fields are ignored).
void Table_ref::restore_properties | ( | ) |
Restore persistent properties into TABLE from Table_ref.
Required after a TABLE object has been rebound to a statement at start of execution of a prepared statement.
bool Table_ref::save_properties | ( | ) |
Save persistent properties from TABLE into Table_ref.
Required because some properties about a table are calculated inside TABLE but should last for the duration of the statement. Since the TABLEs are released after execution of a statement and rebound at start of next execution, those properties must be saved in Table_ref after a statement is prepared.
|
inline |
|
inline |
Set table and all referencing views as being deleted from.
|
inline |
|
inline |
Set the query expression of a derived table or view.
(Will also define this as a derived table, unless it is a named view.)
|
inline |
Set table as full-text search (default is not fulltext searched)
bool Table_ref::set_insert_values | ( | MEM_ROOT * | mem_root | ) |
Allocate a buffer for inserted column values.
Set insert_values buffer.
mem_root | memory pool for allocating |
|
inline |
Set table as insertable-into. (per default, a table is not insertable)
|
inline |
Set table and all referencing views as being inserted into.
|
inline |
|
inline |
|
inline |
|
inline |
Set table to be merged.
|
inline |
Set granted privileges for a table.
Can be used when generating temporary tables that are also used in resolver process, such as when generating a UNION table
privilege | Privileges granted for this table. |
|
inline |
Set table as readonly, ie it is neither updatable, insertable nor deletable during this statement.
bool Table_ref::set_recursive_reference | ( | ) |
|
inline |
Makes the next a semi/antijoin nest.
|
inline |
|
inline |
Record the value of metadata version of the corresponding table definition cache element in this parse tree node.
|
inline |
Set table number.
|
inline |
|
inline |
Set table as updatable. (per default, a table is non-updatable)
|
inline |
Set table and all referencing views as being updated.
|
inline |
Set table to be materialized.
|
inline |
Set the LEX object of a view (will also define this as a view).
bool Table_ref::setup_materialized_derived | ( | THD * | thd | ) |
Setup a derived table to use materialization.
Prepare a derived table or view for materialization.
The derived table must have been
thd | THD pointer |
bool Table_ref::setup_materialized_derived_tmp_table | ( | THD * | thd | ) |
Sets up the tmp table to contain the derived table's rows.
thd | THD pointer |
bool Table_ref::setup_table_function | ( | THD * | thd | ) |
Setup a table function to use materialization.
Prepare a table function for materialization.
thd | THD pointer |
|
inline |
Return table number.
|
inline |
|
inline |
Return the outermost view this table belongs to, or itself.
|
inline |
|
inline |
Return the base table entry of an updatable table.
In DELETE and UPDATE, a view used as a target table must be mergeable, updatable and defined over a single table.
bool Table_ref::update_derived_keys | ( | THD * | thd, |
Field * | field, | ||
Item ** | values, | ||
uint | num_values, | ||
bool * | allocated | ||
) |
Update derived table's list of possible keys.
thd | session context | |
field | derived table's field to take part in a key | |
values | array of values. Each value combined with "field" forms an equality predicate. | |
num_values | number of elements in the array values | |
[out] | allocated | true if key was allocated, false if unsupported |
This function creates/extends a list of possible keys for this derived table/view. For each table used by a value from the 'values' array the corresponding possible key is extended to include the 'field'. If there is no such possible key, then it is created. field's part_of_key bitmaps are updated accordingly.
bool Table_ref::update_sampling_percentage | ( | ) |
|
inline |
Return true if this is a materializable derived table/view.
bool Table_ref::validate_tablesample_clause | ( | THD * | thd | ) |
int Table_ref::view_check_option | ( | THD * | thd | ) | const |
Evaluate the check option of a view.
Check CHECK OPTION condition.
thd | thread handler |
VIEW_CHECK_OK | OK |
VIEW_CHECK_ERROR | FAILED |
VIEW_CHECK_SKIP | FAILED, but continue |
|
inline |
Return the valid LEX object for a view.
AccessPath* Table_ref::access_path_for_derived {nullptr} |
If we've previously made an access path for “derived”, it is cached here.
This is useful if we need to plan the query block twice (the hypergraph optimizer can do so, with and without in2exists predicates), both saving work and avoiding issues when we try to throw away the old items_to_copy for a new (identical) one.
ulonglong Table_ref::algorithm {0} |
The declared algorithm, if this is a view.
One of
const char * Table_ref::alias {nullptr} |
bool Table_ref::cacheable_table {false} |
stop PS caching
bool Table_ref::check_option_processed {false} |
true <=> VIEW CHECK OPTION condition is processed (also for prep. stmts)
COND_EQUAL* Table_ref::cond_equal {nullptr} |
Used with outer join.
bool Table_ref::contain_auto_increment {false} |
|
private |
const char* Table_ref::db {nullptr} |
size_t Table_ref::db_length {0} |
LEX_USER Table_ref::definer |
definer of view
table_map Table_ref::dep_tables {0} |
The set of tables in the query block that this table depends on.
Can be set due to outer join, join order hints or NOT EXISTS relationship.
|
private |
This field is set to non-null for derived tables and views.
It points to the Query_expression representing the derived table/view. E.g. for a query
SELECT * FROM (SELECT a FROM t1) b
List<Derived_key> Table_ref::derived_key_list |
bool Table_ref::derived_keys_ready {false} |
true <=> all possible keys for a derived table were collected and could be re-used while statement re-execution.
Query_result_union* Table_ref::derived_result {nullptr} |
|
private |
The view algorithm that is actually used, if this is a view.
Field_translator* Table_ref::field_translation {nullptr} |
Array of selected expressions from a derived table or view.
Field_translator* Table_ref::field_translation_end {nullptr} |
pointer to element after last one in translation table above
|
private |
|
private |
|
private |
GRANT_INFO Table_ref::grant |
bool Table_ref::ignore_leaves {false} |
preload only non-leaf nodes (IS THIS USED???)
List<Index_hint>* Table_ref::index_hints {nullptr} |
bool Table_ref::internal_tmp_table {false} |
bool Table_ref::is_alias {false} |
true if an alias for this table was specified in the SQL.
bool Table_ref::is_dd_ctx_table {false} |
bool Table_ref::is_fqtn {false} |
true if the table is referred to in the statement using a fully qualified name (<db_name>.
<table_name>).
bool Table_ref::is_join_columns_complete {false} |
bool Table_ref::is_natural_join {false} |
bool Table_ref::is_system_view {false} |
List<Natural_join_column>* Table_ref::join_columns {nullptr} |
table_map Table_ref::join_cond_dep_tables {0} |
The outer tables that an outer join's join condition depends on.
mem_root_deque<Table_ref *>* Table_ref::join_list {nullptr} |
The join list immediately containing this table reference.
bool Table_ref::join_order_swapped {false} |
True if was originally the left argument of a RIGHT JOIN, before we made it the right argument of a LEFT JOIN.
|
private |
|
private |
|
private |
|
private |
|
private |
If non-NULL, the CTE which this table is derived from.
|
private |
True if table is target of DELETE statement, or deleted in REPLACE stmt.
|
private |
If the user has specified column names with the syntaxes "table name parenthesis column names": WITH qn(column names) AS (select...) or FROM (select...) dt(column names) or CREATE VIEW v(column_names) AS ... then this points to the list of column names.
NULL otherwise.
|
private |
True if fulltext searched.
|
private |
True if VIEW/TABLE is insertable, based on analysis of query (SQL rules).
|
private |
True if table is target of INSERT statement.
|
private |
If a recursive reference inside the definition of a CTE.
|
private |
If this table or join nest is the Y in "X [LEFT] JOIN Y ON C", this member points to C.
May also be generated from JOIN ... USING clause. It may be modified only by permanent transformations (permanent = done once for all executions of a prepared statement).
Optimized copy of m_join_cond (valid for one single execution).
Initialized by Query_block::get_optimizable_conditions().
|
private |
|
private |
Table map, derived from m_tableno.
|
private |
See comments for set_metadata_id()
|
private |
See comments for TABLE_SHARE::get_table_ref_version()
|
private |
The members below must be kept aligned so that (1 << m_tableno) == m_map.
A table that takes part in a join operation must be assigned a unique table number. Table number within query block
|
private |
True if VIEW/TABLE is updatable, based on analysis of query (SQL rules).
|
private |
True if table is target of UPDATE statement, or updated in IODKU stmt.
bool Table_ref::m_was_scalar_subquery {false} |
If true, this table is a derived (materialized) table which was created from a scalar subquery, cf.
Query_block::transform_scalar_subqueries_to_join_with_derived
MDL_request Table_ref::mdl_request |
|
private |
NESTED_JOIN* Table_ref::nested_join {nullptr} |
Is non-NULL if this table reference is a nested join, ie it represents the inner tables of an outer join, the tables contained in the parentheses of an inner join (eliminated during resolving), the tables referenced in a derived table or view, in a semi-join nest, the tables from the subquery.
|
private |
enum { ... } Table_ref::OPEN_NORMAL |
Indicates that if Table_ref object corresponds to the table/view which requires special handling.
enum_open_type Table_ref::open_type {OT_TEMPORARY_OR_BASE} |
Specifies which kind of table should be open for this element of table list.
Opt_hints_qb* Table_ref::opt_hints_qb {nullptr} |
Opt_hints_table* Table_ref::opt_hints_table {nullptr} |
Table level optimizer hints for this table.
bool Table_ref::optimized_away {false} |
true <=> this table is a const one and was optimized away.
char* Table_ref::option {nullptr} |
bool Table_ref::outer_join {false} |
True if right argument of LEFT JOIN; false in other cases (i.e.
if left argument of LEFT JOIN, if argument of INNER JOIN; RIGHT JOINs are converted to LEFT JOIN during contextualization).
bool Table_ref::prelocking_placeholder {false} |
Query_block* Table_ref::query_block {nullptr} |
|
private |
|
private |
bool Table_ref::replace_filter_processed {false} |
true <=> Filter condition is processed
dd::enum_table_type Table_ref::required_type {} |
|
private |
|
private |
Sampling information.
Query_block* Table_ref::schema_query_block {nullptr} |
ST_SCHEMA_TABLE* Table_ref::schema_table {nullptr} |
bool Table_ref::schema_table_filled {false} |
bool Table_ref::schema_table_reformed {false} |
Security_context* Table_ref::security_ctx {nullptr} |
LEX_STRING Table_ref::select_stmt {nullptr, 0} |
text of (CREATE/SELECT) statement
uint Table_ref::shared {0} |
table_map Table_ref::sj_inner_tables {0} |
LEX_STRING Table_ref::source {nullptr, 0} |
source of CREATE VIEW
bool Table_ref::straight {false} |
Table_function* Table_ref::table_function {nullptr} |
mysql::binlog::event::Table_id Table_ref::table_id {} |
const char * Table_ref::table_name {nullptr} |
size_t Table_ref::table_name_length {0} |
LEX_CSTRING Table_ref::target_tablespace_name {nullptr, 0} |
LEX_STRING Table_ref::timestamp {nullptr, 0} |
GMT time stamp of last operation.
char Table_ref::timestamp_buffer[20] {0} |
uint8 Table_ref::trg_event_map {0} |
Indicates what triggers we need to pre-load for this Table_ref when opening an associated TABLE.
This is filled after the parsed tree is created.
ulonglong Table_ref::updatable_view {0} |
VIEW can be updated.
bool Table_ref::updating {false} |
True for tables and views being changed in a data change statement.
Also true for tables subject to a SELECT ... FOR UPDATE. Also used by replication to filter out statements that can be ignored, especially important for multi-table UPDATE and DELETE.
LEX_STRING Table_ref::view_body_utf8 {nullptr, 0} |
LEX_CSTRING Table_ref::view_client_cs_name {nullptr, 0} |
LEX_CSTRING Table_ref::view_connection_cl_name {nullptr, 0} |
View_creation_ctx* Table_ref::view_creation_ctx {nullptr} |
bool Table_ref::view_no_explain {false} |
if true, EXPLAIN can't explain view due to insufficient rights.
Security_context* Table_ref::view_sctx {nullptr} |
ulonglong Table_ref::view_suid {0} |
view is suid (true by default)
mem_root_deque<Table_ref *>* Table_ref::view_tables {nullptr} |
ulonglong Table_ref::with_check {0} |
WITH CHECK OPTION.
|
private |