MySQL  8.0.17
Source Code Documentation
table.h File Reference
#include <string.h>
#include <sys/types.h>
#include <string>
#include "field_types.h"
#include "lex_string.h"
#include "m_ctype.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_bitmap.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "my_table_map.h"
#include "mysql/components/services/mysql_mutex_bits.h"
#include "mysql/components/services/psi_table_bits.h"
#include "sql/dd/types/foreign_key.h"
#include "sql/enum_query_type.h"
#include "sql/key.h"
#include "sql/key_spec.h"
#include "sql/mdl.h"
#include "sql/mem_root_array.h"
#include "sql/opt_costmodel.h"
#include "sql/record_buffer.h"
#include "sql/sql_bitmap.h"
#include "sql/sql_const.h"
#include "sql/sql_list.h"
#include "sql/sql_plist.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sql_sort.h"
#include "table_id.h"
#include "thr_lock.h"
#include "typelib.h"

Go to the source code of this file.

Classes

class  Object_creation_ctx
 
Object_creation_ctx – interface for creation context of database objects (views, stored routines, events, triggers). More...
 
class  Default_object_creation_ctx
 
Default_object_creation_ctx – default implementation of Object_creation_ctx. More...
 
class  View_creation_ctx
 
View_creation_ctx – creation context of view objects. More...
 
struct  ORDER
 Order clause list element. More...
 
struct  GRANT_INTERNAL_INFO
 State information for internal tables grants. More...
 
struct  GRANT_INFO
 The current state of the privilege checking process for the current user, SQL statement and SQL object. More...
 
struct  TABLE_FIELD_TYPE
 
struct  TABLE_FIELD_DEF
 
class  Table_check_intact
 
class  Wait_for_flush
 Class representing the fact that some thread waits for table share to be flushed. More...
 
struct  Table_share_foreign_key_info
 
struct  Table_share_foreign_key_parent_info
 
struct  TABLE_SHARE
 This structure is shared between different table objects. More...
 
class  Blob_mem_storage
 Class is used as a BLOB field value storage for intermediate GROUP_CONCAT results. More...
 
class  Binary_diff
 Class that represents a single change to a column value in partial update of a JSON column. More...
 
struct  TABLE
 
struct  FOREIGN_KEY_INFO
 
struct  ST_FIELD_INFO
 
struct  ST_SCHEMA_TABLE
 
struct  Field_translator
 Struct that describes an expression selected from a derived table or view. More...
 
class  Natural_join_column
 
struct  LEX_ALTER
 
struct  LEX_USER
 
class  Derived_key
 This structure is used to keep info about possible key for the result table of a derived table/view. More...
 
struct  TABLE_LIST
 
class  Field_iterator
 
class  Field_iterator_table
 
class  Field_iterator_view
 Iterator over the fields of a merged derived table or view. More...
 
class  Field_iterator_natural_join
 
class  Field_iterator_table_ref
 Generic iterator over the fields of an arbitrary table reference. More...
 
class  Table_list_iterator< Next_pointer >
 An iterator over an intrusive list in TABLE_LIST objects. More...
 
class  Table_list_adapter< Iterator_type >
 Provides a list interface on TABLE_LIST objects. More...
 
struct  OPEN_TABLE_LIST
 
class  Common_table_expr
 After parsing, a Common Table Expression is accessed through a TABLE_LIST. More...
 
class  Derived_refs_iterator
 This iterates on those references to a derived table / view / CTE which are materialized. More...
 
class  FRM_context
 These members were removed from TABLE_SHARE as they are not used in in the code. More...
 

Namespaces

 histograms
 
 dd
 The version of the current data dictionary table definitions.
 

Macros

#define store_record(A, B)   memcpy((A)->B, (A)->record[0], (size_t)(A)->s->reclength)
 
#define restore_record(A, B)   memcpy((A)->record[0], (A)->B, (size_t)(A)->s->reclength)
 
#define cmp_record(A, B)   memcmp((A)->record[0], (A)->B, (size_t)(A)->s->reclength)
 
#define tmp_file_prefix   "#sql"
 Prefix for tmp tables. More...
 
#define tmp_file_prefix_length   4
 
#define TMP_TABLE_KEY_EXTRA   8
 
#define PLACEHOLDER_TABLE_ROW_ESTIMATE   2
 
#define STATUS_NOT_STARTED   1
 Flags for TABLE::m_status (maximum 8 bits). More...
 
#define STATUS_NOT_FOUND   2
 Means we were searching for a row and didn't find it. More...
 
#define STATUS_UPDATED   16
 Reserved for use by multi-table update. Means the row has been updated. More...
 
#define STATUS_NULL_ROW   32
 Means that table->null_row is set. More...
 
#define STATUS_DELETED   64
 Reserved for use by multi-table delete. Means the row has been deleted. More...
 
#define MY_I_S_MAYBE_NULL   1
 
#define MY_I_S_UNSIGNED   2
 
#define JOIN_TYPE_LEFT   1
 
#define JOIN_TYPE_RIGHT   2
 
#define VIEW_SUID_INVOKER   0
 
#define VIEW_SUID_DEFINER   1
 
#define VIEW_SUID_DEFAULT   2
 
#define VIEW_CHECK_NONE   0
 
#define VIEW_CHECK_LOCAL   1
 
#define VIEW_CHECK_CASCADED   2
 
#define VIEW_CHECK_OK   0
 
