MySQL  8.0.27
Source Code Documentation
TABLE_LIST Struct Reference

#include <table.h>

Inheritance diagram for TABLE_LIST:
RPL_TABLE_LIST

Public Types

enum  { OPEN_NORMAL = 0 , OPEN_IF_EXISTS , OPEN_FOR_CREATE , OPEN_STUB }
 Indicates that if TABLE_LIST object corresponds to the table/view which requires special handling. More...
 

Public Member Functions

 TABLE_LIST ()=default
 
 TABLE_LIST (TABLE *table_arg)
 Only to be used by legacy code that temporarily needs a TABLE_LIST, more specifically: Query_result_create::binlog_show_create_table(). More...
 
 TABLE_LIST (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_LIST (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_LIST object with pre-allocated strings for database, table and alias. More...
 
 TABLE_LIST (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_LIST (TABLE *table_arg, const char *alias_arg)
 This constructor can be used when a TABLE_LIST is needed for an existing temporary table. More...
 
 TABLE_LIST (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_LIST (const char *db_name, const char *table_name_arg, enum thr_lock_type lock_type_arg, enum enum_mdl_type mdl_request_type)
 
 TABLE_LIST (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_LIST (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_LIST (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_LIST (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_LIST (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 ()
 
Itemjoin_cond () const
 
void set_join_cond (Item *val)
 
Itemjoin_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 cleanup_items ()
 Cleanup field translations for 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_LIST **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_LISTfirst_leaf_for_name_resolution ()
 Retrieve the first (left-most) leaf in a nested join tree with respect to name resolution. More...
 
TABLE_LISTlast_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_LISTtop_table () const
 Return the outermost view this table belongs to, or itself. More...
 
TABLE_LISTtop_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...
 
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_LISTfirst_leaf_table ()
 Return first leaf table of a base table or a view/derived table. More...
 
TABLE_LISTany_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...
 
LEXview_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_expressionderived_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...
 
Itemget_derived_expr (uint expr_index)
 Get derived table expression. More...
 
Itemget_clone_for_derived_expr (THD *thd, Item *item, Name_resolution_context *context)
 Get cloned item for a derived table column. More...
 
void cleanup_derived (THD *thd)
 Clean up the query expression for a materialized derived table. More...
 
bool prepare_security (THD *thd)
 Prepare security context for a view. More...
 
Security_contextfind_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_LIST represents. More...
 
int fetch_number_of_rows ()
 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_LISTouter_join_nest () const
 Returns the outer join nest that this TABLE_LIST 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_LISTupdatable_base_table () const
 Return the base table entry of an updatable table. More...
 
TABLE_LISTupdatable_base_table ()
 
void add_join_natural (TABLE_LIST *b)
 Mark that there is a NATURAL JOIN or JOIN ... More...
 
void set_privileges (ulong privilege)
 Set granted privileges for a table. More...
 
bool save_properties ()
 Save persistent properties from TABLE into TABLE_LIST. More...
 
void restore_properties ()
 Restore persistent properties into TABLE from TABLE_LIST. More...
 
void set_lock (const Lock_descriptor &descriptor)
 
const Lock_descriptorlock_descriptor () 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_exprcommon_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_listderived_column_names () const
 
void set_derived_column_names (const Create_col_name_list *d)
 

Static Public Member Functions

static TABLE_LISTnew_nested_join (MEM_ROOT *allocator, const char *alias, TABLE_LIST *embedding, mem_root_deque< TABLE_LIST * > *belongs_to, Query_block *select)
 Create a TABLE_LIST object representing a nested join. More...
 

Public Attributes

TABLE_LISTnext_local {nullptr}
 
TABLE_LISTnext_global {nullptr}
 
TABLE_LIST ** 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_tableopt_hints_table {nullptr}
 Table level optimizer hints for this table. More...
 
Opt_hints_qbopt_hints_qb {nullptr}
 
table_map sj_inner_tables {0}
 
TABLE_LISTnatural_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_LISTnext_name_resolution_table {nullptr}
 
List< Index_hint > * index_hints {nullptr}
 
TABLEtable {nullptr}
 
Table_id table_id {}
 
Query_result_unionderived_result {nullptr}
 
TABLE_LISTcorrespondent_table {nullptr}
 
Table_functiontable_function {nullptr}
 
AccessPathaccess_path_for_derived {nullptr}
 If we've previously made an access path for “derived”, it is cached here. More...
 
ST_SCHEMA_TABLEschema_table {nullptr}
 
Query_blockschema_query_block {nullptr}
 
bool schema_table_reformed {false}
 
Temp_table_paramschema_table_param {nullptr}
 
Query_blockquery_block {nullptr}
 
Field_translatorfield_translation {nullptr}
 Array of selected expressions from a derived table or view. More...
 
Field_translatorfield_translation_end {nullptr}
 pointer to element after last one in translation table above More...
 
TABLE_LISTmerge_underlying_list {nullptr}
 
mem_root_deque< TABLE_LIST * > * view_tables {nullptr}
 
TABLE_LISTbelong_to_view {nullptr}
 
TABLE_LISTreferencing_view {nullptr}
 
TABLE_LISTparent_l {nullptr}
 
Security_contextsecurity_ctx {nullptr}
 
Security_contextview_sctx {nullptr}
 
TABLE_LISTnext_leaf {nullptr}
 
Itemderived_where_cond {nullptr}
 WHERE condition from derived table. More...
 
Itemcheck_option {nullptr}
 WITH CHECK OPTION condition. More...
 
Itemreplace_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...
 
Name_resolution_contextm_merged_derived_context {nullptr}
 Context that is used to resolve a merged derived table's fields. 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_JOINnested_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_LISTembedding {nullptr}
 The nested join containing this table reference. More...
 
mem_root_deque< TABLE_LIST * > * 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_LIST:: { ... }  OPEN_NORMAL
 Indicates that if TABLE_LIST 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_ctxview_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_keyderived_key_list
 
uint8 trg_event_map {0}
 Indicates what triggers we need to pre-load for this TABLE_LIST when opening an associated TABLE. More...
 
uint i_s_requested_object {0}
 
bool has_db_lookup_value {false}
 
bool has_table_lookup_value {false}
 
uint table_open_method {0}
 
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_EQUALcond_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...
 
Itemm_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}
 
Query_expressionderived {nullptr}
 This field is set to non-null for derived tables and views. More...
 
Common_table_exprm_common_table_expr {nullptr}
 If non-NULL, the CTE which this table is derived from. More...
 
const Create_col_name_listm_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 ... More...
 
LEXview {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...
 
Itemm_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_map read_set_small [bitmap_buffer_size(64)/sizeof(my_bitmap_map)]
 
my_bitmap_map write_set_small [bitmap_buffer_size(64)/sizeof(my_bitmap_map)]
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Indicates that if TABLE_LIST object corresponds to the table/view which requires special handling.

Enumerator
OPEN_NORMAL 
OPEN_IF_EXISTS 
OPEN_FOR_CREATE 
OPEN_STUB 

Constructor & Destructor Documentation

◆ TABLE_LIST() [1/13]

TABLE_LIST::TABLE_LIST ( )
default

◆ TABLE_LIST() [2/13]

TABLE_LIST::TABLE_LIST ( TABLE table_arg)
inlineexplicit

Only to be used by legacy code that temporarily needs a TABLE_LIST, more specifically: Query_result_create::binlog_show_create_table().

◆ TABLE_LIST() [3/13]

TABLE_LIST::TABLE_LIST ( const char *  db_name,
const char *  table_name,
enum thr_lock_type  lock_type 
)
inline

Constructor that can be used when the strings are null terminated.

◆ TABLE_LIST() [4/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

Creates a TABLE_LIST object with pre-allocated strings for database, table and alias.

◆ TABLE_LIST() [5/13]

TABLE_LIST::TABLE_LIST ( const char *  db_name,
const char *  table_name,
const char *  alias,
enum thr_lock_type  lock_type 
)
inline

Constructor that can be used when the strings are null terminated.

◆ TABLE_LIST() [6/13]

TABLE_LIST::TABLE_LIST ( TABLE table_arg,
const char *  alias_arg 
)
inline

This constructor can be used when a TABLE_LIST 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.

◆ TABLE_LIST() [7/13]

TABLE_LIST::TABLE_LIST ( TABLE table_arg,
const char *  alias_arg,
enum_mdl_type  mdl_type 
)
inline

Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor.

◆ TABLE_LIST() [8/13]

TABLE_LIST::TABLE_LIST ( const char *  db_name,
const char *  table_name_arg,
enum thr_lock_type  lock_type_arg,
enum enum_mdl_type  mdl_request_type 
)
inline

◆ TABLE_LIST() [9/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

◆ TABLE_LIST() [10/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

◆ TABLE_LIST() [11/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

Sets an explicit enum_mdl_type value, without initializing m_lock_descriptor.

◆ TABLE_LIST() [12/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

◆ TABLE_LIST() [13/13]

TABLE_LIST::TABLE_LIST ( 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 
)
inline

Member Function Documentation

◆ add_join_natural()

void TABLE_LIST::add_join_natural ( TABLE_LIST b)
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_LIST::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>)
Parameters
bRight join argument.

◆ any_outer_leaf_table()

TABLE_LIST* TABLE_LIST::any_outer_leaf_table ( )
inline

Return any leaf table that is not an inner table of an outer join.

◆ can_push_condition_to_derived()

bool TABLE_LIST::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.

Hint and/or optimizer switch derived_condition_pushdown must be on.

A condition cannot be pushed down to derived table if any of the following holds true:

  1. If the derived table has UNION - Implementation restriction
  2. If it has LIMIT - If the derived table has LIMIT, then the pushed condition would affect the number of rows that would be fetched.
  3. It cannot be an inner table of an outer join - that would lead to more NULL-complemented rows.
  4. This cannot be a CTE having derived tables being referenced multiple times - there is only one temporary table for both references, if materialized ("shared materialization").

◆ check_single_table()

bool TABLE_LIST::check_single_table ( TABLE_LIST **  table_ref,
table_map  map 
)

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.

Parameters
[out]table_refreference to found table (must be set to NULL by caller)
mapbit mask of tables
Return values
falsetable not found or found only one (table_ref is non-NULL)
truefound several tables

◆ cleanup_derived()

void TABLE_LIST::cleanup_derived ( THD thd)

Clean up the query expression for a materialized derived table.

◆ cleanup_items()

void TABLE_LIST::cleanup_items ( )

Cleanup field translations for a view.

Cleanup items belonged to view fields translation table.

◆ common_table_expr()

Common_table_expr* TABLE_LIST::common_table_expr ( ) const
inline

If non-NULL, the CTE which this table is derived from.

◆ create_field_translation()

bool TABLE_LIST::create_field_translation ( THD thd)

Create field translation for merged derived table/view.

Parameters
thdThread handle
Returns
false if success, true if error.

◆ create_materialized_table()

bool TABLE_LIST::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.

Parameters
thdthread handle

This function actually creates the result table for given 'derived' table/view, but it doesn't fill it.

Returns
false if success, true if error.

◆ derived_column_names()

const Create_col_name_list* TABLE_LIST::derived_column_names ( ) const
inline
See also
m_derived_column_names

◆ derived_query_expression()

Query_expression* TABLE_LIST::derived_query_expression ( ) const
inline

Return the query expression of a derived table or view.

◆ fetch_number_of_rows()

int TABLE_LIST::fetch_number_of_rows ( )

Retrieve number of rows in the table.

Retrieve number of rows in the table referred by this TABLE_LIST and store it in the table's stats.records variable. If this TABLE_LIST refers to a materialized derived table/view, then the estimated number of rows of the derived table/view is used instead.

Returns
0 ok
non zero error

◆ find_view_security_context()

Security_context * TABLE_LIST::find_view_security_context ( THD thd)

Find security context of current view.

Parameters
thdthread handler

◆ first_leaf_for_name_resolution()

TABLE_LIST * TABLE_LIST::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.

Return values
If'this' is a nested table reference - the left-most child of
thetree rooted in 'this', else return 'this'

◆ first_leaf_table()

TABLE_LIST* TABLE_LIST::first_leaf_table ( )
inline

Return first leaf table of a base table or a view/derived table.

◆ generate_keys()

bool TABLE_LIST::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.

See also
add_derived_key
Returns
true an error occur.
false all keys were successfully added.

◆ get_clone_for_derived_expr()

Item * TABLE_LIST::get_clone_for_derived_expr ( THD thd,
Item item,
Name_resolution_context context 
)

Get cloned item for a derived table column.

Create a clone for an expression of materialized derived table.

This creates the clone and resolves it in the context provided.

This clone will be used for pushing conditions down to this table. When pushing a condition down to this table, columns in the condition are replaced with this derived table's expressions. If there are nested derived tables, these columns will be replaced again with another derived table's expression when the condition is pushed further down. However at this point, same column needs to be part of the SELECT clause of this derived table and the WHERE clause of another derived table where the condition is pushed down (Example below). To keep the sanity of this table's expression, a clone is created and used before pushing a condition down. To clone an expression, we re-parse the expression to get another copy.

Ex: Where cloned objects become necessary

Consider a query like this one: SELECT * FROM (SELECT i+10 AS n FROM (SELECT a+7 AS i FROM t1) AS dt1 ) AS dt2 WHERE n > 100;

The first call to Query_block::push_conditions_to_derived_tables would result in the following query. "n" in the where clause is replaced with (i+10). SELECT * FROM (SELECT i+10 AS n FROM (SELECT a+7 AS i FROM t1) AS dt1 WHERE (dt1.i+10) > 100) as dt2;

The next call to Query_block::push_conditions_to_derived_tables should result in the following query. "i" is replaced with "a+7". SELECT * FROM (SELECT i+10 AS n FROM (SELECT a+7 AS i FROM t1 WHERE ((t1.a+7)+10) > 100) AS dt1) as dt2;

However without cloned expressions, it would be

SELECT * FROM (SELECT ((t1.a+7)+10) AS n FROM (SELECT a+7 AS i FROM t1 WHERE ((t1.a+7)+10) > 100) AS dt1) as dt2;

Notice that the column "i" in derived table dt2 is getting replaced with (a+7) because the argument of the function in Item_func_plus in (i+10) is replaced with (a+7). The arguments to the function (i+10) need to be different so as to be able to replace them with some other expressions later.

Parameters
[in]thdCurrent thread
[in]itemItem for which clone is requested
[in]contextContext used for resolving the cloned item.
Returns
Cloned object for the item.

◆ get_db_name()

const char* TABLE_LIST::get_db_name ( ) const
inline

Returns the name of the database that the referenced table belongs to.

◆ get_derived_expr()

Item * TABLE_LIST::get_derived_expr ( uint  expr_index)

Get derived table expression.

Get the expression from derived table using its position in the derived table's fields list.

Parameters
[in]expr_indexposition in the fields list of the table
Returns
expression from the derived table.

◆ get_table_name()

const char* TABLE_LIST::get_table_name ( ) const
inline

Returns the name of the table that this TABLE_LIST represents.

The unqualified table name or view name for a table or view, respectively.

◆ is_aj_nest()

bool TABLE_LIST::is_aj_nest ( ) const
inline
Returns
true if anti-join nest

◆ is_base_table()

bool TABLE_LIST::is_base_table ( ) const
inline
Returns
true if this is a base table (permanent or temporary)

◆ is_deleted()

bool TABLE_LIST::is_deleted ( ) const
inline

Return true if table is being deleted from.

◆ is_derived()

bool TABLE_LIST::is_derived ( ) const
inline

Return true if this represents a derived table (an unnamed view)

◆ is_fulltext_searched()

bool TABLE_LIST::is_fulltext_searched ( ) const
inline

Returns true if a MATCH function references this table.

◆ is_inner_table_of_outer_join()

bool TABLE_LIST::is_inner_table_of_outer_join ( ) const
inline

Return true if this table is an inner table of some outer join.

Examine all the embedding join nests of the table.

Note
This function works also before redundant join nests have been eliminated.
Returns
true if table is an inner table of some outer join, false otherwise.

◆ is_insertable()

bool TABLE_LIST::is_insertable ( ) const
inline

Return true if table is insertable-into.

◆ is_inserted()

bool TABLE_LIST::is_inserted ( ) const
inline

Return true if table is being inserted into.

◆ is_internal()

bool TABLE_LIST::is_internal ( ) const
inline
Returns
true for a table that represents an optimizer internal table, is a derived table, a recursive reference, a table function. Internal tables are only visible inside a query expression, and is hence not visible in any schema, or need any kind of privilege checking.

◆ is_leaf_for_name_resolution()

bool TABLE_LIST::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.

Return values
trueif a leaf, false otherwise.

◆ is_mergeable()

bool TABLE_LIST::is_mergeable ( ) const

Return true if view or derived table and can be merged.

Returns
true if view or derived table is mergeable, based on technical constraints.

◆ is_merged()

bool TABLE_LIST::is_merged ( ) const
inline

Return true if this is a derived table or view that is merged.

◆ is_multiple_tables()

bool TABLE_LIST::is_multiple_tables ( ) const
inline

Return true if this is a view or derived table that is defined over more than one base table, and false otherwise.

◆ is_placeholder()

bool TABLE_LIST::is_placeholder ( ) const
inline
Returns
true for a table that is a placeholder, ie a derived table, a view, a recursive reference, a table function or a schema table. A table is also considered to be a placeholder if it does not have a TABLE object for some other reason.

◆ is_recursive_reference()

bool TABLE_LIST::is_recursive_reference ( ) const
inline
Returns
true if this is a recursive reference inside the definition of a recursive CTE.
Note
that it starts its existence as a dummy derived table, until the end of resolution when it's not a derived table anymore, just a reference to the materialized temporary table. Whereas a non-recursive reference to the recursive CTE is a derived table.

◆ is_sj_nest()

bool TABLE_LIST::is_sj_nest ( ) const
inline
Returns
true if semi-join nest

◆ is_sj_or_aj_nest()

bool TABLE_LIST::is_sj_or_aj_nest ( ) const
inline
Returns
true if anti/semi-join nest

◆ is_table_function()

bool TABLE_LIST::is_table_function ( ) const
inline

Return true if this represents a table function.

◆ is_table_ref_id_equal()

bool TABLE_LIST::is_table_ref_id_equal ( TABLE_SHARE s) const
inline

Compare the version of metadata from the previous execution (if any) with values obtained from the current table definition cache element.

See also
check_and_update_table_version()

◆ is_updatable()

bool TABLE_LIST::is_updatable ( ) const
inline

Return true if table is updatable.

◆ is_updated()

bool TABLE_LIST::is_updated ( ) const
inline

Return true if table is being updated.

◆ is_view()

bool TABLE_LIST::is_view ( ) const
inline

Return true if this represents a named view.

◆ is_view_or_derived()

bool TABLE_LIST::is_view_or_derived ( ) const
inline

Return true if this represents a named view or a derived table.

◆ join_cond()

Item* TABLE_LIST::join_cond ( ) const
inline

◆ join_cond_optim()

Item* TABLE_LIST::join_cond_optim ( ) const
inline

◆ join_cond_optim_ref()

Item** TABLE_LIST::join_cond_optim_ref ( )
inline

◆ join_cond_ref()

Item** TABLE_LIST::join_cond_ref ( )
inline

◆ last_leaf_for_name_resolution()

TABLE_LIST * TABLE_LIST::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.

Returns
  • If 'this' is a nested table reference - the right-most child of the tree rooted in 'this',
  • else - 'this'

◆ leaf_tables_count()

uint TABLE_LIST::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.

◆ lock_descriptor()

const Lock_descriptor& TABLE_LIST::lock_descriptor ( ) const
inline

◆ map()

table_map TABLE_LIST::map ( ) const
inline

Return table map derived from table number.

◆ materializable_is_const()

bool TABLE_LIST::materializable_is_const ( ) const

Checks if this is a table that contains zero rows or one row, and that can be materialized during optimization.

Returns
true if materializable table contains one or zero rows, and materialization during optimization is permitted

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.

◆ materialize_derived()

bool TABLE_LIST::materialize_derived ( THD thd)

Materialize derived table.

Parameters
thdThread 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.

Returns
false if success, true if error.

◆ merge_underlying_tables()

bool TABLE_LIST::merge_underlying_tables ( Query_block select)

Merge tables from a query block into a nested join structure.

Parameters
selectQuery block containing tables to be merged into nested join
Returns
false if success, true if error

◆ merge_where()

bool TABLE_LIST::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.

Parameters
thdthread handler
Returns
false if success, true if error

◆ new_nested_join()

TABLE_LIST * TABLE_LIST::new_nested_join ( MEM_ROOT allocator,
const char *  alias,
TABLE_LIST embedding,
mem_root_deque< TABLE_LIST * > *  belongs_to,
Query_block select 
)
static

Create a TABLE_LIST object representing a nested join.

Parameters
allocatorMem root allocator that object is created from.
aliasName of nested join object
embeddingPointer to embedding join nest (or NULL if top-most)
belongs_toList of tables this nest belongs to (never NULL).
selectThe query block that this join nest belongs within.
Returns
Pointer to created join nest object, or NULL if error.

◆ optimize_derived()

bool TABLE_LIST::optimize_derived ( THD thd)

Optimize the query expression representing a derived table/view.

Note
If optimizer finds out that the derived table/view is of the type "SELECT a_constant" this functions also materializes it.
Parameters
thdthread handle
Returns
false if success, true if error.

◆ outer_join_nest()

TABLE_LIST* TABLE_LIST::outer_join_nest ( ) const
inline

Returns the outer join nest that this TABLE_LIST 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:

  • 1. If this table/nest is embedded in a nest and this nest IS NOT a semi-join nest. (In other words, it is an outer-join nest.)
  • 2. If this table/nest is embedded in a nest and this nest IS a semi-join nest, but this semi-join nest is embedded in another nest. (This other nest will be an outer-join nest, since all inner joined nested semi-join nests have been merged in simplify_joins() ). Note: This function assumes that simplify_joins() has been performed. Before that, join nests will be present for all types of join.
Returns
outer join nest, or NULL if none.

◆ prepare_check_option()

bool TABLE_LIST::prepare_check_option ( THD thd,
bool  is_cascaded = false 
)

Prepare check option for a view.

Prepare check option expression of table.

Parameters
thdthread handler
is_cascadedTrue 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.

Returns
false if success, true if error

◆ prepare_replace_filter()

bool TABLE_LIST::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.

Parameters
thdthread handler
Returns
false if success, true if error

◆ prepare_security()

bool TABLE_LIST::prepare_security ( THD thd)

Prepare security context for a view.

Prepare security context and load underlying tables priveleges for view.

Parameters
thdthread handler
Return values
falseOK
trueError

◆ prepare_view_security_context()

bool TABLE_LIST::prepare_view_security_context ( THD thd)

Load security context information for this view.

Parameters
thdthread handler
Return values
falseOK
trueError

◆ print()

void TABLE_LIST::print ( const THD thd,
String str,
enum_query_type  query_type 
) const

Produce a textual identification of this object.

◆ process_index_hints()

bool TABLE_LIST::process_index_hints ( const THD thd,
TABLE tbl 
)

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.

Parameters
thdThe current session.
tblthe TABLE to operate on.

The parser collects the index hints for each table in a "tagged list" (TABLE_LIST::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:

  1. All indexes in USE (or FORCE) INDEX are added to the mask.
  2. All IGNORE INDEX

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".

Return values
falseNo errors found.
trueFound and reported an error.

◆ query_block_id()

uint TABLE_LIST::query_block_id ( ) const

If a derived table, returns query block id of first underlying query block.

Zero if not derived.

◆ query_block_id_for_explain()

uint TABLE_LIST::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_LIST instance. Zero if not derived.

◆ reset()

void TABLE_LIST::reset ( void  )

Reset table.

Reset a table reference after preparation or execution, before (re-)execution.

◆ resolve_derived()

bool TABLE_LIST::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.

Parameters
thdthread handle
apply_semijoinApply possible semi-join transforms if this is true
Returns
false if success, true if error

Give the unit to the result (the other fields are ignored).

◆ restore_properties()

void TABLE_LIST::restore_properties ( )

Restore persistent properties into TABLE from TABLE_LIST.

Required after a TABLE object has been rebound to a statement at start of execution of a prepared statement.

◆ save_properties()

bool TABLE_LIST::save_properties ( )

Save persistent properties from TABLE into TABLE_LIST.

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_LIST after a statement is prepared.

Returns
false if success, true if error

◆ set_common_table_expr()

void TABLE_LIST::set_common_table_expr ( Common_table_expr c)
inline

◆ set_deleted()

void TABLE_LIST::set_deleted ( )
inline

Set table and all referencing views as being deleted from.

◆ set_derived_column_names()

void TABLE_LIST::set_derived_column_names ( const Create_col_name_list d)
inline

◆ set_derived_query_expression()

void TABLE_LIST::set_derived_query_expression ( Query_expression query_expr)
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.)

◆ set_fulltext_searched()

void TABLE_LIST::set_fulltext_searched ( )
inline

Set table as full-text search (default is not fulltext searched)

◆ set_insert_values()

bool TABLE_LIST::set_insert_values ( MEM_ROOT mem_root)

Allocate a buffer for inserted column values.

Set insert_values buffer.

Parameters
mem_rootmemory pool for allocating
Returns
false if success, true if error (out of memory)

◆ set_insertable()

void TABLE_LIST::set_insertable ( )
inline

Set table as insertable-into. (per default, a table is not insertable)

◆ set_inserted()

void TABLE_LIST::set_inserted ( )
inline

Set table and all referencing views as being inserted into.

◆ set_join_cond()

void TABLE_LIST::set_join_cond ( Item val)
inline

◆ set_join_cond_optim()

void TABLE_LIST::set_join_cond_optim ( Item cond)
inline

◆ set_lock()

void TABLE_LIST::set_lock ( const Lock_descriptor descriptor)
inline

◆ set_merged()

void TABLE_LIST::set_merged ( )
inline

Set table to be merged.

◆ set_privileges()

void TABLE_LIST::set_privileges ( ulong  privilege)
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

Parameters
privilegePrivileges granted for this table.

◆ set_readonly()

void TABLE_LIST::set_readonly ( )
inline

Set table as readonly, ie it is neither updatable, insertable nor deletable during this statement.

◆ set_recursive_reference()

bool TABLE_LIST::set_recursive_reference ( )
See also
is_recursive_reference().
Returns
true if error

◆ set_sj_or_aj_nest()

void TABLE_LIST::set_sj_or_aj_nest ( )
inline

Makes the next a semi/antijoin nest.

◆ set_table_ref_id() [1/2]

void TABLE_LIST::set_table_ref_id ( enum_table_ref_type  table_ref_type_arg,
ulonglong  table_ref_version_arg 
)
inline

◆ set_table_ref_id() [2/2]

void TABLE_LIST::set_table_ref_id ( TABLE_SHARE s)
inline

Record the value of metadata version of the corresponding table definition cache element in this parse tree node.

See also
check_and_update_table_version()

◆ set_tableno()

void TABLE_LIST::set_tableno ( uint  tableno)
inline

Set table number.

◆ set_updatable()

void TABLE_LIST::set_updatable ( )
inline

Set table as updatable. (per default, a table is non-updatable)

◆ set_updated()

void TABLE_LIST::set_updated ( )
inline

Set table and all referencing views as being updated.

◆ set_uses_materialization()

void TABLE_LIST::set_uses_materialization ( )
inline

Set table to be materialized.

◆ set_view_query()

void TABLE_LIST::set_view_query ( LEX lex)
inline

Set the LEX object of a view (will also define this as a view).

Note
: The value 1 is used to indicate a view but without a valid query object. Use only if the LEX object is not going to be used in later processing.

◆ setup_materialized_derived()

bool TABLE_LIST::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

  • resolved by resolve_derived(),
  • or resolved as a subquery (by Item_*_subselect_fix_fields()) then converted to a derived table.
Parameters
thdTHD pointer
Returns
false if successful, true if error

◆ setup_materialized_derived_tmp_table()

bool TABLE_LIST::setup_materialized_derived_tmp_table ( THD thd)

Sets up the tmp table to contain the derived table's rows.

Parameters
thdTHD pointer
Returns
false if successful, true if error

◆ setup_table_function()

bool TABLE_LIST::setup_table_function ( THD thd)

Setup a table function to use materialization.

Prepare a table function for materialization.

Parameters
thdTHD pointer
Returns
false if successful, true if error

◆ tableno()

uint TABLE_LIST::tableno ( ) const
inline

Return table number.

◆ top_table() [1/2]

TABLE_LIST* TABLE_LIST::top_table ( )
inline

◆ top_table() [2/2]

const TABLE_LIST* TABLE_LIST::top_table ( ) const
inline

Return the outermost view this table belongs to, or itself.

◆ updatable_base_table() [1/2]

TABLE_LIST* TABLE_LIST::updatable_base_table ( )
inline

◆ updatable_base_table() [2/2]

const TABLE_LIST* TABLE_LIST::updatable_base_table ( ) const
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.

◆ update_derived_keys()

bool TABLE_LIST::update_derived_keys ( THD thd,
Field field,
Item **  values,
uint  num_values,
bool *  allocated 
)

Update derived table's list of possible keys.

Parameters
thdsession context
fieldderived table's field to take part in a key
valuesarray of values. Each value combined with "field" forms an equality predicate.
num_valuesnumber of elements in the array values
[out]allocatedtrue 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.

See also
add_derived_key
Returns
false if success, true if error

◆ uses_materialization()

bool TABLE_LIST::uses_materialization ( ) const
inline

Return true if this is a materializable derived table/view.

◆ view_check_option()

int TABLE_LIST::view_check_option ( THD thd) const

Evaluate the check option of a view.

Check CHECK OPTION condition.

Parameters
thdthread handler
Return values
VIEW_CHECK_OKOK
VIEW_CHECK_ERRORFAILED
VIEW_CHECK_SKIPFAILED, but continue

◆ view_query()

LEX* TABLE_LIST::view_query ( ) const
inline

Return the valid LEX object for a view.

Member Data Documentation

◆ access_path_for_derived

AccessPath* TABLE_LIST::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.

◆ algorithm

ulonglong TABLE_LIST::algorithm {0}

The declared algorithm, if this is a view.

One of

  • VIEW_ALGORITHM_UNDEFINED
  • VIEW_ALGORITHM_TEMPTABLE
  • VIEW_ALGORITHM_MERGE

◆ alias

const char * TABLE_LIST::alias {nullptr}

◆ belong_to_view

TABLE_LIST* TABLE_LIST::belong_to_view {nullptr}

◆ cacheable_table

bool TABLE_LIST::cacheable_table {false}

stop PS caching

◆ check_option

Item* TABLE_LIST::check_option {nullptr}

WITH CHECK OPTION condition.

◆ check_option_processed

bool TABLE_LIST::check_option_processed {false}

true <=> VIEW CHECK OPTION condition is processed (also for prep. stmts)

◆ cond_equal

COND_EQUAL* TABLE_LIST::cond_equal {nullptr}

Used with outer join.

◆ contain_auto_increment

bool TABLE_LIST::contain_auto_increment {false}

◆ correspondent_table

TABLE_LIST* TABLE_LIST::correspondent_table {nullptr}

◆ covering_keys_saved

Key_map TABLE_LIST::covering_keys_saved
private

◆ db

const char* TABLE_LIST::db {nullptr}

◆ db_length

size_t TABLE_LIST::db_length {0}

◆ definer

LEX_USER TABLE_LIST::definer

definer of view

◆ dep_tables

table_map TABLE_LIST::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.

◆ derived

Query_expression* TABLE_LIST::derived {nullptr}
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 

◆ derived_key_list

List<Derived_key> TABLE_LIST::derived_key_list

◆ derived_keys_ready

bool TABLE_LIST::derived_keys_ready {false}

true <=> all possible keys for a derived table were collected and could be re-used while statement re-execution.

◆ derived_result

Query_result_union* TABLE_LIST::derived_result {nullptr}

◆ derived_where_cond

Item* TABLE_LIST::derived_where_cond {nullptr}

WHERE condition from derived table.

◆ effective_algorithm

enum_view_algorithm TABLE_LIST::effective_algorithm {VIEW_ALGORITHM_UNDEFINED}
private

The view algorithm that is actually used, if this is a view.

◆ embedding

TABLE_LIST* TABLE_LIST::embedding {nullptr}

The nested join containing this table reference.

◆ field_translation

Field_translator* TABLE_LIST::field_translation {nullptr}

Array of selected expressions from a derived table or view.

◆ field_translation_end

Field_translator* TABLE_LIST::field_translation_end {nullptr}

pointer to element after last one in translation table above

◆ force_index_group_saved

bool TABLE_LIST::force_index_group_saved {false}
private

◆ force_index_order_saved

bool TABLE_LIST::force_index_order_saved {false}
private

◆ force_index_saved

bool TABLE_LIST::force_index_saved {false}
private

◆ grant

GRANT_INFO TABLE_LIST::grant

◆ has_db_lookup_value

bool TABLE_LIST::has_db_lookup_value {false}

◆ has_table_lookup_value

bool TABLE_LIST::has_table_lookup_value {false}

◆ i_s_requested_object

uint TABLE_LIST::i_s_requested_object {0}

◆ ignore_leaves

bool TABLE_LIST::ignore_leaves {false}

preload only non-leaf nodes (IS THIS USED???)

◆ index_hints

List<Index_hint>* TABLE_LIST::index_hints {nullptr}

◆ internal_tmp_table

bool TABLE_LIST::internal_tmp_table {false}

◆ is_alias

bool TABLE_LIST::is_alias {false}

true if an alias for this table was specified in the SQL.

◆ is_dd_ctx_table

bool TABLE_LIST::is_dd_ctx_table {false}

◆ is_fqtn

bool TABLE_LIST::is_fqtn {false}

true if the table is referred to in the statement using a fully qualified name (<db_name>.

<table_name>).

◆ is_join_columns_complete

bool TABLE_LIST::is_join_columns_complete {false}

◆ is_natural_join

bool TABLE_LIST::is_natural_join {false}

◆ is_system_view

bool TABLE_LIST::is_system_view {false}

◆ join_columns

List<Natural_join_column>* TABLE_LIST::join_columns {nullptr}

◆ join_cond_dep_tables

table_map TABLE_LIST::join_cond_dep_tables {0}

The outer tables that an outer join's join condition depends on.

◆ join_list

mem_root_deque<TABLE_LIST *>* TABLE_LIST::join_list {nullptr}

The join list immediately containing this table reference.

◆ join_order_swapped

bool TABLE_LIST::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.

◆ join_using_fields

List<String>* TABLE_LIST::join_using_fields {nullptr}

◆ keys_in_use_for_group_by_saved

Key_map TABLE_LIST::keys_in_use_for_group_by_saved
private

◆ keys_in_use_for_order_by_saved

Key_map TABLE_LIST::keys_in_use_for_order_by_saved
private

◆ keys_in_use_for_query_saved

Key_map TABLE_LIST::keys_in_use_for_query_saved
private

◆ lock_partitions_saved

MY_BITMAP TABLE_LIST::lock_partitions_saved
private

◆ m_common_table_expr

Common_table_expr* TABLE_LIST::m_common_table_expr {nullptr}
private

If non-NULL, the CTE which this table is derived from.

◆ m_deleted

bool TABLE_LIST::m_deleted {false}
private

True if table is target of DELETE statement, or deleted in REPLACE stmt.

◆ m_derived_column_names

const Create_col_name_list* TABLE_LIST::m_derived_column_names {nullptr}
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.

◆ m_fulltext_searched

bool TABLE_LIST::m_fulltext_searched {false}
private

True if fulltext searched.

◆ m_insertable

bool TABLE_LIST::m_insertable {false}
private

True if VIEW/TABLE is insertable, based on analysis of query (SQL rules).

◆ m_inserted

bool TABLE_LIST::m_inserted {false}
private

True if table is target of INSERT statement.

◆ m_is_recursive_reference

bool TABLE_LIST::m_is_recursive_reference {false}
private

If a recursive reference inside the definition of a CTE.

◆ m_is_sj_or_aj_nest

bool TABLE_LIST::m_is_sj_or_aj_nest {false}
private

◆ m_join_cond

Item* TABLE_LIST::m_join_cond {nullptr}
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).

◆ m_join_cond_optim

Item* TABLE_LIST::m_join_cond_optim {nullptr}
private

Optimized copy of m_join_cond (valid for one single execution).

Initialized by Query_block::get_optimizable_conditions().

◆ m_lock_descriptor

Lock_descriptor TABLE_LIST::m_lock_descriptor
private

◆ m_map

table_map TABLE_LIST::m_map {0}
private

Table map, derived from m_tableno.

◆ m_merged_derived_context

Name_resolution_context* TABLE_LIST::m_merged_derived_context {nullptr}

Context that is used to resolve a merged derived table's fields.

Needed when a field from a merged derived table is cloned. Used during condition pushdown to derived tables.

◆ m_table_ref_type

enum_table_ref_type TABLE_LIST::m_table_ref_type {TABLE_REF_NULL}
private

See comments for set_metadata_id()

◆ m_table_ref_version

ulonglong TABLE_LIST::m_table_ref_version {0}
private

See comments for TABLE_SHARE::get_table_ref_version()

◆ m_tableno

uint TABLE_LIST::m_tableno {0}
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

◆ m_updatable

bool TABLE_LIST::m_updatable {false}
private

True if VIEW/TABLE is updatable, based on analysis of query (SQL rules).

◆ m_updated

bool TABLE_LIST::m_updated {false}
private

True if table is target of UPDATE statement, or updated in IODKU stmt.

◆ m_was_scalar_subquery

bool TABLE_LIST::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

MDL_request TABLE_LIST::mdl_request

◆ merge_keys_saved

Key_map TABLE_LIST::merge_keys_saved
private

◆ merge_underlying_list

TABLE_LIST* TABLE_LIST::merge_underlying_list {nullptr}

◆ natural_join

TABLE_LIST* TABLE_LIST::natural_join {nullptr}

◆ nested_join

NESTED_JOIN* TABLE_LIST::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.

◆ next_global

TABLE_LIST* TABLE_LIST::next_global {nullptr}

◆ next_leaf

TABLE_LIST* TABLE_LIST::next_leaf {nullptr}

◆ next_local

TABLE_LIST* TABLE_LIST::next_local {nullptr}

◆ next_name_resolution_table

TABLE_LIST* TABLE_LIST::next_name_resolution_table {nullptr}

◆ nullable_saved

bool TABLE_LIST::nullable_saved {false}
private

◆ 

enum { ... } TABLE_LIST::OPEN_NORMAL

Indicates that if TABLE_LIST object corresponds to the table/view which requires special handling.

◆ open_type

enum_open_type TABLE_LIST::open_type {OT_TEMPORARY_OR_BASE}

Specifies which kind of table should be open for this element of table list.

◆ opt_hints_qb

Opt_hints_qb* TABLE_LIST::opt_hints_qb {nullptr}

◆ opt_hints_table

Opt_hints_table* TABLE_LIST::opt_hints_table {nullptr}

Table level optimizer hints for this table.


◆ optimized_away

bool TABLE_LIST::optimized_away {false}

true <=> this table is a const one and was optimized away.

◆ option

char* TABLE_LIST::option {nullptr}

◆ outer_join

bool TABLE_LIST::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).

◆ parent_l

TABLE_LIST* TABLE_LIST::parent_l {nullptr}

◆ partition_names

List<String>* TABLE_LIST::partition_names {nullptr}

◆ prelocking_placeholder

bool TABLE_LIST::prelocking_placeholder {false}

◆ prev_global

TABLE_LIST ** TABLE_LIST::prev_global {nullptr}

◆ query_block

Query_block* TABLE_LIST::query_block {nullptr}

◆ read_set_saved

MY_BITMAP TABLE_LIST::read_set_saved
private

◆ read_set_small

my_bitmap_map TABLE_LIST::read_set_small[bitmap_buffer_size(64)/sizeof(my_bitmap_map)]
private

◆ referencing_view

TABLE_LIST* TABLE_LIST::referencing_view {nullptr}

◆ replace_filter

Item* TABLE_LIST::replace_filter {nullptr}

Filter for REPLACE command.

◆ replace_filter_processed

bool TABLE_LIST::replace_filter_processed {false}

true <=> Filter condition is processed

◆ required_type

dd::enum_table_type TABLE_LIST::required_type {}

◆ schema_query_block

Query_block* TABLE_LIST::schema_query_block {nullptr}

◆ schema_table

ST_SCHEMA_TABLE* TABLE_LIST::schema_table {nullptr}

◆ schema_table_filled

bool TABLE_LIST::schema_table_filled {false}

◆ schema_table_param

Temp_table_param* TABLE_LIST::schema_table_param {nullptr}

◆ schema_table_reformed

bool TABLE_LIST::schema_table_reformed {false}

◆ security_ctx

Security_context* TABLE_LIST::security_ctx {nullptr}

◆ select_stmt

LEX_STRING TABLE_LIST::select_stmt {nullptr, 0}

text of (CREATE/SELECT) statement

◆ shared

uint TABLE_LIST::shared {0}

◆ sj_inner_tables

table_map TABLE_LIST::sj_inner_tables {0}

◆ source

LEX_STRING TABLE_LIST::source {nullptr, 0}

source of CREATE VIEW

◆ straight

bool TABLE_LIST::straight {false}

◆ table

TABLE* TABLE_LIST::table {nullptr}

◆ table_function

Table_function* TABLE_LIST::table_function {nullptr}

◆ table_id

Table_id TABLE_LIST::table_id {}

◆ table_name

const char * TABLE_LIST::table_name {nullptr}

◆ table_name_length

size_t TABLE_LIST::table_name_length {0}

◆ table_open_method

uint TABLE_LIST::table_open_method {0}

◆ target_tablespace_name

LEX_CSTRING TABLE_LIST::target_tablespace_name {nullptr, 0}

◆ timestamp

LEX_STRING TABLE_LIST::timestamp {nullptr, 0}

GMT time stamp of last operation.

◆ timestamp_buffer

char TABLE_LIST::timestamp_buffer[20] {0}

◆ trg_event_map

uint8 TABLE_LIST::trg_event_map {0}

Indicates what triggers we need to pre-load for this TABLE_LIST when opening an associated TABLE.

This is filled after the parsed tree is created.

◆ updatable_view

ulonglong TABLE_LIST::updatable_view {0}

VIEW can be updated.

Note
: This field is currently not reliable when read from dictionary: If an underlying view is changed, updatable_view is not changed, due to lack of dependency checking in dictionary implementation. Prefer to use is_updatable() during preparation and optimization.

◆ updating

bool TABLE_LIST::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.

◆ view

LEX* TABLE_LIST::view {nullptr}
private

◆ view_body_utf8

LEX_STRING TABLE_LIST::view_body_utf8 {nullptr, 0}

◆ view_client_cs_name

LEX_CSTRING TABLE_LIST::view_client_cs_name {nullptr, 0}

◆ view_connection_cl_name

LEX_CSTRING TABLE_LIST::view_connection_cl_name {nullptr, 0}

◆ view_creation_ctx

View_creation_ctx* TABLE_LIST::view_creation_ctx {nullptr}

◆ view_no_explain

bool TABLE_LIST::view_no_explain {false}

if true, EXPLAIN can't explain view due to insufficient rights.

◆ view_sctx

Security_context* TABLE_LIST::view_sctx {nullptr}

◆ view_suid

ulonglong TABLE_LIST::view_suid {0}

view is suid (true by default)

◆ view_tables

mem_root_deque<TABLE_LIST *>* TABLE_LIST::view_tables {nullptr}

◆ with_check

ulonglong TABLE_LIST::with_check {0}

WITH CHECK OPTION.

◆ write_set_saved

MY_BITMAP TABLE_LIST::write_set_saved
private

◆ write_set_small

my_bitmap_map TABLE_LIST::write_set_small[bitmap_buffer_size(64)/sizeof(my_bitmap_map)]
private

The documentation for this struct was generated from the following files: