24#ifndef SQL_TABLE_INCLUDED 
   25#define SQL_TABLE_INCLUDED 
   39#include "mysqld_error.h" 
   97                             bool stay_quiet = 
false,
 
   98                             bool *has_errors = 
nullptr);
 
  102                            bool *was_truncated);
 
  107  bool truncated_not_used;
 
  109                              &truncated_not_used);
 
  117                                Alter_info *alter_info, uint select_field_count,
 
  118                                bool find_parent_keys, 
bool *is_trans,
 
  132  typedef std::map<std::pair<dd::String_type, dd::String_type>,
 
  133                   std::pair<handlerton *, enum_invalidation_type>>
 
  166      const char *old_db_name = 
nullptr, 
const char *old_table_name = 
nullptr,
 
  167      const char *new_db_name = 
nullptr,
 
  168      const char *new_table_name = 
nullptr) noexcept
 
  249    THD *thd, 
bool check_charsets, 
const char *parent_table_db,
 
  250    const char *parent_table_name, 
handlerton *hton,
 
  252    bool invalidate_tdc);
 
  261    THD *thd, 
const char *parent_table_db, 
const char *parent_table_name,
 
  265      thd, 
true, parent_table_db, parent_table_name, hton, parent_table_def,
 
  266      parent_alter_info, 
true);
 
  334                                  uint fk_max_generated_name_number,
 
  378    THD *thd, 
const char *db, 
const char *
table_name, 
const char *new_db,
 
  379    const char *new_table_name, 
handlerton *hton);
 
  397                                               const char *new_table_name,
 
  432                                         bool is_self_referencing_fk,
 
  464                             const uint &used_fields);
 
  481                        const char *old_name, 
const char *old_fk_db,
 
  482                        const char *old_fk_name, 
const dd::Schema &new_schema,
 
  483                        const char *new_db, 
const char *new_name, uint 
flags);
 
  488                    bool drop_temporary);
 
  490                             bool drop_temporary, 
bool drop_database,
 
  491                             const char *database_name,
 
  492                             const bool should_drop_schema_ddl_log,
 
  493                             bool *dropped_non_atomic_flag,
 
  494                             std::set<handlerton *> *post_ddl_htons,
 
  496                             std::vector<MDL_ticket *> *safe_to_release_mdl);
 
  521                             size_t *comment_len, uint max_len, uint err_code,
 
  522                             const char *comment_name);
 
  524                  size_t query_length, 
bool is_trans = 
false);
 
  547                          const char *error_table_name,
 
  589    THD *thd, 
const char *error_schema_name, 
const char *error_table_name,
 
  591    bool is_partitioned, 
KEY **key_info_buffer, uint *key_count,
 
  592    FOREIGN_KEY **fk_key_info_buffer, uint *fk_key_count,
 
  593    FOREIGN_KEY *existing_fks, uint existing_fks_count,
 
  594    const dd::Table *existing_fks_table, uint fk_max_generated_name_number,
 
  595    int select_field_count, 
bool find_parent_keys);
 
  647                                            const char *target_db,
 
  648                                            const char *target_table_name);
 
  686                                         bool error_if_not_loaded);
 
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:205
 
Runtime context for ALTER TABLE.
Definition: sql_alter.h:516
 
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:51
 
Helper class for keeping track for which tables we need to invalidate data-dictionary cache entries a...
Definition: sql_table.h:126
 
void invalidate(THD *thd)
Definition: sql_table.cc:1540
 
void mark_for_reopen_if_added(const char *db_name, const char *table_name)
Definition: sql_table.cc:1530
 
const Parent_map & parents() const
Definition: sql_table.h:151
 
enum_invalidation_type
Definition: sql_table.h:128
 
@ INVALIDATE_AND_MARK_FOR_REOPEN
Definition: sql_table.h:130
 
@ INVALIDATE_AND_CLOSE_TABLE
Definition: sql_table.h:129
 
std::map< std::pair< dd::String_type, dd::String_type >, std::pair< handlerton *, enum_invalidation_type > > Parent_map
Definition: sql_table.h:134
 
void clear()
Definition: sql_table.h:153
 
