MySQL 8.0.40
Source Code Documentation
dd_table.cc File Reference
#include "sql/dd/dd_table.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include "lex_string.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/udf_registration_types.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/collection.h"
#include "sql/dd/dd.h"
#include "sql/dd/dictionary.h"
#include "sql/dd/impl/dictionary_impl.h"
#include "sql/dd/impl/system_registry.h"
#include "sql/dd/impl/tables/dd_properties.h"
#include "sql/dd/impl/utils.h"
#include "sql/dd/performance_schema/init.h"
#include "sql/create_field.h"
#include "sql/dd/dd_version.h"
#include "sql/dd/properties.h"
#include "sql/dd/string_type.h"
#include "sql/dd/tablespace_id_owner_visitor.h"
#include "sql/dd/types/abstract_table.h"
#include "sql/dd/types/check_constraint.h"
#include "sql/dd/types/column.h"
#include "sql/dd/types/column_type_element.h"
#include "sql/dd/types/foreign_key.h"
#include "sql/dd/types/foreign_key_element.h"
#include "sql/dd/types/index.h"
#include "sql/dd/types/index_element.h"
#include "sql/dd/types/object_table.h"
#include "sql/dd/types/partition.h"
#include "sql/dd/types/partition_index.h"
#include "sql/dd/types/partition_value.h"
#include "sql/dd/types/schema.h"
#include "sql/dd/types/table.h"
#include "sql/dd/types/tablespace.h"
#include "sql/dd_table_share.h"
#include "sql/debug_sync.h"
#include "sql/default_values.h"
#include "sql/enum_query_type.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/key.h"
#include "sql/key_spec.h"
#include "sql/log.h"
#include "sql/mdl.h"
#include "sql/mem_root_array.h"
#include "sql/my_decimal.h"
#include "sql/mysqld.h"
#include "sql/partition_element.h"
#include "sql/partition_info.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_check_constraint.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_gipk.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_partition.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sql_show.h"
#include "sql/sql_table.h"
#include "sql/srs_fetcher.h"
#include "sql/strfunc.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql_string.h"
#include "typelib.h"

Namespaces

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

Functions

dd::enum_column_types dd::get_new_field_type (enum_field_types type)
 Convert to and from new enum types in DD framework to current MySQL server enum types. More...
 
dd::String_type dd::get_sql_type_by_create_field (TABLE *table, const Create_field &field)
 Function returns string representing column type by Create_field. More...
 
static void dd::prepare_default_value_string (uchar *buf, TABLE *table, const Create_field &field, dd::Column *col_obj, String *def_value)
 Helper method to get default value of column in the string format. More...
 
bool dd::get_field_numeric_scale (const Create_field *field, uint *scale)
 Helper method to get numeric scale for types using Create_field type object. More...
 
bool dd::get_field_numeric_precision (const Create_field *field, uint *numeric_precision)
 Helper method to get numeric precision for types using Create_field type object. More...
 
bool dd::get_field_datetime_precision (const Create_field *field, uint *datetime_precision)
 Helper method to get datetime precision for types using Create_field type object. More...
 
static dd::String_type dd::now_with_opt_decimals (uint decimals)
 
bool dd::fill_dd_columns_from_create_fields (THD *thd, dd::Abstract_table *tab_obj, const List< Create_field > &create_fields, handler *file)
 Add column objects to dd::Abstract_table according to list of Create_field objects. More...
 
static dd::Index::enum_index_algorithm dd::dd_get_new_index_algorithm_type (enum ha_key_alg type)
 
static dd::Index::enum_index_type dd::dd_get_new_index_type (const KEY *key)
 
static void dd::fill_dd_index_elements_from_key_parts (const dd::Table *tab_obj, dd::Index *idx_obj, uint key_part_count, const KEY_PART_INFO *key_parts, handler *file, bool is_primary_key)
 Add dd::Index_element objects to dd::Index/Table according to KEY_PART_INFO array for the index. More...
 
static bool dd::is_candidate_primary_key (THD *thd, const KEY *key, const List< Create_field > &create_fields)
 
static void dd::fill_dd_indexes_from_keyinfo (THD *thd, dd::Table *tab_obj, uint key_count, const KEY *keyinfo, const List< Create_field > &create_fields, handler *file)
 Add index objects to dd::Table according to array of KEY structures. More...
 
