MySQL 9.7.0
Source Code Documentation
sql_alter.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_ALTER_TABLE_H
25#define SQL_ALTER_TABLE_H
26
27#include <assert.h>
28#include <stddef.h>
29#include <sys/types.h>
30#include <functional> // std::function
31#include <optional>
32
33#include "lex_string.h"
34
35#include "field_types.h"
36#include "my_io.h"
37#include "my_sqlcommand.h"
39#include "sql/dd/types/column.h"
40#include "sql/gis/srid.h"
41#include "sql/mdl.h" // MDL_request
42#include "sql/mem_root_array.h" // Mem_root_array
43#include "sql/sql_check_constraint.h" // Sql_check_constraint_spec_list
44#include "sql/sql_cmd.h" // Sql_cmd
45#include "sql/sql_cmd_ddl_table.h" // Sql_cmd_ddl_table
46#include "sql/sql_list.h" // List
47#include "sql/thr_malloc.h"
48
49class Alter_info;
50class Create_field;
51class FOREIGN_KEY;
52class Value_generator;
53class Item;
54class Key_spec;
55class String;
56class THD;
57struct CHARSET_INFO;
58class Table_ref;
59
60/**
61 Class representing DROP COLUMN, DROP KEY, DROP FOREIGN KEY, DROP CHECK
62 CONSTRAINT and DROP CONSTRAINT clauses in ALTER TABLE statement.
63*/
64
66 public:
68 const char *name;
70
71 Alter_drop(drop_type par_type, const char *par_name)
72 : name(par_name), type(par_type) {
73 assert(par_name != nullptr);
74 }
75};
76
77/**
78 Class representing SET DEFAULT, DROP DEFAULT, RENAME COLUMN, SET VISIBLE and
79 SET INVISIBLE clause in ALTER TABLE statement.
80*/
81
83 public:
84 /// The column name being altered.
85 const char *name;
86
87 /// The default value supplied.
88 Item *def{nullptr};
89
90 /// The expression to be used to generate the default value.
92
93 /// The new column name.
94 const char *m_new_name{nullptr};
95
96 /// The new masking policy name.
99 }
100
101 enum class Type {
109 };
110
111 /// Type of change requested in ALTER TABLE.
112 Type change_type() const { return m_type; }
113
114 /// Constructor used when altering the field's default value with a literal
115 /// constant or when dropping a field's default value.
116 Alter_column(const char *par_name, Item *literal)
117 : name{par_name}, def{literal} {
118 if (def != nullptr)
120 else
122 }
123
124 /// Constructor for assigning or unassigning a column's MASKING POLICY.
125 Alter_column(const char *col_name, LEX_CSTRING policy_name)
126 : name{col_name},
127 m_type{policy_name.str != nullptr ? Type::SET_MASKING_POLICY
128 : Type::DROP_MASKING_POLICY},
129 m_new_masking_policy_name{policy_name} {}
130
131 /// Constructor used when setting a field's DEFAULT value to an expression.
132 Alter_column(const char *par_name, Value_generator *gen_def)
133 : name(par_name),
134 m_default_val_expr(gen_def),
135 m_type(Type::SET_DEFAULT) {}
136
137 /// Constructor used while renaming field name.
138 Alter_column(const char *old_name, const char *new_name)
139 : name(old_name), m_new_name(new_name), m_type(Type::RENAME_COLUMN) {}
140
141 /// Constructor used while altering column visibility.
142 Alter_column(const char *par_name, bool par_is_visible) : name(par_name) {
143 m_type = (par_is_visible ? Type::SET_COLUMN_VISIBLE
145 }
146
147 private:
150};
151
152/// An ALTER INDEX operation that changes the visibility of an index.
154 public:
157 assert(name != nullptr);
158 }
159
160 const char *name() const { return m_name; }
161
162 /// The visibility after the operation is performed.
163 bool is_visible() const { return m_is_visible; }
164
165 private:
166 const char *m_name;
168};
169
170/**
171 Class which instances represent RENAME INDEX clauses in
172 ALTER TABLE statement.
173*/
174
176 public:
177 const char *old_name;
178 const char *new_name;
179
180 Alter_rename_key(const char *old_name_arg, const char *new_name_arg)
181 : old_name(old_name_arg), new_name(new_name_arg) {}
182};
183
184/**
185 Class representing ALTER CHECK and ALTER CONSTRAINT clauses in ALTER TABLE
186 statement.
187*/
188
190 public:
192 const char *name;
195
196 Alter_constraint_enforcement(Type par_type, const char *par_name,
197 bool par_is_enforced)
198 : name(par_name), type(par_type), is_enforced(par_is_enforced) {
199 assert(par_name != nullptr);
200 }
201};
202
203using CreateFieldApplier = std::function<bool(Create_field *, Alter_info *)>;
204
205/**
206 Data describing the table being created by CREATE TABLE or
207 altered by ALTER TABLE.
208*/
209
211 public:
212 /*
213 These flags are set by the parser and describes the type of
214 operation(s) specified by the ALTER TABLE statement.
215
216 They do *not* describe the type operation(s) to be executed
217 by the storage engine. For example, we don't yet know the
218 type of index to be added/dropped.
219 */
220
222 /// Set for ADD [COLUMN]
223 ALTER_ADD_COLUMN = 1ULL << 0,
224
225 /// Set for DROP [COLUMN]
226 ALTER_DROP_COLUMN = 1ULL << 1,
227
228 /// Set for CHANGE [COLUMN] | MODIFY [CHANGE]
229 /// Set by mysql_recreate_table()
231
232 /// Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY |
233 /// ADD UNIQUE INDEX | ALTER ADD [COLUMN]
234 ALTER_ADD_INDEX = 1ULL << 3,
235
236 /// Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX
237 ALTER_DROP_INDEX = 1ULL << 4,
238
239 /// Set for RENAME [TO]
240 ALTER_RENAME = 1ULL << 5,
241
242 /// Set for ORDER BY
243 ALTER_ORDER = 1ULL << 6,
244
245 /// Set for table_options
246 ALTER_OPTIONS = 1ULL << 7,
247
248 /// Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT
250
251 /// Set for DISABLE KEYS | ENABLE KEYS
252 ALTER_KEYS_ONOFF = 1ULL << 9,
253
254 /// Set for FORCE
255 /// Set for ENGINE(same engine)
256 /// Set by mysql_recreate_table()
257 ALTER_RECREATE = 1ULL << 10,
258
259 /// Set for ADD PARTITION
261
262 /// Set for DROP PARTITION
264
265 /// Set for COALESCE PARTITION
267
268 /// Set for REORGANIZE PARTITION ... INTO
270
271 /// Set for partition_options
272 ALTER_PARTITION = 1ULL << 15,
273
274 /// Set for LOAD INDEX INTO CACHE ... PARTITION
275 /// Set for CACHE INDEX ... PARTITION
277
278 /// Set for REORGANIZE PARTITION
279 ALTER_TABLE_REORG = 1ULL << 17,
280
281 /// Set for REBUILD PARTITION
283
284 /// Set for partitioning operations specifying ALL keyword
286
287 /// Set for REMOVE PARTITIONING
289
290 /// Set for ADD FOREIGN KEY
291 ADD_FOREIGN_KEY = 1ULL << 21,
292
293 /// Set for DROP FOREIGN KEY
294 DROP_FOREIGN_KEY = 1ULL << 22,
295
296 /// Set for EXCHANGE PARTITION
298
299 /// Set by Sql_cmd_alter_table_truncate_partition::execute()
301
302 /// Set for ADD [COLUMN] FIRST | AFTER
303 ALTER_COLUMN_ORDER = 1ULL << 25,
304
305 /// Set for RENAME INDEX
306 ALTER_RENAME_INDEX = 1ULL << 26,
307
308 /// Set for discarding the tablespace
310
311 /// Set for importing the tablespace
313
314 /// Means that the visibility of an index is changed.
316
317 /// Set for SECONDARY LOAD
319
320 /// Set for SECONDARY UNLOAD
322
323 /// Set for add check constraint.
325
326 /// Set for drop check constraint.
328
329 /// Set for check constraint enforce.
331
332 /// Set for check constraint suspend.
334
335 /// Set for DROP CONSTRAINT.
337
338 /// Set for ALTER CONSTRAINT symbol ENFORCED.
340
341 /// Set for ALTER CONSTRAINT symbol NOT ENFORCED.
343
344 /// Set if ANY engine attribute is used (also in CREATE) Note that
345 /// this is NOT to be set for SECONDARY_ENGINE_ATTRIBUTE as this flag
346 /// controls if execution should check if SE supports engine
347 /// attributes.
349
350 /// Set for column visibility attribute alter.
352
353 /// Set for ALTER [COLUMN] ... SET MASKING POLICY | DROP MASKING POLICY.
355
356 /// Must be last, not a real type.
357 ALTER_TYPE_END = 1ULL << 42
358 };
359
361
362 /**
363 The different values of the ALGORITHM clause.
364 Describes which algorithm to use when altering the table.
365 */
367 // In-place if supported, copy otherwise.
369
370 // In-place if supported, error otherwise.
372
373 // Instant if supported, error otherwise.
375
376 // Copy if supported, error otherwise.
378 };
379
380 /**
381 The different values of the LOCK clause.
382 Describes the level of concurrency during ALTER TABLE.
383 */
385 // Maximum supported level of concurrency for the given operation.
387
388 // Allow concurrent reads & writes. If not supported, give error.
390
391 // Allow concurrent reads only. If not supported, give error.
393
394 // Block reads and writes.
396 };
397
398 /**
399 Status of validation clause in ALTER TABLE statement. Used during
400 partitions and GC alterations.
401 */
403 /**
404 Default value, used when it's not specified in the statement.
405 Means WITH VALIDATION for partitions alterations and WITHOUT VALIDATION
406 for altering virtual GC.
407 */
411 };
412
413 /**
414 Columns, keys and constraints to be dropped.
415 */
417 // Columns for ALTER_COLUMN_CHANGE_DEFAULT.
419 // List of keys, used by both CREATE and ALTER TABLE.
420
422 // Keys to be renamed.
424
425 /// Indexes whose visibilities are to be changed.
427
428 /// List of check constraints whose enforcement state is changed.
431
432 /// Check constraints specification for CREATE and ALTER TABLE operations.
434
435 // List of columns, used by both CREATE and ALTER TABLE.
437 std::vector<CreateFieldApplier> cf_appliers;
438
439 // Type of ALTER TABLE operation.
441 // Enable or disable keys.
443 // List of partitions.
445 // Number of partitions.
447 // Type of ALTER TABLE algorithm.
449 // Type of ALTER TABLE lock.
451 /*
452 Whether VALIDATION is asked for an operation. Used during virtual GC and
453 partitions alterations.
454 */
456
457 /// Whether SECONDARY_LOAD should do guided load.
459
460 /// SECONDARY_LOAD should only validate not load table.
462 /// Number of rows to be validated by SECONDARY_LOAD
464
465 /// "new_db" (if any) or "db" (if any) or default database from
466 /// ALTER TABLE [db.]table [ RENAME [TO|AS|=] [new_db.]new_table ]
468
469 /// New table name in the
470 /// \code
471 /// RENAME [TO] <table_name>
472 /// \endcode
473 /// clause or NULL_STR
475
484 flags(0),
486 num_parts(0),
491 validation_only(false),
495
496 /**
497 Construct a copy of this object to be used for mysql_alter_table
498 and mysql_create_table.
499
500 Historically, these two functions modify their Alter_info
501 arguments. This behaviour breaks re-execution of prepared
502 statements and stored procedures and is compensated by always
503 supplying a copy of Alter_info to these functions.
504
505 @param rhs Alter_info to make copy of
506 @param mem_root Mem_root for new Alter_info
507
508 @note You need to use check the error in THD for out
509 of memory condition after calling this function.
510 */
512
513 bool add_field(THD *thd, const LEX_STRING *field_name,
514 enum enum_field_types type, const char *length,
515 const char *decimal, uint type_modifier, Item *default_value,
516 Item *on_update_value, LEX_CSTRING *comment,
517 const char *change, List<String> *interval_list,
518 const CHARSET_INFO *cs, bool has_explicit_collation,
519 uint uint_geom_type, Value_generator *gcol_info,
520 Value_generator *default_val_expr, LEX_CSTRING masking_policy,
521 const char *opt_after, std::optional<gis::srid_t> srid,
522 Sql_check_constraint_spec_list *check_cons_list,
523 dd::Column::enum_hidden_type hidden, bool is_array = false);
524
525 private:
526 Alter_info &operator=(const Alter_info &rhs); // not implemented
527 Alter_info(const Alter_info &rhs); // not implemented
528};
529
530/** Runtime context for ALTER TABLE. */
532 public:
534
535 Alter_table_ctx(THD *thd, Table_ref *table_list, uint tables_opened_arg,
536 const char *new_db_arg, const char *new_name_arg);
537
539
540 /**
541 @return true if the table is moved to another database, false otherwise.
542 */
543 bool is_database_changed() const { return (new_db != db); }
544
545 /**
546 @return true if the table name is changed, false otherwise.
547 */
548 bool is_table_name_changed() const { return (new_name != table_name); }
549
550 /**
551 @return true if the table is renamed (i.e. its name or database changed),
552 false otherwise.
553 */
554 bool is_table_renamed() const {
556 }
557
558 /**
559 @return path to the original table.
560 */
561 const char *get_path() const {
562 assert(!tmp_table);
563 return path;
564 }
565
566 /**
567 @return path to the temporary table created during ALTER TABLE.
568 */
569 const char *get_tmp_path() const { return tmp_path; }
570
571 public:
575
579 const char *db;
580 const char *table_name;
581 const char *alias;
582 const char *new_db;
583 const char *new_name;
584 const char *new_alias;
585 char tmp_name[80];
586
587 /* Used to remember which foreign keys already existed in the table. */
590 /**
591 Maximum number component used by generated foreign key names in the
592 old version of table.
593 */
595
596 /**
597 Metadata lock request on table's new name when this name or database
598 are changed.
599 */
601 /** Metadata lock request on table's new database if it is changed. */
603
604 private:
607 char path[FN_REFLEN + 1];
610
611#ifndef NDEBUG
612 /** Indicates that we are altering temporary table. Used only in asserts. */
614#endif
615
616 Alter_table_ctx &operator=(const Alter_table_ctx &rhs); // not implemented
617 Alter_table_ctx(const Alter_table_ctx &rhs); // not implemented
618};
619
620/**
621 Represents the common properties of the ALTER TABLE statements.
622 @todo move Alter_info and other ALTER generic structures from Lex here.
623*/
625 public:
627
628 ~Sql_cmd_common_alter_table() override = 0; // force abstract class
629
631};
632
634
635/**
636 Represents the generic ALTER TABLE statement.
637 @todo move Alter_info and other ALTER specific structures from Lex here.
638*/
640 public:
641 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
642
643 bool execute(THD *thd) override;
644 bool reprepare_on_execute_required() const override;
645};
646
647/**
648 Represents ALTER TABLE IMPORT/DISCARD TABLESPACE statements.
649*/
651 public:
652 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
653
654 bool execute(THD *thd) override;
655
656 private:
657 bool mysql_discard_or_import_tablespace(THD *thd, Table_ref *table_list);
658};
659
660/**
661 Represents ALTER TABLE SECONDARY_LOAD/SECONDARY_UNLOAD statements.
662*/
664 public:
665 // Inherit the constructors from the parent class.
666 using Sql_cmd_common_alter_table::Sql_cmd_common_alter_table;
667
668 bool execute(THD *thd) override;
669
670 private:
671 bool mysql_secondary_load_or_unload(THD *thd, Table_ref *table_list);
672};
673
674#endif
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
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:138
const char * m_new_name
The new column name.
Definition: sql_alter.h:94
Alter_column(const char *col_name, LEX_CSTRING policy_name)
Constructor for assigning or unassigning a column's MASKING POLICY.
Definition: sql_alter.h:125
Alter_column(const char *par_name, bool par_is_visible)
Constructor used while altering column visibility.
Definition: sql_alter.h:142
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
LEX_CSTRING m_new_masking_policy_name
Definition: sql_alter.h:149
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:132
Type
Definition: sql_alter.h:101
LEX_CSTRING new_masking_policy_name() const
The new masking policy name.
Definition: sql_alter.h:97
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:112
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:116
Type m_type
Definition: sql_alter.h:148
Class representing ALTER CHECK and ALTER CONSTRAINT clauses in ALTER TABLE statement.
Definition: sql_alter.h:189
const char * name
Definition: sql_alter.h:192
Type type
Definition: sql_alter.h:193
Type
Definition: sql_alter.h:191
Alter_constraint_enforcement(Type par_type, const char *par_name, bool par_is_enforced)
Definition: sql_alter.h:196
bool is_enforced
Definition: sql_alter.h:194
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:153
const char * m_name
Definition: sql_alter.h:166
bool is_visible() const
The visibility after the operation is performed.
Definition: sql_alter.h:163
Alter_index_visibility(const char *name, bool is_visible)
Definition: sql_alter.h:155
const char * name() const
Definition: sql_alter.h:160
bool m_is_visible
Definition: sql_alter.h:167
Data describing the table being created by CREATE TABLE or altered by ALTER TABLE.
Definition: sql_alter.h:210
enum_alter_table_algorithm
The different values of the ALGORITHM clause.
Definition: sql_alter.h:366
@ ALTER_TABLE_ALGORITHM_DEFAULT
Definition: sql_alter.h:368
@ ALTER_TABLE_ALGORITHM_INPLACE
Definition: sql_alter.h:371
@ ALTER_TABLE_ALGORITHM_COPY
Definition: sql_alter.h:377
@ ALTER_TABLE_ALGORITHM_INSTANT
Definition: sql_alter.h:374
Sql_check_constraint_spec_list check_constraint_spec_list
Check constraints specification for CREATE and ALTER TABLE operations.
Definition: sql_alter.h:433
Alter_info & operator=(const Alter_info &rhs)
enum_alter_table_lock
The different values of the LOCK clause.
Definition: sql_alter.h:384
@ ALTER_TABLE_LOCK_DEFAULT
Definition: sql_alter.h:386
@ ALTER_TABLE_LOCK_EXCLUSIVE
Definition: sql_alter.h:395
@ ALTER_TABLE_LOCK_NONE
Definition: sql_alter.h:389
@ ALTER_TABLE_LOCK_SHARED
Definition: sql_alter.h:392
Alter_info(const Alter_info &rhs)
Mem_root_array< Key_spec * > key_list
Definition: sql_alter.h:421
Mem_root_array< const Alter_drop * > drop_list
Columns, keys and constraints to be dropped.
Definition: sql_alter.h:416
enum_alter_table_algorithm requested_algorithm
Definition: sql_alter.h:448
Mem_root_array< const Alter_constraint_enforcement * > alter_constraint_enforcement_list
List of check constraints whose enforcement state is changed.
Definition: sql_alter.h:430
enum_with_validation with_validation
Definition: sql_alter.h:455
List< String > partition_names
Definition: sql_alter.h:444
enum_with_validation
Status of validation clause in ALTER TABLE statement.
Definition: sql_alter.h:402
@ ALTER_VALIDATION_DEFAULT
Default value, used when it's not specified in the statement.
Definition: sql_alter.h:408
@ ALTER_WITHOUT_VALIDATION
Definition: sql_alter.h:410
@ ALTER_WITH_VALIDATION
Definition: sql_alter.h:409
enum_with_validation guided_load
Whether SECONDARY_LOAD should do guided load.
Definition: sql_alter.h:458
enum_enable_or_disable
Definition: sql_alter.h:360
@ ENABLE
Definition: sql_alter.h:360
@ LEAVE_AS_IS
Definition: sql_alter.h:360
@ DISABLE
Definition: sql_alter.h:360
List< Create_field > create_list
Definition: sql_alter.h:436
Alter_info(MEM_ROOT *mem_root)
Definition: sql_alter.h:476
LEX_CSTRING new_table_name
New table name in the.
Definition: sql_alter.h:474
Mem_root_array< const Alter_column * > alter_list
Definition: sql_alter.h:418
LEX_CSTRING new_db_name
"new_db" (if any) or "db" (if any) or default database from ALTER TABLE [db.
Definition: sql_alter.h:467
enum_enable_or_disable keys_onoff
Definition: sql_alter.h:442
ulonglong flags
Definition: sql_alter.h:440
Mem_root_array< const Alter_rename_key * > alter_rename_key_list
Definition: sql_alter.h:423
bool validation_only
SECONDARY_LOAD should only validate not load table.
Definition: sql_alter.h:461
std::vector< CreateFieldApplier > cf_appliers
Definition: sql_alter.h:437
uint num_parts
Definition: sql_alter.h:446
Alter_info_flag
Definition: sql_alter.h:221
@ ALTER_RENAME_INDEX
Set for RENAME INDEX.
Definition: sql_alter.h:306
@ ALTER_CHANGE_COLUMN_DEFAULT
Set for ALTER [COLUMN] ... SET DEFAULT ... | DROP DEFAULT.
Definition: sql_alter.h:249
@ ALTER_TRUNCATE_PARTITION
Set by Sql_cmd_alter_table_truncate_partition::execute()
Definition: sql_alter.h:300
@ DROP_CHECK_CONSTRAINT
Set for drop check constraint.
Definition: sql_alter.h:327
@ ALTER_REBUILD_PARTITION
Set for REBUILD PARTITION.
Definition: sql_alter.h:282
@ ALTER_DROP_INDEX
Set for DROP PRIMARY KEY | DROP FOREIGN KEY | DROP KEY | DROP INDEX.
Definition: sql_alter.h:237
@ ENFORCE_ANY_CONSTRAINT
Set for ALTER CONSTRAINT symbol ENFORCED.
Definition: sql_alter.h:339
@ ALTER_DROP_PARTITION
Set for DROP PARTITION.
Definition: sql_alter.h:263
@ ALTER_KEYS_ONOFF
Set for DISABLE KEYS | ENABLE KEYS.
Definition: sql_alter.h:252
@ ALTER_ADD_COLUMN
Set for ADD [COLUMN].
Definition: sql_alter.h:223
@ ALTER_INDEX_VISIBILITY
Means that the visibility of an index is changed.
Definition: sql_alter.h:315
@ ALTER_ADMIN_PARTITION
Set for LOAD INDEX INTO CACHE ... PARTITION Set for CACHE INDEX ... PARTITION.
Definition: sql_alter.h:276
@ ALTER_PARTITION
Set for partition_options.
Definition: sql_alter.h:272
@ ALTER_COLUMN_VISIBILITY
Set for column visibility attribute alter.
Definition: sql_alter.h:351
@ ALTER_ADD_PARTITION
Set for ADD PARTITION.
Definition: sql_alter.h:260
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:324
@ ALTER_RENAME
Set for RENAME [TO].
Definition: sql_alter.h:240
@ SUSPEND_CHECK_CONSTRAINT
Set for check constraint suspend.
Definition: sql_alter.h:333
@ ALTER_REORGANIZE_PARTITION
Set for REORGANIZE PARTITION ... INTO.
Definition: sql_alter.h:269
@ ALTER_TYPE_END
Must be last, not a real type.
Definition: sql_alter.h:357
@ 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:234
@ ALTER_COALESCE_PARTITION
Set for COALESCE PARTITION.
Definition: sql_alter.h:266
@ DROP_FOREIGN_KEY
Set for DROP FOREIGN KEY.
Definition: sql_alter.h:294
@ ALTER_ALL_PARTITION
Set for partitioning operations specifying ALL keyword.
Definition: sql_alter.h:285
@ ALTER_CHANGE_COLUMN
Set for CHANGE [COLUMN] | MODIFY [CHANGE] Set by mysql_recreate_table()
Definition: sql_alter.h:230
@ ALTER_SECONDARY_LOAD
Set for SECONDARY LOAD.
Definition: sql_alter.h:318
@ ALTER_DROP_COLUMN
Set for DROP [COLUMN].
Definition: sql_alter.h:226
@ ALTER_RECREATE
Set for FORCE Set for ENGINE(same engine) Set by mysql_recreate_table()
Definition: sql_alter.h:257
@ ALTER_EXCHANGE_PARTITION
Set for EXCHANGE PARTITION.
Definition: sql_alter.h:297
@ ALTER_IMPORT_TABLESPACE
Set for importing the tablespace.
Definition: sql_alter.h:312
@ 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:348
@ ALTER_OPTIONS
Set for table_options.
Definition: sql_alter.h:246
@ ALTER_SECONDARY_UNLOAD
Set for SECONDARY UNLOAD.
Definition: sql_alter.h:321
@ ALTER_REMOVE_PARTITIONING
Set for REMOVE PARTITIONING.
Definition: sql_alter.h:288
@ ALTER_COLUMN_MASKING
Set for ALTER [COLUMN] ... SET MASKING POLICY | DROP MASKING POLICY.
Definition: sql_alter.h:354
@ DROP_ANY_CONSTRAINT
Set for DROP CONSTRAINT.
Definition: sql_alter.h:336
@ ENFORCE_CHECK_CONSTRAINT
Set for check constraint enforce.
Definition: sql_alter.h:330
@ ALTER_COLUMN_ORDER
Set for ADD [COLUMN] FIRST | AFTER.
Definition: sql_alter.h:303
@ SUSPEND_ANY_CONSTRAINT
Set for ALTER CONSTRAINT symbol NOT ENFORCED.
Definition: sql_alter.h:342
@ ALTER_DISCARD_TABLESPACE
Set for discarding the tablespace.
Definition: sql_alter.h:309
@ ADD_FOREIGN_KEY
Set for ADD FOREIGN KEY.
Definition: sql_alter.h:291
@ ALTER_ORDER
Set for ORDER BY.
Definition: sql_alter.h:243
@ ALTER_TABLE_REORG
Set for REORGANIZE PARTITION.
Definition: sql_alter.h:279
Mem_root_array< const Alter_index_visibility * > alter_index_visibility_list
Indexes whose visibilities are to be changed.
Definition: sql_alter.h:426
uint64_t validate_num_rows
Number of rows to be validated by SECONDARY_LOAD.
Definition: sql_alter.h:463
enum_alter_table_lock requested_lock
Definition: sql_alter.h:450
Class which instances represent RENAME INDEX clauses in ALTER TABLE statement.
Definition: sql_alter.h:175
Alter_rename_key(const char *old_name_arg, const char *new_name_arg)
Definition: sql_alter.h:180
const char * new_name
Definition: sql_alter.h:178
const char * old_name
Definition: sql_alter.h:177
Runtime context for ALTER TABLE.
Definition: sql_alter.h:531
bool tmp_table
Indicates that we are altering temporary table.
Definition: sql_alter.h:613
char path[FN_REFLEN+1]
Definition: sql_alter.h:607
bool is_database_changed() const
Definition: sql_alter.h:543
Alter_table_ctx(const Alter_table_ctx &rhs)
const char * table_name
Definition: sql_alter.h:580
uint error_if_not_empty_mask
Definition: sql_alter.h:572
bool is_table_renamed() const
Definition: sql_alter.h:554
const char * new_name
Definition: sql_alter.h:583
uint fk_count
Definition: sql_alter.h:589
static const error_if_not_empty_mask DATETIME_WITHOUT_DEFAULT
Definition: sql_alter.h:573
FOREIGN_KEY * fk_info
Definition: sql_alter.h:588
char tmp_path[FN_REFLEN+1]
Definition: sql_alter.h:609
char tmp_name[80]
Definition: sql_alter.h:585
MDL_request target_db_mdl_request
Metadata lock request on table's new database if it is changed.
Definition: sql_alter.h:602
Alter_table_ctx & operator=(const Alter_table_ctx &rhs)
static const error_if_not_empty_mask GEOMETRY_WITHOUT_DEFAULT
Definition: sql_alter.h:574
bool is_table_name_changed() const
Definition: sql_alter.h:548
Alter_table_ctx()
Definition: sql_alter.cc:99
const char * get_tmp_path() const
Definition: sql_alter.h:569
const char * new_db
Definition: sql_alter.h:582
MDL_request target_mdl_request
Metadata lock request on table's new name when this name or database are changed.
Definition: sql_alter.h:600
const char * db
Definition: sql_alter.h:579
error_if_not_empty_mask error_if_not_empty
Definition: sql_alter.h:577
const char * new_alias
Definition: sql_alter.h:584
char new_alias_buff[FN_REFLEN+1]
Definition: sql_alter.h:606
Create_field * datetime_field
Definition: sql_alter.h:576
const char * get_path() const
Definition: sql_alter.h:561
char new_filename[FN_REFLEN+1]
Definition: sql_alter.h:605
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:594
uint tables_opened
Definition: sql_alter.h:578
const char * alias
Definition: sql_alter.h:581
char new_path[FN_REFLEN+1]
Definition: sql_alter.h:608
Create_field is a description a field/column that may or may not exists in a table.
Definition: create_field.h:51
Definition: key.h:43
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
Definition: key_spec.h:208
Definition: sql_list.h:494
A pending metadata lock request.
Definition: mdl.h:805
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:432
Represents the generic ALTER TABLE statement.
Definition: sql_alter.h:639
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:360
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:220
Represents the common properties of the ALTER TABLE statements.
Definition: sql_alter.h:624
~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:630
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:650
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:372
bool mysql_discard_or_import_tablespace(THD *thd, Table_ref *table_list)
Definition: sql_table.cc:12157
Represents ALTER TABLE SECONDARY_LOAD/SECONDARY_UNLOAD statements.
Definition: sql_alter.h:663
bool execute(THD *thd) override
Execute this SQL statement.
Definition: sql_alter.cc:426
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:12396
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2958
Used for storing information associated with generated column, default values generated from expressi...
Definition: field.h:481
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, LEX_CSTRING masking_policy, 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:5571
constexpr const LEX_CSTRING NULL_CSTR
Definition: lex_string.h:48
#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:87
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_ALTER_TABLE
Definition: my_sqlcommand.h:50
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
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:203
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