#define VIEW_CHECK_ERROR   1
 
#define VIEW_CHECK_SKIP   2
 
#define MAX_TDC_BLOB_SIZE   65536
 The threshold size a blob field buffer before it is freed. More...
 

Typedefs

typedef int8 plan_idx
 
using Sql_table_check_constraint_list = Mem_root_array< Sql_table_check_constraint * >
 
using Sql_check_constraint_share_list = Mem_root_array< Sql_check_constraint_share * >
 
typedef Mem_root_array_YY< LEX_CSTRINGCreate_col_name_list
 
typedef int64 query_id_t
 
typedef enum enum_table_category TABLE_CATEGORY
 
typedef I_P_List< Wait_for_flush, I_P_List_adapter< Wait_for_flush, &Wait_for_flush::next_in_share, &Wait_for_flush::prev_in_share > > Wait_for_flush_list
 
typedef struct Table_share_foreign_key_info TABLE_SHARE_FOREIGN_KEY_INFO
 
typedef struct Table_share_foreign_key_parent_info TABLE_SHARE_FOREIGN_KEY_PARENT_INFO
 
using Binary_diff_vector = Mem_root_array< Binary_diff >
 Vector of Binary_diff objects. More...
 
typedef Bitmap< MAX_FIELDSField_map
 
typedef Table_list_iterator<&TABLE_LIST::next_localLocal_tables_iterator
 
typedef Table_list_iterator<&TABLE_LIST::next_globalGlobal_tables_iterator
 
typedef Table_list_adapter< Local_tables_iteratorLocal_tables_list
 A list interface over the TABLE_LIST::next_local pointer. More...
 
typedef Table_list_adapter< Global_tables_iteratorGlobal_tables_list
 A list interface over the TABLE_LIST::next_global pointer. More...
 

Enumerations

enum  enum_table_ref_type {
  TABLE_REF_NULL = 0, TABLE_REF_VIEW, TABLE_REF_BASE_TABLE, TABLE_REF_I_S_TABLE,
  TABLE_REF_TMP_TABLE
}
 Enumerate possible types of a table from re-execution standpoint. More...
 
enum  Ident_name_check { Ident_name_check::OK, Ident_name_check::WRONG, Ident_name_check::TOO_LONG }
 
Enumerate possible status of a identifier name while determining its validity More...
 
enum  tmp_table_type {
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE, INTERNAL_TMP_TABLE,
  SYSTEM_TMP_TABLE
}
 
enum  enum_table_category {
  TABLE_UNKNOWN_CATEGORY = 0, TABLE_CATEGORY_TEMPORARY = 1, TABLE_CATEGORY_USER = 2, TABLE_CATEGORY_SYSTEM = 3,
  TABLE_CATEGORY_INFORMATION = 4, TABLE_CATEGORY_LOG = 5, TABLE_CATEGORY_PERFORMANCE = 6, TABLE_CATEGORY_RPL_INFO = 7,
  TABLE_CATEGORY_GTID = 8, TABLE_CATEGORY_DICTIONARY = 9
}
 Category of table found in the table share. More...
 
enum  index_hint_type { INDEX_HINT_IGNORE, INDEX_HINT_USE, INDEX_HINT_FORCE }
 
enum  enum_schema_table_state : int { NOT_PROCESSED = 0, PROCESSED_BY_CREATE_SORT_INDEX, PROCESSED_BY_JOIN_EXEC }
 
enum  enum_view_algorithm { VIEW_ALGORITHM_UNDEFINED = 0, VIEW_ALGORITHM_TEMPTABLE = 1, VIEW_ALGORITHM_MERGE = 2 }
 Strategy for how to process a view or derived table (merge or materialization) More...
 
enum  Lex_acl_attrib_udyn { Lex_acl_attrib_udyn::UNCHANGED, Lex_acl_attrib_udyn::DEFAULT, Lex_acl_attrib_udyn::YES, Lex_acl_attrib_udyn::NO }
 This is generic enum. More...
 
enum  enum_open_type { OT_TEMPORARY_OR_BASE = 0, OT_TEMPORARY_ONLY, OT_BASE_ONLY }
 Type of table which can be open for an element of table list. More...
 

Functions

bool assert_ref_count_is_locked (const TABLE_SHARE *)
 Assert that the LOCK_open mutex is held when the reference count of a TABLE_SHARE is accessed. More...
 
static void empty_record (TABLE *table)
 
enum enum_mdl_type mdl_type_for_dml (enum thr_lock_type lock_type)
 Derive type of metadata lock to be requested for table used by a DML statement from the type of THR_LOCK lock requested for this table. More...
 
static my_bitmap_maptmp_use_all_columns (TABLE *table, MY_BITMAP *bitmap)
 
static void tmp_restore_column_map (MY_BITMAP *bitmap, my_bitmap_map *old)
 
static my_bitmap_mapdbug_tmp_use_all_columns (TABLE *table, MY_BITMAP *bitmap)
 
static void dbug_tmp_restore_column_map (MY_BITMAP *bitmap, my_bitmap_map *old)
 
static void dbug_tmp_use_all_columns (TABLE *table, my_bitmap_map **save, MY_BITMAP *read_set, MY_BITMAP *write_set)
 
static void dbug_tmp_restore_column_maps (MY_BITMAP *read_set, MY_BITMAP *write_set, my_bitmap_map **old)
 
void init_mdl_requests (TABLE_LIST *table_list)
 Helper function which allows to allocate metadata lock request objects for all elements of table list. More...
 
