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