void add(const char *db_name, const char *table_name, handlerton *hton, enum_invalidation_type invalidation_type=INVALIDATE_AND_CLOSE_TABLE)
Definition: sql_table.cc:1522
 
Parent_map m_parent_map
Definition: sql_table.h:135
 
bool is_empty() const
Definition: sql_table.h:152
 
Intrusive parameterized list.
Definition: sql_plist.h:75
 
Definition: sql_list.h:494
 
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
 
Auxiliary class implementing RAII principle for getting permission for/ notification about finished D...
Definition: sql_table.h:162
 
bool m_hton_notified
Definition: sql_table.h:197
 
const MDL_key m_key
Definition: sql_table.h:199
 
THD * m_thd
Definition: sql_table.h:198
 
bool notify() noexcept
Definition: sql_table.h:178
 
const char * m_old_db_name
Definition: sql_table.h:201
 
const char * m_new_table_name
Definition: sql_table.h:204
 
const ha_ddl_type m_ddl_type
Definition: sql_table.h:200
 
const char * m_old_table_name
Definition: sql_table.h:202
 
const char * m_new_db_name
Definition: sql_table.h:203
 
Table_ddl_hton_notification_guard(THD *thd, const MDL_key *key, ha_ddl_type ddl_type, const char *old_db_name=nullptr, const char *old_table_name=nullptr, const char *new_db_name=nullptr, const char *new_table_name=nullptr) noexcept
Definition: sql_table.h:164
 
~Table_ddl_hton_notification_guard()
Definition: sql_table.h:189
 
Definition: foreign_key.h:47
 
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4741
 
A table definition from the master.
Definition: rpl_utility.h:249
 
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
 
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:217
 
static int flags[50]
Definition: hp_test1.cc:40
 
Some integer typedefs for easier portability.
 
long long int longlong
Definition: my_inttypes.h:55
 
#define MYF(v)
Definition: my_inttypes.h:97
 
Functions related to handling of plugins and other dynamically loaded libraries.
 
#define MYSQL_PLUGIN_IMPORT
Definition: my_sharedlib.h:71
 
static char * query
Definition: myisam_ftdump.cc:47
 
ABI for instrumented mutexes.
 
static Secondary_engine * secondary_engine
Definition: mysqltest.cc:260
 
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
 
borrowable::session_track::Schema< true > Schema
Definition: classic_protocol_session_track.h:288
 
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:43
 
Json_data_extension ext
Definition: backend.cc:50
 
entry::Table Table
Definition: select.h:51
 
const char * table_name
Definition: rules_table_service.cc:56
 
const char * db_name
Definition: rules_table_service.cc:55
 
required string key
Definition: replication_asynchronous_connection_failover.proto:60
 