bool unpack_value_generator (THD *thd, TABLE *table, Value_generator **val_generator, Value_generator_source source, const char *source_name, Field *field, bool is_create_table, bool *error_reported)
 Unpacks the definition of a generated column, default expression or check constraint expression passed as argument. More...
 
bool unpack_partition_info (THD *thd, TABLE *outparam, TABLE_SHARE *share, handlerton *engine_type, bool is_create_table)
 Unpack the partition expression. More...
 
int open_table_from_share (THD *thd, TABLE_SHARE *share, const char *alias, uint db_stat, uint prgflag, uint ha_open_flags, TABLE *outparam, bool is_create_table, const dd::Table *table_def_param)
 Open a table based on a TABLE_SHARE. More...
 
TABLE_SHAREalloc_table_share (const char *db, const char *table_name, const char *key, size_t key_length, bool open_secondary)
 Allocate and setup a TABLE_SHARE structure. More...
 
void init_tmp_table_share (THD *thd, TABLE_SHARE *share, const char *key, size_t key_length, const char *table_name, const char *path, MEM_ROOT *mem_root)
 Initialize share for temporary tables. More...
 
void free_table_share (TABLE_SHARE *share)
 Free table share and memory used by it. More...
 
void update_create_info_from_table (HA_CREATE_INFO *info, TABLE *form)
 
Ident_name_check check_db_name (const char *name, size_t length)
 Check if database name is valid. More...
 
Ident_name_check check_and_convert_db_name (LEX_STRING *db, bool preserve_lettercase)
 Check if database name is valid, and convert to lower case if necessary. More...
 
bool check_column_name (const char *name)
 
Ident_name_check check_table_name (const char *name, size_t length)
 Function to check if table name is valid or not. More...
 
int rename_file_ext (const char *from, const char *to, const char *ext)
 
char * get_field (MEM_ROOT *mem, Field *field)
 Allocate string field in MEM_ROOT and return it as NULL-terminated string. More...
 
bool get_field (MEM_ROOT *mem, Field *field, class String *res)
 Allocate string field in MEM_ROOT and return it as String. More...
 
int closefrm (TABLE *table, bool free_share)
 Free information allocated by openfrm. More...
 
void free_blobs (TABLE *table)
 
void free_blob_buffers_and_reset (TABLE *table, uint32 size)
 Reclaims temporary blob storage which is bigger than a threshold. More...
 
int set_zone (int nr, int min_zone, int max_zone)
 
void append_unescaped (String *res, const char *pos, size_t length)
 Store an SQL quoted string. More...
 
char * fn_rext (char *name)
 Returns pointer to '.frm' extension of the file name. More...
 
TABLE_CATEGORY get_table_category (const LEX_CSTRING &db, const LEX_CSTRING &name)
 
bool is_infoschema_db (const char *name, size_t len)
 
bool is_infoschema_db (const char *name)
 
bool is_perfschema_db (const char *name, size_t len)
 
bool is_perfschema_db (const char *name)
 
bool is_user_table (TABLE *table)
 return true if the table was created explicitly. More...
 
bool is_simple_order (ORDER *order)
 Test if the order list consists of simple field expressions. More...
 
uint add_pk_parts_to_sk (KEY *sk, uint sk_n, KEY *pk, uint pk_n, TABLE_SHARE *share, handler *handler_file, uint *usable_parts)
 Generate extended secondary keys by adding primary key parts to the existing secondary key. More...
 
void setup_key_part_field (TABLE_SHARE *share, handler *handler_file, uint primary_key_n, KEY *keyinfo, uint key_n, uint key_part_n, uint *usable_parts, bool part_of_key_not_extended)
 Setup key-related fields of Field object for given key and key part. More...
 
const ucharget_field_name (const uchar *arg, size_t *length)
 
void repoint_field_to_record (TABLE *table, uchar *old_rec, uchar *new_rec)
 Repoint a table's fields from old_rec to new_rec. More...
 
bool update_generated_write_fields (const MY_BITMAP *bitmap, TABLE *table)
 Calculate data for each generated field marked for write in the corresponding column map. More...
 
bool update_generated_read_fields (uchar *buf, TABLE *table, uint active_index=MAX_KEY)
 Evaluate necessary virtual generated columns. More...
 
bool is_temporary_table (TABLE_LIST *tl)
 Check if a TABLE_LIST instance represents a pre-opened temporary table. More...
 
bool create_table_share_for_upgrade (THD *thd, const char *path, TABLE_SHARE *share, FRM_context *frm_context, const char *db, const char *table, bool is_fix_view_cols_and_deps)
 Create TABLE_SHARE from .frm file. More...
 

Variables

ulong refresh_version
 
LEX_STRING PERFORMANCE_SCHEMA_DB_NAME
 
LEX_STRING GENERAL_LOG_NAME
 
LEX_STRING SLOW_LOG_NAME
 
LEX_CSTRING INFORMATION_SCHEMA_NAME
 
LEX_STRING MYSQL_SCHEMA_NAME
 
static const uint MYSQL_SCHEMA_DD_ID = 1
 
LEX_STRING MYSQL_TABLESPACE_NAME
 
static const uint MYSQL_TABLESPACE_DD_ID = 1
 
LEX_STRING RLI_INFO_NAME
 
LEX_STRING MI_INFO_NAME
 
LEX_STRING WORKER_INFO_NAME
 

