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