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