Macro Definition Documentation

◆ cmp_record

#define cmp_record (   A,
 
)    memcmp((A)->record[0], (A)->B, (size_t)(A)->s->reclength)

◆ JOIN_TYPE_LEFT

#define JOIN_TYPE_LEFT   1

◆ JOIN_TYPE_RIGHT

#define JOIN_TYPE_RIGHT   2

◆ MAX_TDC_BLOB_SIZE

#define MAX_TDC_BLOB_SIZE   65536

The threshold size a blob field buffer before it is freed.

◆ MY_I_S_MAYBE_NULL

#define MY_I_S_MAYBE_NULL   1

◆ MY_I_S_UNSIGNED

#define MY_I_S_UNSIGNED   2

◆ PLACEHOLDER_TABLE_ROW_ESTIMATE

#define PLACEHOLDER_TABLE_ROW_ESTIMATE   2

◆ restore_record

#define restore_record (   A,
 
)    memcpy((A)->record[0], (A)->B, (size_t)(A)->s->reclength)

◆ STATUS_DELETED

#define STATUS_DELETED   64

Reserved for use by multi-table delete. Means the row has been deleted.

◆ STATUS_NOT_FOUND

#define STATUS_NOT_FOUND   2

Means we were searching for a row and didn't find it.

This is used by storage engines (

See also
handler::index_read_map()) and the executor, both when doing an exact row lookup and advancing a scan (no more rows in range).

◆ STATUS_NOT_STARTED

#define STATUS_NOT_STARTED   1

Flags for TABLE::m_status (maximum 8 bits).

The flags define the state of the row buffer in TABLE::record[0]. STATUS_NOT_STARTED is set when table is not accessed yet. Neither STATUS_NOT_FOUND nor STATUS_NULL_ROW can be set when this flag is set.

◆ STATUS_NULL_ROW

#define STATUS_NULL_ROW   32

Means that table->null_row is set.

This is an artificial NULL-filled row (one example: in outer join, if no match has been found in inner table).

◆ STATUS_UPDATED

#define STATUS_UPDATED   16

Reserved for use by multi-table update. Means the row has been updated.

◆ store_record

#define store_record (   A,
 
)    memcpy((A)->B, (A)->record[0], (size_t)(A)->s->reclength)

◆ tmp_file_prefix

#define tmp_file_prefix   "#sql"

Prefix for tmp tables.

◆ tmp_file_prefix_length

#define tmp_file_prefix_length   4

◆ TMP_TABLE_KEY_EXTRA

#define TMP_TABLE_KEY_EXTRA   8

◆ VIEW_CHECK_CASCADED

#define VIEW_CHECK_CASCADED   2

◆ VIEW_CHECK_ERROR

#define VIEW_CHECK_ERROR   1

◆ VIEW_CHECK_LOCAL

#define VIEW_CHECK_LOCAL   1

◆ VIEW_CHECK_NONE

#define VIEW_CHECK_NONE   0

◆ VIEW_CHECK_OK

#define VIEW_CHECK_OK   0

◆ VIEW_CHECK_SKIP

#define VIEW_CHECK_SKIP   2

◆ VIEW_SUID_DEFAULT

#define VIEW_SUID_DEFAULT   2

◆ VIEW_SUID_DEFINER

#define VIEW_SUID_DEFINER   1

◆ VIEW_SUID_INVOKER

#define VIEW_SUID_INVOKER   0

Typedef Documentation

◆ Binary_diff_vector

Vector of Binary_diff objects.

The Binary_diff objects in the vector should be ordered on offset, and none of the diffs should be overlapping or adjacent.

◆ Create_col_name_list

◆ Field_map

◆ Global_tables_iterator

◆ Global_tables_list

A list interface over the TABLE_LIST::next_global pointer.

◆ Local_tables_iterator

◆ Local_tables_list

A list interface over the TABLE_LIST::next_local pointer.

◆ plan_idx

typedef int8 plan_idx

◆ query_id_t

typedef int64 query_id_t

◆ Sql_check_constraint_share_list

◆ Sql_table_check_constraint_list

◆ TABLE_CATEGORY

◆ TABLE_SHARE_FOREIGN_KEY_INFO

◆ TABLE_SHARE_FOREIGN_KEY_PARENT_INFO

◆ Wait_for_flush_list

Enumeration Type Documentation

◆ enum_open_type

Type of table which can be open for an element of table list.

Enumerator
OT_TEMPORARY_OR_BASE 
OT_TEMPORARY_ONLY 
OT_BASE_ONLY 

◆ enum_schema_table_state

Enumerator
NOT_PROCESSED 
PROCESSED_BY_CREATE_SORT_INDEX 
PROCESSED_BY_JOIN_EXEC 

◆ enum_table_category

Category of table found in the table share.

Enumerator
TABLE_UNKNOWN_CATEGORY 

Unknown value.

TABLE_CATEGORY_TEMPORARY 

Temporary table.

The table is visible only in the session. Therefore,

  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON do not apply to this table. Note that LOCK TABLE t FOR READ/WRITE can be used on temporary tables. Temporary tables are not part of the table cache.

