24#ifndef SQL_ALTER_TABLE_H
25#define SQL_ALTER_TABLE_H
73 assert(par_name !=
nullptr);
152 assert(
name !=
nullptr);
192 bool par_is_enforced)
194 assert(par_name !=
nullptr);
493 const char *
decimal, uint type_modifier,
Item *default_value,
499 std::optional<gis::srid_t> srid,
514 const char *new_db_arg,
const char *new_name_arg);
619 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
630 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
644 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Class representing SET DEFAULT, DROP DEFAULT, RENAME COLUMN, SET VISIBLE and SET INVISIBLE clause in ...
Definition: sql_alter.h:82
Alter_column(const char *old_name, const char *new_name)
Constructor used while renaming field name.
Definition: sql_alter.h:130
const char * m_new_name
The new column name.
Definition: sql_alter.h:94
Alter_column(const char *par_name, bool par_is_visible)
Constructor used while altering column visibility.
Definition: sql_alter.h:137
Value_generator * m_default_val_expr
The expression to be used to generate the default value.
Definition: sql_alter.h:91
Item * def
The default value supplied.
Definition: sql_alter.h:88
Alter_column(const char *par_name, Value_generator *gen_def)
Constructor used when setting a field's DEFAULT value to an expression.
Definition: sql_alter.h:122
Type
Definition: sql_alter.h:96
const char * name
The column name being altered.
Definition: sql_alter.h:85
Type change_type() const
Type of change requested in ALTER TABLE.
Definition: sql_alter.h:106
Alter_column(const char *par_name, Item *literal)
Constructor used when altering the field's default value with a literal constant or when dropping a f...
Definition: sql_alter.h:110
Type m_type
Definition: sql_alter.h:144
Class representing ALTER CHECK and ALTER CONSTRAINT clauses in ALTER TABLE statement.
Definition: sql_alter.h:184
const char * name
Definition: sql_alter.h:187
Type type
Definition: sql_alter.h:188
Type
Definition: sql_alter.h:186
Alter_constraint_enforcement(Type par_type, const char *par_name, bool par_is_enforced)
Definition: sql_alter.h:191
bool is_enforced
Definition: sql_alter.h:189
Class representing DROP COLUMN, DROP KEY, DROP FOREIGN KEY, DROP CHECK CONSTRAINT and DROP CONSTRAINT...
Definition: sql_alter.h:65
drop_type type
Definition: sql_alter.h:69
const char * name
Definition: sql_alter.h:68
Alter_drop(drop_type par_type, const char *par_name)
Definition: sql_alter.h:71
drop_type
Definition: sql_alter.h:67
@ FOREIGN_KEY
Definition: sql_alter.h:67
@ ANY_CONSTRAINT
Definition: sql_alter.h:67
@ KEY
Definition: sql_alter.h:67
@ COLUMN
Definition: sql_alter.h:67
@ CHECK_CONSTRAINT
Definition: sql_alter.h:67
An ALTER INDEX operation that changes the visibility of an index.
Definition: sql_alter.h:148
const char * m_name
Definition: sql_alter.h:161
bool is_visible() const
The visibility after the operation is performed.
Definition: sql_alter.h:158
Alter_index_visibility(const char *name, bool is_visible)
Definition: sql_alter.h:150
const char * name() const
Definition: sql_alter.h:155
bool m_is_visible
Definition: sql_alter.h:162
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:205
enum_alter_table_algorithm
The different values of the ALGORITHM clause.
Definition: sql_alter.h:355
@ ALTER_TABLE_ALGORITHM_DEFAULT
Definition: sql_alter.h:357
@ ALTER_TABLE_ALGORITHM_INPLACE
Definition: sql_alter.h:360
@ ALTER_TABLE_ALGORITHM_COPY
Definition: sql_alter.h:366
@ ALTER_TABLE_ALGORITHM_INSTANT
Definition: sql_alter.h:363
Sql_check_constraint_spec_list check_constraint_spec_list
Check constraints specification for CREATE and ALTER TABLE operations.
Definition: sql_alter.h:422
Alter_info & operator=(const Alter_info &rhs)
enum_alter_table_lock
The different values of the LOCK clause.
Definition: sql_alter.h:373
@ ALTER_TABLE_LOCK_DEFAULT
Definition: sql_alter.h:375
@ ALTER_TABLE_LOCK_EXCLUSIVE
Definition: sql_alter.h:384
@ ALTER_TABLE_LOCK_NONE
Definition: sql_alter.h:378
@ ALTER_TABLE_LOCK_SHARED
Definition: sql_alter.h:381
Alter_info(const Alter_info &rhs)
Mem_root_array< Key_spec * > key_list
Definition: sql_alter.h:410
Mem_root_array< const Alter_drop * > drop_list
Columns, keys and constraints to be dropped.
Definition: sql_alter.h:405
enum_alter_table_algorithm requested_algorithm
Definition: sql_alter.h:437
Mem_root_array< const Alter_constraint_enforcement * > alter_constraint_enforcement_list
List of check constraints whose enforcement state is changed.
Definition: sql_alter.h:419
enum_with_validation with_validation
Definition: sql_alter.h:444
List< String > partition_names
Definition: sql_alter.h:433
enum_with_validation
Status of validation clause in ALTER TABLE statement.
Definition: sql_alter.h:391
@ ALTER_VALIDATION_DEFAULT
Default value, used when it's not specified in the statement.
Definition: sql_alter.h:397
@ ALTER_WITHOUT_VALIDATION
Definition: sql_alter.h:399
@ ALTER_WITH_VALIDATION
Definition: sql_alter.h:398
enum_enable_or_disable
Definition: sql_alter.h:349
@ ENABLE
Definition: sql_alter.h:349
@ LEAVE_AS_IS
Definition: sql_alter.h:349
@ DISABLE
Definition: sql_alter.h:349
List< Create_field > create_list
Definition: sql_alter.h:425
Alter_info(MEM_ROOT *mem_root)
Definition: sql_alter.h:457
LEX_CSTRING new_table_name
New table name in the.
Definition: sql_alter.h:455
Mem_root_array< const Alter_column * > alter_list
Definition: sql_alter.h:407
LEX_CSTRING new_db_name
"new_db" (if any) or "db" (if any) or default database from ALTER TABLE [db.
Definition: sql_alter.h:448
enum_enable_or_disable keys_onoff
Definition: sql_alter.h:431
ulonglong flags
Definition: sql_alter.h:429
Mem_root_array< const Alter_rename_key * > alter_rename_key_list
Definition: sql_alter.h:412
std::vector< CreateFieldApplier > cf_appliers
Definition: sql_alter.h:426
uint num_parts
Definition: sql_alter.h:435
Alter_info_flag
Definition: sql_alter.h:216
@ ALTER_RENAME_INDEX
Set for RENAME INDEX.
Definition: sql_alter.h:301
@ ALTER_CHANGE_COLUMN_DEFAULT
Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT.
Definition: sql_alter.h:244
@ ALTER_TRUNCATE_PARTITION
Set by Sql_cmd_alter_table_truncate_partition::execute()
Definition: sql_alter.h:295
@ DROP_CHECK_CONSTRAINT
Set for drop check constraint.
Definition: sql_alter.h:322
@ ALTER_REBUILD_PARTITION
Set for REBUILD PARTITION.
Definition: sql_alter.h:277
@ ALTER_DROP_INDEX
Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX.
Definition: sql_alter.h:232
@ ENFORCE_ANY_CONSTRAINT
Set for ALTER CONSTRAINT symbol ENFORCED.
Definition: sql_alter.h:334
@ ALTER_DROP_PARTITION
Set for DROP PARTITION.
Definition: sql_alter.h:258
@ ALTER_KEYS_ONOFF
Set for DISABLE KEYS | ENABLE KEYS.
Definition: sql_alter.h:247
@ ALTER_ADD_COLUMN
Set for ADD [COLUMN].
Definition: sql_alter.h:218
@ ALTER_INDEX_VISIBILITY
Means that the visibility of an index is changed.
Definition: sql_alter.h:310
@ ALTER_ADMIN_PARTITION
Set for LOAD INDEX INTO CACHE ... PARTITION Set for CACHE INDEX ... PARTITION.
Definition: sql_alter.h:271
@ ALTER_PARTITION
Set for partition_options.
Definition: sql_alter.h:267
@ ALTER_COLUMN_VISIBILITY
Set for column visibility attribute alter.
Definition: sql_alter.h:346
@ ALTER_ADD_PARTITION
Set for ADD PARTITION.
Definition: sql_alter.h:255
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:319
@ ALTER_RENAME
Set for RENAME [TO].
Definition: sql_alter.h:235
@ SUSPEND_CHECK_CONSTRAINT
Set for check constraint suspend.
Definition: sql_alter.h:328
@ ALTER_REORGANIZE_PARTITION
Set for REORGANIZE PARTITION ... INTO.
Definition: sql_alter.h:264
@ ALTER_ADD_INDEX
Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY | ADD UNIQUE INDEX | ALTER ADD [COLUMN...
Definition: sql_alter.h:229
@ ALTER_COALESCE_PARTITION
Set for COALESCE PARTITION.
Definition: sql_alter.h:261
@ DROP_FOREIGN_KEY
Set for DROP FOREIGN KEY.
Definition: sql_alter.h:289
@ ALTER_ALL_PARTITION
Set for partitioning operations specifying ALL keyword.
Definition: sql_alter.h:280
@ ALTER_CHANGE_COLUMN
Set for CHANGE [COLUMN] | MODIFY [CHANGE] Set by mysql_recreate_table()
Definition: sql_alter.h:225
@ ALTER_SECONDARY_LOAD
Set for SECONDARY LOAD.
Definition: sql_alter.h:313
@ ALTER_DROP_COLUMN
Set for DROP [COLUMN].
Definition: sql_alter.h:221
@ ALTER_RECREATE
Set for FORCE Set for ENGINE(same engine) Set by mysql_recreate_table()
Definition: sql_alter.h:252
@ ALTER_EXCHANGE_PARTITION
Set for EXCHANGE PARTITION.
Definition: sql_alter.h:292
@ ALTER_IMPORT_TABLESPACE
Set for importing the tablespace.
Definition: sql_alter.h:307
@ ANY_ENGINE_ATTRIBUTE
Set if ANY engine attribute is used (also in CREATE) Note that this is NOT to be set for SECONDARY_EN...
Definition: sql_alter.h:343
@ ALTER_OPTIONS
Set for table_options.
Definition: sql_alter.h:241
@ ALTER_SECONDARY_UNLOAD
Set for SECONDARY UNLOAD.
Definition: sql_alter.h:316
@ ALTER_REMOVE_PARTITIONING
Set for REMOVE PARTITIONING.
Definition: sql_alter.h:283
@ DROP_ANY_CONSTRAINT
Set for DROP CONSTRAINT.
Definition: sql_alter.h:331
@ ENFORCE_CHECK_CONSTRAINT
Set for check constraint enforce.
Definition: sql_alter.h:325
@ ALTER_COLUMN_ORDER
Set for ADD [COLUMN] FIRST | AFTER.
Definition: sql_alter.h:298
@ SUSPEND_ANY_CONSTRAINT
Set for ALTER CONSTRAINT symbol NOT ENFORCED.
Definition: sql_alter.h:337
@ ALTER_DISCARD_TABLESPACE
Set for discarding the tablespace.
Definition: sql_alter.h:304
@ ADD_FOREIGN_KEY
Set for ADD FOREIGN KEY.
Definition: sql_alter.h:286
@ ALTER_ORDER
Set for ORDER BY.
Definition: sql_alter.h:238
@ ALTER_TABLE_REORG
Set for REORGANIZE PARTITION.
Definition: sql_alter.h:274
Mem_root_array< const Alter_index_visibility * > alter_index_visibility_list
Indexes whose visibilities are to be changed.
Definition: sql_alter.h:415
enum_alter_table_lock requested_lock
Definition: sql_alter.h:439
Class which instances represent RENAME INDEX clauses in ALTER TABLE statement.
Definition: sql_alter.h:170
Alter_rename_key(const char *old_name_arg, const char *new_name_arg)
Definition: sql_alter.h:175
const char * new_name
Definition: sql_alter.h:173
const char * old_name
Definition: sql_alter.h:172
Runtime context for ALTER TABLE.
Definition: sql_alter.h:509
bool tmp_table
Indicates that we are altering temporary table.
Definition: sql_alter.h:591
char path[FN_REFLEN+1]
Definition: sql_alter.h:585
bool is_database_changed() const
Definition: sql_alter.h:521
Alter_table_ctx(const Alter_table_ctx &rhs)
const char * table_name
Definition: sql_alter.h:558
uint error_if_not_empty_mask
Definition: sql_alter.h:550
bool is_table_renamed() const
Definition: sql_alter.h:532
const char * new_name
Definition: sql_alter.h:561
uint fk_count
Definition: sql_alter.h:567
static const error_if_not_empty_mask DATETIME_WITHOUT_DEFAULT
Definition: sql_alter.h:551
FOREIGN_KEY * fk_info
Definition: sql_alter.h:566
char tmp_path[FN_REFLEN+1]
Definition: sql_alter.h:587
char tmp_name[80]
Definition: sql_alter.h:563
MDL_request target_db_mdl_request
Metadata lock request on table's new database if it is changed.
Definition: sql_alter.h:580
Alter_table_ctx & operator=(const Alter_table_ctx &rhs)
static const error_if_not_empty_mask GEOMETRY_WITHOUT_DEFAULT
Definition: sql_alter.h:552
bool is_table_name_changed() const
Definition: sql_alter.h:526
Alter_table_ctx()
Definition: sql_alter.cc:98
const char * get_tmp_path() const
Definition: sql_alter.h:547
const char * new_db
Definition: sql_alter.h:560
MDL_request target_mdl_request
Metadata lock request on table's new name when this name or database are changed.
Definition: sql_alter.h:578
const char * db
Definition: sql_alter.h:557
error_if_not_empty_mask error_if_not_empty
Definition: sql_alter.h:555
const char * new_alias
Definition: sql_alter.h:562
char new_alias_buff[FN_REFLEN+1]
Definition: sql_alter.h:584
Create_field * datetime_field
Definition: sql_alter.h:554
const char * get_path() const
Definition: sql_alter.h:539
char new_filename[FN_REFLEN+1]
Definition: sql_alter.h:583
uint fk_max_generated_name_number
Maximum number component used by generated foreign key names in the old version of table.
Definition: sql_alter.h:572
uint tables_opened
Definition: sql_alter.h:556
const char * alias
Definition: sql_alter.h:559
char new_path[FN_REFLEN+1]
Definition: sql_alter.h:586
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:51
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: key_spec.h:208
Definition: sql_list.h:494
A pending metadata lock request.
Definition: mdl.h:803
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
Represents the generic ALTER TABLE statement.
Definition: sql_alter.h:617
bool reprepare_on_execute_required() const override
Some SQL commands currently require re-preparation on re-execution of a prepared statement or stored ...
Definition: sql_alter.cc:359
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:219
Represents the common properties of the ALTER TABLE statements.
Definition: sql_alter.h:602
~Sql_cmd_common_alter_table() override=0
enum_sql_command sql_command_code() const final
Return the command code for this statement.
Definition: sql_alter.h:608
A base class for CREATE/ALTER TABLE commands and friends.
Definition: sql_cmd_ddl_table.h:50
Sql_cmd_ddl_table(Alter_info *alter_info)
Definition: sql_cmd_ddl_table.cc:68
Represents ALTER TABLE IMPORT/DISCARD TABLESPACE statements.
Definition: sql_alter.h:628
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:371
bool mysql_discard_or_import_tablespace(THD *thd, Table_ref *table_list)
Definition: sql_table.cc:11477
Represents ALTER TABLE SECONDARY_LOAD/SECONDARY_UNLOAD statements.
Definition: sql_alter.h:641
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:425
bool mysql_secondary_load_or_unload(THD *thd, Table_ref *table_list)
Loads a table into a secondary engine if SECONDARY_LOAD, unloads from secondary engine if SECONDARY_U...
Definition: sql_table.cc:11716
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Used for storing information associated with generated column, default values generated from expressi...
Definition: field.h:485
enum_hidden_type
Definition: column.h:96
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
bool add_field(THD *thd, const LEX_STRING *field_name, enum enum_field_types type, const char *length, const char *decimal, uint type_modifier, Item *default_value, Item *on_update_value, LEX_CSTRING *comment, const char *change, List< String > *interval_list, const CHARSET_INFO *cs, bool has_explicit_collation, uint uint_geom_type, Value_generator *gcol_info, Value_generator *default_val_expr, const char *opt_after, std::optional< gis::srid_t > srid, Sql_check_constraint_spec_list *check_cons_list, dd::Column::enum_hidden_type hidden, bool is_array=false)
Store field definition for create.
Definition: sql_parse.cc:5459
#define comment
Definition: lexyy.cc:959
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Common #defines and includes for file and socket I/O.
#define FN_REFLEN
Definition: my_io.h:83
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_ALTER_TABLE
Definition: my_sqlcommand.h:50
Definition: commit_order_queue.h:34
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Performance schema instrumentation interface.
required string type
Definition: replication_group_member_actions.proto:34
std::function< bool(Create_field *, Alter_info *)> CreateFieldApplier
Definition: sql_alter.h:198
Representation of an SQL command.
Definition: m_ctype.h:421
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
Definition: mysql_lex_string.h:35
A structure to store a decimal value together with its precision and number of decimals TODO: HCS-100...
Definition: protocol_local_v2.h:43