static dd::Foreign_key::enum_rule dd::get_fk_rule (fk_option opt)
 Translate from the old fk_option enum to the new dd::Foreign_key::enum_rule enum. More...
 
static bool dd::fill_dd_foreign_keys_from_create_fields (dd::Table *tab_obj, uint key_count, const FOREIGN_KEY *keyinfo)
 Add foreign keys to dd::Table according to Foreign_key_spec structs. More...
 
template<typename T >
static bool dd::fill_dd_tablespace_id_or_name (THD *thd, T *obj, handlerton *hton, const char *tablespace_name, bool is_temporary_table)
 Set dd::Tablespace object id for dd::Table and dd::Partition object during CREATE TABLE. More...
 
static bool dd::get_field_list_str (dd::String_type &str, List< char > *name_list)
 Get a string of fields to be stores as partition_expression. More...
 
static void dd::set_partition_options (partition_element *part_elem, dd::Properties *part_options)
 Helper function to set partition options. More...
 
static bool dd::add_part_col_vals (partition_info *part_info, part_elem_value *list_value, uint list_index, dd::Partition *part_obj, const HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, String *part_desc_str)
 
static void dd::collect_partition_expr (const THD *thd, List< char > &field_list, String *str)
 
static bool dd::fill_dd_partition_from_create_info (THD *thd, dd::Table *tab_obj, const HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, partition_info *part_info)
 Fill in partitioning meta data form create_info to the table object. More...
 
bool dd::fill_dd_check_constraints (THD *thd, dd::Table *tab_obj, const Sql_check_constraint_spec_list *check_cons_spec)
 Fill in check constraints metadata to the Table object from the list of check constraint specifications. More...
 
static Table::enum_row_format dd::dd_get_new_row_format (row_type old_format)
 Convert old row type value to corresponding value in new row format enum used by DD framework. More...
 
static bool dd::engine_supports_provided_srs_id (THD *thd, const dd::Table &table, const handler *handler)
 Check if the storage engine supports geographic geometry columns. More...
 
bool dd::invalid_tablespace_usage (THD *thd, const dd::String_type &schema_name, const dd::String_type &table_name, const HA_CREATE_INFO *create_info)
 Checking if the table is being created in a restricted tablespace. More...
 
static bool dd::fill_dd_table_from_create_info (THD *thd, dd::Table *tab_obj, const dd::String_type &table_name, const dd::String_type &schema_name, const HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, Alter_info::enum_enable_or_disable keys_onoff, const FOREIGN_KEY *fk_keyinfo, uint fk_keys, const Sql_check_constraint_spec_list *check_cons_spec, handler *file)
 Fill dd::Table object from mysql_prepare_create_table() output. More...
 
static bool dd::get_se_private_data (THD *thd, dd::Table *tab_obj)
 Get the SE private data from the dd_properties table. More...
 
static std::unique_ptr< dd::Tabledd::create_dd_system_table (THD *thd, const dd::Schema &system_schema, const dd::String_type &table_name, HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, const FOREIGN_KEY *fk_keyinfo, uint fk_keys, const Sql_check_constraint_spec_list *check_cons_spec, handler *file, const dd::Object_table &dd_table)
 
bool dd::is_server_ps_table_name (const dd::String_type &schema_name, const dd::String_type &table_name)
 
std::unique_ptr< dd::Tabledd::create_dd_user_table (THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name, HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, Alter_info::enum_enable_or_disable keys_onoff, const FOREIGN_KEY *fk_keyinfo, uint fk_keys, const Sql_check_constraint_spec_list *check_cons_spec, handler *file)
 Prepares a dd::Table object from mysql_prepare_create_table() output and return it to the caller. More...
 
std::unique_ptr< dd::Tabledd::create_table (THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name, HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, Alter_info::enum_enable_or_disable keys_onoff, const FOREIGN_KEY *fk_keyinfo, uint fk_keys, const Sql_check_constraint_spec_list *check_cons_spec, handler *file)
 Prepares a dd::Table object from mysql_prepare_create_table() output and return it to the caller. More...
 