2016-06-14 Contrary to what's written in these comments, the truth is:

  • tables created by CREATE TEMPORARY TABLE have TABLE_CATEGORY_USER
  • tables created by create_tmp_table() (internal ones) have TABLE_CATEGORY_TEMPORARY. ha_innodb.cc relies on this observation (so: grep it). If you clean this up, you may also want to look at 'no_tmp_table'; its enum values' meanings have degraded over time: INTERNAL_TMP_TABLE is not used for some internal tmp tables (derived tables). Unification of both enums would be great. Whatever the result, we need to be able to distinguish the two types of temporary tables above, as usage patterns are more restricted for the second type, and allow more optimizations.
TABLE_CATEGORY_USER 

User table.

These tables do honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON User tables are cached in the table cache.
TABLE_CATEGORY_SYSTEM 

System table, maintained by the server.

These tables do honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON Typically, writes to system tables are performed by the server implementation, not explicitly be a user. System tables are cached in the table cache.
TABLE_CATEGORY_INFORMATION 

Information schema tables.

These tables are an interface provided by the system to inspect the system metadata. These tables do not honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON as there is no point in locking explicitly an INFORMATION_SCHEMA table. Nothing is directly written to information schema tables. Note that this value is not used currently, since information schema tables are not shared, but implemented as session specific temporary tables.
TABLE_CATEGORY_LOG 

Log tables.

These tables are an interface provided by the system to inspect the system logs. These tables do not honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON as there is no point in locking explicitly a LOG table. An example of LOG tables are:
  • mysql.slow_log
  • mysql.general_log, which are updated even when there is either a GLOBAL READ LOCK or a GLOBAL READ_ONLY in effect. User queries do not write directly to these tables (there are exceptions for log tables). The server implementation perform writes. Log tables are cached in the table cache.
TABLE_CATEGORY_PERFORMANCE 

Performance schema tables.

These tables are an interface provided by the system to inspect the system performance data. These tables do not honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON as there is no point in locking explicitly a PERFORMANCE_SCHEMA table. An example of PERFORMANCE_SCHEMA tables are:
  • performance_schema.* which are updated (but not using the handler interface) even when there is either a GLOBAL READ LOCK or a GLOBAL READ_ONLY in effect. User queries do not write directly to these tables (there are exceptions for SETUP_* tables). The server implementation perform writes. Performance tables are cached in the table cache.
TABLE_CATEGORY_RPL_INFO 

Replication Information Tables.

These tables are used to store replication information. These tables do not honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON as there is no point in locking explicitly a Replication Information table. An example of replication tables are:
  • mysql.slave_master_info
  • mysql.slave_relay_log_info, which are updated even when there is either a GLOBAL READ LOCK or a GLOBAL READ_ONLY in effect. User queries do not write directly to these tables. Replication tables are cached in the table cache.
TABLE_CATEGORY_GTID 

Gtid Table.

The table is used to store gtids. The table does not honor:

  • LOCK TABLE t FOR READ/WRITE
  • FLUSH TABLES WITH READ LOCK
  • SET GLOBAL READ_ONLY = ON as there is no point in locking explicitly a Gtid table. An example of gtid_executed table is:
  • mysql.gtid_executed, which is updated even when there is either a GLOBAL READ LOCK or a GLOBAL READ_ONLY in effect. Gtid table is cached in the table cache.
TABLE_CATEGORY_DICTIONARY 

A data dictionary table.

Table's with this category will skip checking the TABLE_SHARE versions because these table structures are fixed upon server bootstrap.

◆ enum_table_ref_type

Enumerate possible types of a table from re-execution standpoint.

TABLE_LIST class has a member of this type. At prepared statement prepare, this member is assigned a value as of the current state of the database. Before (re-)execution of a prepared statement, we check that the value recorded at prepare matches the type of the object we obtained from the table definition cache.

See also
check_and_update_table_version()
Execute_observer
Prepared_statement::reprepare()
Enumerator
TABLE_REF_NULL 

Initial value set by the parser.

TABLE_REF_VIEW 
TABLE_REF_BASE_TABLE 
TABLE_REF_I_S_TABLE 
TABLE_REF_TMP_TABLE 

◆ enum_view_algorithm

Strategy for how to process a view or derived table (merge or materialization)

Enumerator
VIEW_ALGORITHM_UNDEFINED 
VIEW_ALGORITHM_TEMPTABLE 
VIEW_ALGORITHM_MERGE 

◆ Ident_name_check

enum Ident_name_check
strong


Enumerate possible status of a identifier name while determining its validity

Enumerator
OK 
WRONG 
TOO_LONG 

◆ index_hint_type

Enumerator
INDEX_HINT_IGNORE 
INDEX_HINT_USE 
INDEX_HINT_FORCE 

◆ Lex_acl_attrib_udyn

enum Lex_acl_attrib_udyn
strong

This is generic enum.

It may be reused in the ACL statements for clauses that can map to the values defined in this enum.

Enumerator
UNCHANGED 
DEFAULT 
YES 
NO 

◆ tmp_table_type

Enumerator
NO_TMP_TABLE 
NON_TRANSACTIONAL_TMP_TABLE 
TRANSACTIONAL_TMP_TABLE 
INTERNAL_TMP_TABLE 
SYSTEM_TMP_TABLE 

Function Documentation

◆ add_pk_parts_to_sk()

uint add_pk_parts_to_sk ( KEY sk,
uint  sk_n,
KEY pk,
uint  pk_n,
TABLE_SHARE share,
handler handler_file,
uint usable_parts 
)

Generate extended secondary keys by adding primary key parts to the existing secondary key.