bool ha_notify_table_ddl(THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, ha_ddl_type ddl_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name)
Notify/get permission from all interested storage engines before or after executed DDL (ALTER TABLE,...
Definition: handler.cc:8926
 
ha_ddl_type
Definition: handler.h:964
 
@ HA_NOTIFY_POST_EVENT
Definition: handler.h:963
 
@ HA_NOTIFY_PRE_EVENT
Definition: handler.h:963
 
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:106
 
static const uint NO_DD_COMMIT
Don't commit transaction after updating data-dictionary while renaming the table.
Definition: sql_table.h:87
 
bool collect_fk_parents_for_new_fks(THD *thd, const char *db_name, const char *table_name, const Alter_info *alter_info, enum_mdl_type lock_type, handlerton *hton, MDL_request_list *mdl_requests, Foreign_key_parents_invalidator *fk_invalidator)
Add MDL requests for lock of specified type on tables referenced by the foreign keys to be added by t...
Definition: sql_table.cc:10774
 
bool lock_check_constraint_names_for_rename(THD *thd, const char *db, const char *table_name, const dd::Table *table_def, const char *target_db, const char *target_table_name)
Method to lock check constraint names for rename table operation.
Definition: sql_table.cc:20721
 
static const uint FN_TO_IS_TMP
Definition: sql_table.h:79
 
int write_bin_log(THD *thd, bool clear_error, const char *query, size_t query_length, bool is_trans=false)
Definition: sql_table.cc:1265
 
size_t tablename_to_filename(const char *from, char *to, size_t to_length)
Definition: sql_table.cc:845
 
void promote_first_timestamp_column(List< Create_field > *column_definitions)
Modifies the first column definition whose SQL type is TIMESTAMP by adding the features DEFAULT CURRE...
Definition: sql_table.cc:4364
 
bool adjust_fk_parents(THD *thd, const char *db, const char *name, bool reload_self, const Foreign_key_parents_invalidator *fk_invalidator)
Definition: sql_table.cc:10227
 
bool lock_trigger_names(THD *thd, Table_ref *tables)
Acquire metadata lock on triggers associated with a list of tables.
Definition: sql_table.cc:1280
 
bool lock_check_constraint_names(THD *thd, Table_ref *tables)
Method to collect check constraint names for the all the tables and acquire MDL lock on them.
Definition: sql_table.cc:20781
 
bool quick_rm_table(THD *thd, handlerton *base, const char *db, const char *table_name, uint flags)
Quickly remove a table.
Definition: sql_table.cc:4007
 
bool rm_table_do_discovery_and_lock_fk_tables(THD *thd, Table_ref *tables)
Discover missing tables in SE and acquire locks on tables which participate in FKs on tables to be dr...
Definition: sql_table.cc:1450
 
bool mysql_prepare_create_table(THD *thd, const char *error_schema_name, const char *error_table_name, HA_CREATE_INFO *create_info, Alter_info *alter_info, handler *file, bool is_partitioned, KEY **key_info_buffer, uint *key_count, FOREIGN_KEY **fk_key_info_buffer, uint *fk_key_count, FOREIGN_KEY *existing_fks, uint existing_fks_count, const dd::Table *existing_fks_table, uint fk_max_generated_name_number, int select_field_count, bool find_parent_keys)
Prepares the table and key structures for table creation.
Definition: sql_table.cc:8263
 
bool collect_fk_names_for_new_fks(THD *thd, const char *db_name, const char *table_name, const Alter_info *alter_info, handlerton *hton, uint fk_max_generated_name_number, MDL_request_list *mdl_requests)
Add MDL requests for exclusive metadata locks on names of foreign keys to be added by the CREATE TABL...
Definition: sql_table.cc:10811
 
bool adjust_adopted_self_ref_fk_for_simple_rename_table(THD *thd, const char *db, const char *table_name, const char *new_db, const char *new_table_name, handlerton *hton)
As a result of simple rename table operation, orphan non-self-referencing foreign keys may become non...
Definition: sql_table.cc:16623
 
std::atomic_ullong deprecated_use_fk_on_non_standard_key_last_timestamp
Last time fk is created on non standard index key, as usec since epoch.
Definition: sql_table.cc:224
 
handlerton * get_viable_handlerton_for_create(THD *thd, const char *table_name, const HA_CREATE_INFO &ci)
Checks if the handlerton for the specified ENGINE is enabled AND NOT explicitly disabled (listed in t...
Definition: sql_table.cc:438
 
const CHARSET_INFO * get_sql_field_charset(const Create_field *sql_field, const HA_CREATE_INFO *create_info)
Get the character set from field object generated by the parser, using default values when not set.
Definition: sql_table.cc:4331
 
mysql_mutex_t mysql_mutex_t
Definition: sql_table.h:65
 
bool mysql_compare_tables(THD *thd, TABLE *table, Alter_info *alter_info, HA_CREATE_INFO *create_info, bool *metadata_equal)
Compare two tables to see if their metadata are compatible.
Definition: sql_table.cc:13587
 
bool mysql_prepare_alter_table(THD *thd, const dd::Table *src_table, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info, Alter_table_ctx *alter_ctx)
Prepare column and key definitions for CREATE TABLE in ALTER TABLE.
Definition: sql_table.cc:16225
 
bool prepare_sp_create_field(THD *thd, Create_field *field_def)
Prepare an instance of Create_field for field creation (fill all necessary attributes).
Definition: sql_table.cc:4310
 
bool mysql_rename_table(THD *thd, handlerton *base, const char *old_db, const char *old_name, const char *old_fk_db, const char *old_fk_name, const dd::Schema &new_schema, const char *new_db, const char *new_name, uint flags)
Rename a table.
Definition: sql_table.cc:11460
 
bool mysql_rm_table_no_locks(THD *thd, Table_ref *tables, bool if_exists, bool drop_temporary, bool drop_database, const char *database_name, const bool should_drop_schema_ddl_log, bool *dropped_non_atomic_flag, std::set< handlerton * > *post_ddl_htons, Foreign_key_parents_invalidator *fk_invalidator, std::vector< MDL_ticket * > *safe_to_release_mdl)
Execute the drop of a normal or temporary table.
Definition: sql_table.cc:3276
 
bool collect_fk_children(THD *thd, const char *schema, const char *table_name, handlerton *hton, enum_mdl_type lock_type, MDL_request_list *mdl_requests)
Add MDL requests for specified lock type on all tables referencing the given schema qualified table n...
Definition: sql_table.cc:10159
 
bool prepare_fk_parent_key(THD *thd, handlerton *hton, const dd::Table *parent_table_def, const dd::Table *old_parent_table_def, const dd::Table *old_child_table_def, bool is_self_referencing_fk, dd::Foreign_key *fk)
Definition: sql_table.cc:6690
 
bool prepare_fields_and_keys(THD *thd, const dd::Table *src_table, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info, Alter_table_ctx *alter_ctx, const uint &used_fields)
Prepare Create_field and Key_spec objects for ALTER and upgrade.
Definition: sql_table.cc:15558
 
MYSQL_PLUGIN_IMPORT const char * primary_key_name
Definition: sql_table.cc:234
 
size_t filename_to_tablename(const char *from, char *to, size_t to_length, bool stay_quiet=false, bool *has_errors=nullptr)
Definition: sql_table.cc:800
 
bool prepare_pack_create_field(THD *thd, Create_field *sql_field, longlong table_flags)
Prepare a create_table instance for packing.
Definition: sql_table.cc:4158
 
static const uint NO_CC_RENAME
Don't change generated check constraint names while renaming table.
Definition: sql_table.h:91
 
static const uint FN_FROM_IS_TMP
Definition: sql_table.h:78
 
bool mysql_rm_table(THD *thd, Table_ref *tables, bool if_exists, bool drop_temporary)
Definition: sql_table.cc:1613
 
size_t build_tmptable_filename(THD *thd, char *buff, size_t bufflen)
Create path to a temporary table, like mysql_tmpdir/#sql1234_12_1 (i.e.
Definition: sql_table.cc:952
 
static const uint FN_IS_TMP
Definition: sql_table.h:80
 
static const uint NO_FK_RENAME
Don't change generated foreign key names while renaming table.
Definition: sql_table.h:89
 
size_t explain_filename(THD *thd, const char *from, char *to, size_t to_length, enum_explain_filename_mode explain_mode)
Explain a path name by split it to database, table etc.
Definition: sql_table.cc:645
 
bool mysql_create_table_no_lock(THD *thd, const char *db, const char *table_name, HA_CREATE_INFO *create_info, Alter_info *alter_info, uint select_field_count, bool find_parent_keys, bool *is_trans, handlerton **post_ddl_ht)
Simple wrapper around create_table_impl() to be used in various version of CREATE TABLE statement.
Definition: sql_table.cc:9984
 
bool mysql_create_table(THD *thd, Table_ref *create_table, HA_CREATE_INFO *create_info, Alter_info *alter_info)
Implementation of SQLCOM_CREATE_TABLE.
Definition: sql_table.cc:10889
 
bool collect_and_lock_fk_tables_for_rename_table(THD *thd, const char *db, const char *table_name, const dd::Table *table_def, const char *new_db, const char *new_table_name, handlerton *hton, Foreign_key_parents_invalidator *fk_invalidator)
Acquire exclusive metadata locks on tables which definitions need to be updated or invalidated since ...
Definition: sql_table.cc:16599
 
std::atomic_ulong deprecated_use_fk_on_non_standard_key_count
Count number of times foreign key is created on non standard index keys.
Definition: sql_table.cc:221
 
bool mysql_alter_table(THD *thd, const char *new_db, const char *new_name, HA_CREATE_INFO *create_info, Table_ref *table_list, Alter_info *alter_info)
Alter table.
Definition: sql_table.cc:17218
 
size_t build_table_filename(char *buff, size_t bufflen, const char *db, const char *table, const char *ext, uint flags, bool *was_truncated)
Definition: sql_table.cc:894
 
bool secondary_engine_unload_table_inner(THD *thd, const char *db_name, const char *table_name, LEX_CSTRING secondary_engine, bool is_partitioned, bool error_if_not_loaded)
Resolves the secondary engine handled via its name and calls the unload table function.
Definition: sql_table.cc:2858
 
bool mysql_recreate_table(THD *thd, Table_ref *table_list, bool table_copy)
Definition: sql_table.cc:19688
 
bool mysql_create_like_table(THD *thd, Table_ref *table, Table_ref *src_table, HA_CREATE_INFO *create_info)
Definition: sql_table.cc:11703
 
bool secondary_engine_unload_materialized_view(THD *thd, const Table_ref *view, const dd::View *view_def)
Unloads the materialized view from a secondary engine, where it might be materialized.
Definition: sql_table.cc:2842
 
bool prepare_create_field(THD *thd, const char *error_schema_name, const char *error_table_name, HA_CREATE_INFO *create_info, List< Create_field > *create_list, int *select_field_pos, handler *file, Create_field *sql_field, int field_no)
Prepares the column definitions for table creation.
Definition: sql_table.cc:4686
 
bool mysql_trans_prepare_alter_copy_data(THD *thd)
Prepare the transaction for the alter table's copy phase.
Definition: sql_table.cc:19330
 
static const uint NO_FK_CHECKS
Don't check foreign key constraints while renaming table.
Definition: sql_table.h:82
 
bool adjust_fks_for_rename_table(THD *thd, const char *db, const char *table_name, const char *new_db, const char *new_table_name, handlerton *hton)
Update referenced table names and the unique constraint name for FKs affected by RENAME TABLE operati...
Definition: sql_table.cc:16662
 
enum_explain_filename_mode
Definition: sql_table.h:71
 
@ EXPLAIN_PARTITIONS_VERBOSE
Definition: sql_table.h:73
 
@ EXPLAIN_ALL_VERBOSE
Definition: sql_table.h:72
 
@ EXPLAIN_PARTITIONS_AS_COMMENT
Definition: sql_table.h:74
 
TYPELIB * create_typelib(MEM_ROOT *mem_root, Create_field *field_def)
Definition: sql_table.cc:4249
 
bool adjust_fk_children_after_parent_def_change(THD *thd, bool check_charsets, const char *parent_table_db, const char *parent_table_name, handlerton *hton, const dd::Table *parent_table_def, Alter_info *parent_alter_info, bool invalidate_tdc)
Check if new definition of parent table is compatible with foreign keys which reference it.
Definition: sql_table.cc:10527
 
bool validate_comment_length(THD *thd, const char *comment_str, size_t *comment_len, uint max_len, uint err_code, const char *comment_name)
check comment length of table, column, index and partition
Definition: sql_table.cc:8729
 
bool prepare_check_constraints_for_create(THD *thd, const char *db_name, const char *table_name, Alter_info *alter_info)
Method to prepare check constraints for the CREATE operation.
Definition: sql_table.cc:20003
 
bool mysql_trans_commit_alter_copy_data(THD *thd)
Commit the copy phase of the alter table.
Definition: sql_table.cc:19350
 
bool mysql_checksum_table(THD *thd, Table_ref *table_list, HA_CHECK_OPT *check_opt)
Definition: sql_table.cc:19714
 
bool mysql_discard_or_import_tablespace(THD *thd, Table_ref *table_list)
 
bool validate_secondary_engine_temporary_table(THD *thd, HA_CREATE_INFO *create_info)
Validation on create temporary table statements with secondary engine defined:
Definition: sql_table.cc:8994
 
case opt name
Definition: sslopt-case.h:29
 
Definition: m_ctype.h:421
 
Definition: handler.h:3954
 
Struct to hold information about the table that should be created.
Definition: handler.h:3347
 
Metadata lock object key.
Definition: mdl.h:366
 
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
 
Definition: mysql_lex_string.h:40
 
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2851
 
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50