std::unique_ptr< dd::Tabledd::create_tmp_table (THD *thd, const dd::Schema &sch_obj, const dd::String_type &table_name, HA_CREATE_INFO *create_info, const List< Create_field > &create_fields, const KEY *keyinfo, uint keys, Alter_info::enum_enable_or_disable keys_onoff, const Sql_check_constraint_spec_list *check_cons_spec, handler *file)
 Prepares a dd::Table object for a temporary table from mysql_prepare_create_table() output. More...
 
bool dd::drop_table (THD *thd, const char *schema_name, const char *name, const dd::Table &table_def)
 
bool dd::table_exists (dd::cache::Dictionary_client *client, const char *schema_name, const char *name, bool *exists)
 Check if a table or view exists. More...
 
bool dd::is_generated_foreign_key_name (const char *table_name, size_t table_name_length, handlerton *hton, const dd::Foreign_key &fk)
 Check if foreign key name is generated one. More...
 
static bool dd::is_foreign_key_name_locked (THD *thd, const char *db, const char *fk_name)
 
bool dd::rename_foreign_keys (THD *thd, const char *old_db, const char *old_table_name, handlerton *hton, const char *new_db, dd::Table *new_tab)
 Rename foreign keys which have generated names to match the new name of the table. More...
 
bool dd::table_legacy_db_type (THD *thd, const char *schema_name, const char *table_name, enum legacy_db_type *db_type)
 Get the legacy db type from the options of the given table. More...
 
template<typename T >
bool dd::table_storage_engine (THD *thd, const T *obj, handlerton **hton)
 Get the storage engine handlerton for the given table or tablespace. More...
 
template bool dd::table_storage_engine< dd::Table > (THD *, const dd::Table *, handlerton **)
 
template bool dd::table_storage_engine< dd::Tablespace > (THD *, const dd::Tablespace *, handlerton **)
 
bool dd::recreate_table (THD *thd, const char *schema_name, const char *table_name)
 Regenerate a metadata locked table. More...
 
dd::String_type dd::get_sql_type_by_field_info (THD *thd, enum_field_types field_type, uint32 field_length, uint32 decimals, bool maybe_null, bool is_unsigned, const CHARSET_INFO *field_charset)
 Function returns string representing column type by ST_FIELD_INFO. More...
 
bool dd::fix_row_type (THD *thd, dd::Table *table, row_type correct_row_type)
 Update row format for the table with the value value supplied by caller function. More...
 
void dd::report_error_as_tablespace_missing (Object_id id)
 
void dd::report_error_as_tablespace_missing (const String_type name)
 
template<typename KEY >
bool dd::is_general_tablespace_and_encrypted (const KEY k, THD *thd, bool *is_encrypted_tablespace, bool *is_general_tablespace)
 
Encrypt_result dd::is_tablespace_encrypted (THD *thd, const Table &t, bool *is_general_tablespace)
 Predicate to determine if a table resides in an encrypted tablespace. More...
 
bool dd::has_primary_key (const Table &t)
 Predicate which indicates if the table has real (non-hidden) primary key. More...
 
bool dd::is_generated_check_constraint_name (const char *table_name, size_t table_name_length, const char *cc_name, size_t cc_name_length)
 Check if name of check constraint is generated one. More...
 
bool dd::rename_check_constraints (const char *old_table_name, dd::Table *new_tab)
 Rename generated check constraint names to match the new name of the table. More...
 
template<typename IT >
static void dd::copy_tablespace_names (const HA_CREATE_INFO *ci, partition_info *pi, IT it)
 
Encrypt_result dd::is_tablespace_encrypted (THD *thd, const HA_CREATE_INFO *ci, bool *is_general_tablespace)
 Predicate to determine if a table resides in an encrypted tablespace and if it a general tablespace. More...
 
bool dd::uses_general_tablespace (const Table &t)
 Check if table uses general tablespace. More...
 
void dd::warn_on_deprecated_prefix_key_partition (THD *thd, const char *schema_name, const char *orig_table_name, const Table *table, const bool is_upgrade)
 Throw deprecation warnings if table uses prefix keys in the partitioning function. More...
 
bool dd::get_implicit_tablespace_options (THD *thd, const Table *table, ulonglong *autoextend_size)
 Get the autoextend_size option value for implicit tablespaces. More...