A primary key part is added if such part doesn't present in the secondary key or the part in the secondary key is a prefix of the key field. Key parts are added till: .) all parts were added .) number of key parts became bigger that MAX_REF_PARTS .) total key length became longer than MAX_REF_LENGTH depending on what occurs first first. Unlike existing secondary key parts which are initialized at open_binary_frm(), newly added ones are initialized here by copying KEY_PART_INFO structure from primary key part and calling setup_key_part_field().

Function updates sk->actual/unused_key_parts and sk->actual_flags.

Parameters
[in]skSecondary key
[in]sk_nSecondary key number
[in]pkPrimary key
[in]pk_nPrimary key number
[in]sharePointer to TABLE_SHARE
[in]handler_filePointer to handler
[in,out]usable_partsPointer to usable_parts variable
Return values
Numberof added key parts

◆ alloc_table_share()

TABLE_SHARE* alloc_table_share ( const char *  db,
const char *  table_name,
const char *  key,
size_t  key_length,
bool  open_secondary 
)

Allocate and setup a TABLE_SHARE structure.

Parameters
dbschema name.
table_nametable name.
keytable cache key (db \0 table_name \0...)
key_lengthlength of the key
open_secondarytrue if the TABLE_SHARE represents a table in a secondary storage engine
Returns
pointer to allocated table share
Return values
NULLerror (out of memory, too long path name)

◆ append_unescaped()

void append_unescaped ( String res,
const char *  pos,
size_t  length 
)

Store an SQL quoted string.

Parameters
resresult String
posstring to be quoted
lengthit's length

NOTE This function works correctly with utf8 or single-byte charset strings. May fail with some multibyte charsets though.

◆ assert_ref_count_is_locked()

bool assert_ref_count_is_locked ( const TABLE_SHARE share)

Assert that the LOCK_open mutex is held when the reference count of a TABLE_SHARE is accessed.

Parameters
sharethe TABLE_SHARE
Returns
true if the assertion holds, terminates the process otherwise

◆ check_and_convert_db_name()

Ident_name_check check_and_convert_db_name ( LEX_STRING org_name,
bool  preserve_lettercase 
)

Check if database name is valid, and convert to lower case if necessary.

Parameters
org_nameName of database and length
preserve_lettercasePreserve lettercase if true
Note
If lower_case_table_names is true and preserve_lettercase is false then database is converted to lower case
Return values
Ident_name_check::OKIdentifier name is Ok (Success)
Ident_name_check::WRONGIdentifier name is Wrong (ER_WRONG_TABLE_NAME)
Ident_name_check::TOO_LONGIdentifier name is too long if it is greater than 64 characters (ER_TOO_LONG_IDENT)
Note
In case of Ident_name_check::WRONG and Ident_name_check::TOO_LONG, this function reports an error (my_error)

◆ check_column_name()

bool check_column_name ( const char *  name)

◆ check_db_name()

Ident_name_check check_db_name ( const char *  name,
size_t  length 
)

Check if database name is valid.

Parameters
nameName of database
lengthLength of name
Return values
Ident_name_check::OKIdentifier name is Ok (Success)
Ident_name_check::WRONGIdentifier name is Wrong (ER_WRONG_TABLE_NAME)
Ident_name_check::TOO_LONGIdentifier name is too long if it is greater than 64 characters (ER_TOO_LONG_IDENT)
Note
In case of Ident_name_check::WRONG and Ident_name_check::TOO_LONG, this function reports an error (my_error)

◆ check_table_name()

Ident_name_check check_table_name ( const char *  name,
size_t  length 
)

Function to check if table name is valid or not.

If it is invalid, return appropriate error in each case to the caller.

Parameters
nameTable name
lengthLength of table name
Return values
Ident_name_check::OKIdentifier name is Ok (Success)
Ident_name_check::WRONGIdentifier name is Wrong (ER_WRONG_TABLE_NAME)
Ident_name_check::TOO_LONGIdentifier name is too long if it is greater than 64 characters (ER_TOO_LONG_IDENT)
Note
Reporting error to the user is the responsiblity of the caller.

◆ closefrm()

int closefrm ( TABLE table,
bool  free_share 
)

Free information allocated by openfrm.

Parameters
tableTABLE object to free
free_shareIs 1 if we also want to free table_share

◆ create_table_share_for_upgrade()

bool create_table_share_for_upgrade ( THD thd,
const char *  path,
TABLE_SHARE share,
FRM_context frm_context,
const char *  db,
const char *  table,
bool  is_fix_view_cols_and_deps 
)

Create TABLE_SHARE from .frm file.

FRM_context object is used to store the value removed from TABLE_SHARE. These values are used only for .frm file parsing.

Parameters
[in]thdThread handle.
[in]pathPath of the frm file.
[out]shareTABLE_SHARE to be populated.
[out]frm_contextFRM_context object.
[in]dbDatabase name.
[in]tableTable name.
[in]is_fix_view_cols_and_depsFix view column data, table and routine dependency.
Return values
TABLE_SHAREON SUCCESS
NULLON FAILURE

◆ dbug_tmp_restore_column_map()

static void dbug_tmp_restore_column_map ( MY_BITMAP bitmap,
my_bitmap_map old 
)
inlinestatic

◆ dbug_tmp_restore_column_maps()

static void dbug_tmp_restore_column_maps ( MY_BITMAP read_set,
MY_BITMAP write_set,
my_bitmap_map **  old 
)
inlinestatic

