MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TABLE_LIST Struct Reference
Inheritance diagram for TABLE_LIST:
Collaboration diagram for TABLE_LIST:

Public Types

enum  { OPEN_NORMAL = 0, OPEN_IF_EXISTS, OPEN_FOR_CREATE, OPEN_STUB }

Public Member Functions

void init_one_table (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
Itemset_join_cond (Item *val)
void calc_md5 (char *buffer)
void set_underlying_merge ()
 Set underlying table for table place holder of view.
int view_check_option (THD *thd, bool ignore_failure) const
bool setup_underlying (THD *thd)
void cleanup_items ()
bool placeholder ()
void print (THD *thd, String *str, enum_query_type query_type)
bool check_single_table (TABLE_LIST **table, table_map map, TABLE_LIST *view)
bool set_insert_values (MEM_ROOT *mem_root)
void hide_view_error (THD *thd)
TABLE_LISTfind_underlying_table (TABLE *table)
TABLE_LISTfirst_leaf_for_name_resolution ()
TABLE_LISTlast_leaf_for_name_resolution ()
bool is_leaf_for_name_resolution ()
const TABLE_LISTtop_table () const
TABLE_LISTtop_table ()
bool prepare_check_option (THD *thd)
bool prepare_where (THD *thd, Item **conds, bool no_where_clause)
bool uses_materialization () const
bool is_view_or_derived () const
bool materializable_is_const () const
void register_want_access (ulong want_access)
bool prepare_security (THD *thd)
Security_context * find_view_security_context (THD *thd)
bool prepare_view_securety_context (THD *thd)
void reinit_before_use (THD *thd)
Item_subselectcontaining_subselect ()
bool process_index_hints (TABLE *table)
bool is_table_ref_id_equal (TABLE_SHARE *s) const
void set_table_ref_id (TABLE_SHARE *s)
void set_table_ref_id (enum_table_ref_type table_ref_type_arg, ulonglong table_ref_version_arg)
bool is_anonymous_derived_table () const
 True if this TABLE_LIST represents an anonymous derived table, i.e. the result of a subquery.
uint query_block_id () const
 returns query block id for derived table, and zero if not derived.
char * get_db_name () const
 Returns the name of the database that the referenced table belongs to.
char * get_table_name () const
 Returns the name of the table that this TABLE_LIST represents.
int fetch_number_of_rows ()
 Retrieve number of rows in the table.
bool update_derived_keys (Field *, Item **, uint)
bool generate_keys ()
 Generate keys for a materialized derived table/view.
bool handle_derived (LEX *lex, bool(*processor)(THD *, LEX *, TABLE_LIST *))
st_select_lex_unit * get_unit () const
 Return unit of this derived table/view.
TABLE_LISTouter_join_nest () const
 Returns the outer join nest that this TABLE_LIST belongs to, if any.

Static Public Member Functions

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

Public Attributes

TABLE_LISTnext_local
TABLE_LISTnext_global
TABLE_LIST ** prev_global
char * db
char * alias
char * table_name
char * schema_table_name
char * option
Name_resolution_contextcontext_of_embedding
Itemprep_join_cond
Itemsj_on_expr
table_map sj_inner_tables
COND_EQUALcond_equal
TABLE_LISTnatural_join
bool is_natural_join
List< String > * join_using_fields
List< Natural_join_column > * join_columns
bool is_join_columns_complete
TABLE_LISTnext_name_resolution_table
List< Index_hint > * index_hints
TABLEtable
Table_id table_id
select_union * derived_result
TABLE_LISTcorrespondent_table
st_select_lex_unit * derived
 Normally, this field is non-null for anonymous derived tables only.
bool derived_keys_ready
ST_SCHEMA_TABLEschema_table
st_select_lex * schema_select_lex
bool schema_table_reformed
TMP_TABLE_PARAM * schema_table_param
st_select_lex * select_lex
LEX * view
Field_translatorfield_translation
Field_translatorfield_translation_end
TABLE_LISTmerge_underlying_list
List< TABLE_LIST > * view_tables
TABLE_LISTbelong_to_view
TABLE_LISTreferencing_view
TABLE_LISTparent_l
Security_context * security_ctx
Security_context * view_sctx
bool allowed_show
TABLE_LISTnext_leaf
Itemwhere
Itemcheck_option
LEX_STRING select_stmt
LEX_STRING md5
LEX_STRING source
LEX_STRING view_db
LEX_STRING view_name
LEX_STRING timestamp
st_lex_user definer
ulonglong file_version
ulonglong updatable_view
ulonglong algorithm
 The declared algorithm, if this is a view.
ulonglong view_suid
ulonglong with_check
uint8 effective_with_check
enum_derived_type effective_algorithm
 The view algorithm that is actually used, if this is a view.
GRANT_INFO grant
ulonglong engine_data
qc_engine_callback callback_func
thr_lock_type lock_type
uint outer_join
uint shared
size_t db_length
size_t table_name_length
bool updatable
bool straight
bool updating
bool force_index
bool ignore_leaves
table_map dep_tables
table_map on_expr_dep_tables
struct st_nested_joinnested_join
TABLE_LISTembedding
List< TABLE_LIST > * join_list
bool cacheable_table
bool table_in_first_from_clause
enum enum_open_type open_type
bool contain_auto_increment
bool multitable_view
bool compact_view_format
bool where_processed
bool check_option_processed
enum frm_type_enum required_type
char timestamp_buffer [20]
bool prelocking_placeholder
enum TABLE_LIST:: { ... }  open_strategy
bool internal_tmp_table
bool is_alias
bool is_fqtn
View_creation_ctxview_creation_ctx
LEX_STRING view_client_cs_name
LEX_STRING view_connection_cl_name
LEX_STRING view_body_utf8
List< Derived_keyderived_key_list
uint8 trg_event_map
bool optimized_away
uint i_s_requested_object
bool has_db_lookup_value
bool has_table_lookup_value
uint table_open_method
enum enum_schema_table_state schema_table_state
MDL_request mdl_request

Detailed Description

Definition at line 1510 of file table.h.

Member Enumeration Documentation

anonymous enum

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

Definition at line 1803 of file table.h.

Member Function Documentation

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

Definition at line 6013 of file table.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 6237 of file table.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 2010 of file table.h.

Here is the caller graph for this function:

st_select_lex_unit * TABLE_LIST::get_unit ( ) const

Return unit of this derived table/view.

Returns
reference to a unit if it's a derived table/view.
0 when it's not a derived table/view.

Definition at line 6315 of file table.cc.

Here is the caller graph for this function:

void TABLE_LIST::hide_view_error ( THD *  thd)

Hide errors which show view underlying table information. There are currently two mechanisms at work that handle errors for views, this one and a more general mechanism based on an Internal_error_handler, see Show_create_error_handler. The latter handles errors encountered during execution of SHOW CREATE VIEW, while the machanism using this method is handles SELECT from views. The two methods should not clash.

Parameters
[in,out]thdthread handler
Precondition
This method can be called only if there is an error.

Definition at line 4174 of file table.cc.

Here is the caller graph for this function:

void TABLE_LIST::init_one_table ( 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

Prepare TABLE_LIST that consists of one table instance to use in simple_open_and_lock_tables

Definition at line 1518 of file table.h.

Here is the call graph for this function:

Here is the caller graph for this function:

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()

Definition at line 1965 of file table.h.

Here is the call graph for this function:

bool TABLE_LIST::materializable_is_const ( ) const
Returns
true if materializable table contains one or zero rows.

Returning true implies that the table is materialized during optimization, so it need not be optimized during execution.

Returns
true if materializable table contains one or zero rows

Definition at line 5993 of file table.cc.

Here is the call graph for this function:

TABLE_LIST * TABLE_LIST::new_nested_join ( MEM_ROOT allocator,
const char *  alias,
TABLE_LIST embedding,
List< TABLE_LIST > *  belongs_to,
class st_select_lex *  select 
)
static

Create a TABLE_LIST object representing a nested join.

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.

Definition at line 3767 of file table.cc.

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.

Definition at line 2034 of file table.h.

Here is the caller graph for this function:

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

Print table as it should be in join list.

Parameters
strstring where table should be printed

Definition at line 2536 of file sql_lex.cc.

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()

Definition at line 1978 of file table.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void TABLE_LIST::set_underlying_merge ( )

Set underlying table for table place holder of view.

Replace all views that only use one table with the table itself. This allows us to treat the view as a simple table and even update it (it is a kind of optimization).

Note

This optimization is potentially dangerous as it makes views masquerade as base tables: Views don't have the pointer TABLE_LIST::table set to non-NULL.

We may have the case where a view accesses tables not normally accessible in the current Security_context (only in the definer's Security_context). According to the table's GRANT_INFO (TABLE::grant), access is fulfilled, but this is implicitly meant in the definer's security context. Hence we must never look at only a TABLE's GRANT_INFO without looking at the one of the referring TABLE_LIST.

Definition at line 3839 of file table.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool TABLE_LIST::uses_materialization ( ) const
inline
Returns
TRUE this is a materializable derived table/view. FALSE otherwise.

Definition at line 1920 of file table.h.

Here is the caller graph for this function:

Member Data Documentation

ulonglong TABLE_LIST::algorithm

The declared algorithm, if this is a view.

One of

  • VIEW_ALGORITHM_UNDEFINED
  • VIEW_ALGORITHM_TMPTABLE
  • VIEW_ALGORITHM_MERGE do Replace with an enum

Definition at line 1738 of file table.h.

Name_resolution_context* TABLE_LIST::context_of_embedding

Context which should be used to resolve identifiers contained in the ON condition of the embedding join nest.

Todo:
When name resolution contexts are created after parsing, we should be able to store this in the embedding join nest instead.

Definition at line 1563 of file table.h.

st_select_lex_unit* TABLE_LIST::derived

Normally, this field is non-null for anonymous derived tables only.

This field is set to non-null for

  • Anonymous derived tables, In this case it points to the SELECT_LEX_UNIT representing the derived table. E.g. for a query
SELECT * FROM (SELECT a FROM t1) b 

For the TABLE_LIST representing the derived table b, derived points to the SELECT_LEX_UNIT representing the result of the query within parenteses.

  • Views. This is set for views with
    ALGORITHM = TEMPTABLE
    
    by mysql_make_view().
Note
Inside views, a subquery in the FROM clause is not allowed.
Do not use this field to separate views/base tables/anonymous derived tables. Use TABLE_LIST::is_anonymous_derived_table().

Definition at line 1661 of file table.h.

enum_derived_type TABLE_LIST::effective_algorithm

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

One of

  • VIEW_ALGORITHM_UNDEFINED
  • VIEW_ALGORITHM_TMPTABLE
  • VIEW_ALGORITHM_MERGE do Replace with an enum

Definition at line 1754 of file table.h.

bool TABLE_LIST::is_alias

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

Definition at line 1819 of file table.h.

bool TABLE_LIST::is_fqtn

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

Definition at line 1823 of file table.h.

enum { ... } TABLE_LIST::open_strategy

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

enum enum_open_type TABLE_LIST::open_type

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

Definition at line 1782 of file table.h.

uint8 TABLE_LIST::trg_event_map

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.

Definition at line 1858 of file table.h.


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