◆ dbug_tmp_use_all_columns() [1/2]

static my_bitmap_map* dbug_tmp_use_all_columns ( TABLE table,
MY_BITMAP bitmap 
)
inlinestatic

◆ dbug_tmp_use_all_columns() [2/2]

static void dbug_tmp_use_all_columns ( TABLE table,
my_bitmap_map **  save,
MY_BITMAP read_set,
MY_BITMAP write_set 
)
inlinestatic

◆ empty_record()

static void empty_record ( TABLE table)
inlinestatic

◆ fn_rext()

char* fn_rext ( char *  name)

Returns pointer to '.frm' extension of the file name.

Parameters
namefile name

Checks file name part starting with the rightmost '.' character, and returns it if it is equal to '.frm'.

Returns
Pointer to the '.frm' extension. If there is no extension, or extension is not '.frm', pointer at the end of file name.

◆ free_blob_buffers_and_reset()

void free_blob_buffers_and_reset ( TABLE table,
uint32  size 
)

Reclaims temporary blob storage which is bigger than a threshold.

Resets blob pointer. Unsets m_keep_old_value.

Parameters
tableA handle to the TABLE object containing blob fields
sizeThe threshold value.

◆ free_blobs()

void free_blobs ( TABLE table)

◆ free_table_share()

void free_table_share ( TABLE_SHARE share)

Free table share and memory used by it.

Parameters
shareTable share

◆ get_field() [1/2]

char* get_field ( MEM_ROOT mem,
Field field 
)

Allocate string field in MEM_ROOT and return it as NULL-terminated string.

Parameters
memMEM_ROOT for allocating
fieldField for retrieving of string
Return values
NullSstring is empty
otherpointer to NULL-terminated string value of field

◆ get_field() [2/2]

bool get_field ( MEM_ROOT mem,
Field field,
String res 
)

Allocate string field in MEM_ROOT and return it as String.

Parameters
memMEM_ROOT for allocating
fieldField for retrieving of string
resresult String
Return values
1string is empty
0all ok

◆ get_field_name()

const uchar* get_field_name ( const uchar arg,
size_t *  length 
)

◆ get_table_category()

TABLE_CATEGORY get_table_category ( const LEX_CSTRING db,
const LEX_CSTRING name 
)

◆ init_mdl_requests()

void init_mdl_requests ( TABLE_LIST table_list)

Helper function which allows to allocate metadata lock request objects for all elements of table list.

◆ init_tmp_table_share()

void init_tmp_table_share ( THD thd,
TABLE_SHARE share,
const char *  key,
size_t  key_length,
const char *  table_name,
const char *  path,
MEM_ROOT mem_root 
)

Initialize share for temporary tables.

Parameters
thdthread handle
shareShare to fill
keyTable_cache_key, as generated from create_table_def_key. must start with db name.
key_lengthLength of key
table_nameTable name
pathPath to file (possible in lower case) without .frm
mem_rootMEM_ROOT to transfer (move) to the TABLE_SHARE; if NULL a new one is initialized.
Note
This is different from alloc_table_share() because temporary tables don't have to be shared between threads or put into the table def cache, so we can do some things notable simpler and faster

If table is not put in thd->temporary_tables (happens only when one uses OPEN TEMPORARY) then one can specify 'db' as key and use key_length= 0 as neither table_cache_key or key_length will be used).

◆ is_infoschema_db() [1/2]

bool is_infoschema_db ( const char *  name,
size_t  len 
)
inline

◆ is_infoschema_db() [2/2]

bool is_infoschema_db ( const char *  name)
inline

◆ is_perfschema_db() [1/2]

bool is_perfschema_db ( const char *  name,
size_t  len 
)
inline

◆ is_perfschema_db() [2/2]

bool is_perfschema_db ( const char *  name)
inline

◆ is_simple_order()

bool is_simple_order ( ORDER order)

Test if the order list consists of simple field expressions.

Parameters
orderLinked list of ORDER BY arguments
Returns
true if order is empty or consist of simple field expressions

◆ is_temporary_table()

bool is_temporary_table ( TABLE_LIST tl)
inline

Check if a TABLE_LIST instance represents a pre-opened temporary table.

◆ is_user_table()

bool is_user_table ( TABLE table)
inline

return true if the table was created explicitly.

◆ mdl_type_for_dml()

enum enum_mdl_type mdl_type_for_dml ( enum thr_lock_type  lock_type)
inline

Derive type of metadata lock to be requested for table used by a DML statement from the type of THR_LOCK lock requested for this table.

◆ open_table_from_share()

int open_table_from_share ( THD thd,
TABLE_SHARE share,
const char *  alias,
uint  db_stat,
uint  prgflag,
uint  ha_open_flags,
TABLE outparam,
bool  is_create_table,
const dd::Table table_def_param 
)

Open a table based on a TABLE_SHARE.

Parameters
thdThread handler
shareTable definition
aliasAlias for table
db_statOpen flags (for example HA_OPEN_KEYFILE| HA_OPEN_RNDFILE..) can be 0 (example in ha_example_table)
prgflagREAD_ALL etc..
ha_open_flagsHA_OPEN_ABORT_IF_LOCKED etc..
outparamResult table.
is_create_tableIndicates that table is opened as part of CREATE or ALTER and does not yet exist in SE.
table_def_paramdd::Table object describing the table to be opened in SE. Can be nullptr, which case this function will try to retrieve such object from the data-dictionary before opening table in SE.
Return values
0ok
1Error (see open_table_error)
2Error (see open_table_error)
4Error (see open_table_error)
7Table definition has changed in engine
8Table row format has changed in engine

◆ rename_file_ext()

int rename_file_ext ( const char *  from,
const char *  to,
const char *  ext 
)

◆ repoint_field_to_record()

void repoint_field_to_record ( TABLE table,
uchar old_rec,
uchar new_rec 
)

Repoint a table's fields from old_rec to new_rec.

Parameters
tablethe table of fields needed to be repointed
old_recthe original record buffer fields point to
new_recthe target record buff fields need to repoint

◆ set_zone()

int set_zone ( int  nr,
int  min_zone,
int  max_zone 
)

◆ setup_key_part_field()

void setup_key_part_field ( TABLE_SHARE share,
handler handler_file,
uint  primary_key_n,
KEY keyinfo,
uint  key_n,
uint  key_part_n,
uint usable_parts,
bool  part_of_key_not_extended 
)

Setup key-related fields of Field object for given key and key part.

Parameters
[in]sharePointer to TABLE_SHARE
[in]handler_filePointer to handler
[in]primary_key_nPrimary key number
[in]keyinfoPointer to processed key
[in]key_nProcessed key number
[in]key_part_nProcessed key part number
[in,out]usable_partsPointer to usable_parts variable
[in]part_of_key_not_extendedSet when column is part of the Key and not appended by the storage engine from primary key columns.

◆ tmp_restore_column_map()

static void tmp_restore_column_map ( MY_BITMAP bitmap,
my_bitmap_map old 
)
inlinestatic

◆ tmp_use_all_columns()

static my_bitmap_map* tmp_use_all_columns ( TABLE table,
MY_BITMAP bitmap 
)
inlinestatic

◆ unpack_partition_info()

bool unpack_partition_info ( THD thd,
TABLE outparam,
TABLE_SHARE share,
handlerton engine_type,
bool  is_create_table 
)

Unpack the partition expression.

Parse the partition expression to produce an Item.

Parameters
[in]thdThread handler
[in]outparamTable object
[in]shareTABLE_SHARE object
[in]engine_typeEngine type of the partitions.
[in]is_create_tableIndicates that table is opened as part of CREATE or ALTER and does not yet exist in SE
Return values
trueFailure.
falseSuccess.

◆ unpack_value_generator()

bool unpack_value_generator ( THD thd,
TABLE table,
Value_generator **  val_generator,
Value_generator_source  source,
const char *  source_name,
Field field,
bool  is_create_table,
bool error_reported 
)

Unpacks the definition of a generated column, default expression or check constraint expression passed as argument.

Parses the text obtained from TABLE_SHARE and produces an Item.

Parameters
thdThread handler
tableTable with the checked field
val_generatorThe expression to unpack.
sourceSource of value generator(a generated column, a regular column with generated default value or a check constraint).
source_nameName of the source (generated column, a reguler column with generated default value or a check constraint).
fieldPointer to Field object
is_create_tableIndicates that table is opened as part of CREATE or ALTER and does not yet exist in SE
error_reportedupdated flag for the caller that no other error messages are to be generated.
Return values
trueFailure.
falseSuccess.

◆ update_create_info_from_table()

void update_create_info_from_table ( HA_CREATE_INFO info,
TABLE form 
)

◆ update_generated_read_fields()

bool update_generated_read_fields ( uchar buf,
TABLE table,
uint  active_index 
)

Evaluate necessary virtual generated columns.

This is used right after reading a row from the storage engine.

Note
this is not necessary for stored generated columns, as they are provided by the storage engine.
Parameters
[in,out]bufthe buffer to store data
tablethe TABLE object
active_indexthe number of key for index scan (MAX_KEY is default)
Returns
true if error.

◆ update_generated_write_fields()

bool update_generated_write_fields ( const MY_BITMAP bitmap,
TABLE table 
)

Calculate data for each generated field marked for write in the corresponding column map.

Note
We need calculate data for both virtual and stored generated fields.
Parameters
bitmapBitmap over fields to update
tablethe TABLE object
Returns
Return values
false- Success
true- Error occurred during the generation/calculation of a generated field value

Variable Documentation

◆ GENERAL_LOG_NAME

LEX_STRING GENERAL_LOG_NAME

◆ INFORMATION_SCHEMA_NAME

LEX_CSTRING INFORMATION_SCHEMA_NAME

◆ MI_INFO_NAME

LEX_STRING MI_INFO_NAME

◆ MYSQL_SCHEMA_DD_ID

const uint MYSQL_SCHEMA_DD_ID = 1
static

◆ MYSQL_SCHEMA_NAME

LEX_STRING MYSQL_SCHEMA_NAME

◆ MYSQL_TABLESPACE_DD_ID

const uint MYSQL_TABLESPACE_DD_ID = 1
static

◆ MYSQL_TABLESPACE_NAME

LEX_STRING MYSQL_TABLESPACE_NAME

◆ PERFORMANCE_SCHEMA_DB_NAME

LEX_STRING PERFORMANCE_SCHEMA_DB_NAME

◆ refresh_version

ulong refresh_version

◆ RLI_INFO_NAME

LEX_STRING RLI_INFO_NAME

◆ SLOW_LOG_NAME

LEX_STRING SLOW_LOG_NAME

◆ WORKER_INFO_NAME

LEX_STRING WORKER_INFO_NAME