mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-16290 ALTER TABLE ... RENAME COLUMN syntax
The existing syntax for renaming a column uses "ALTER TABLE ... CHANGE" command. This requires full column specification to rename the column. This patch adds new syntax "ALTER TABLE ... RENAME COLUMN", which do not expect users to provide full column specification. It means that the new syntax would pick in-place or copy algorithm in the same way as that of existing "ALTER TABLE ... CHANGE" command. The existing syntax "ALTER TABLE ... CHANGE" will continue to work. Syntax changes ============== ALTER TABLE tbl_name [alter_specification [, alter_specification] ...] [partition_options] Following is a new <alter_specification> added: | RENAME COLUMN <oldname> TO <newname> Where <oldname> and <newname> are identifiers for old name and new name of the column. Related to: WL#10761
This commit is contained in:
@ -333,17 +333,25 @@ public:
|
||||
|
||||
class Alter_column :public Sql_alloc {
|
||||
public:
|
||||
const char *name;
|
||||
LEX_CSTRING name;
|
||||
LEX_CSTRING new_name;
|
||||
Virtual_column_info *default_value;
|
||||
bool alter_if_exists;
|
||||
Alter_column(const char *par_name, Virtual_column_info *expr, bool par_exists)
|
||||
:name(par_name), default_value(expr), alter_if_exists(par_exists) {}
|
||||
Alter_column(LEX_CSTRING par_name, Virtual_column_info *expr, bool par_exists)
|
||||
:name(par_name), new_name{NULL, 0}, default_value(expr), alter_if_exists(par_exists) {}
|
||||
Alter_column(LEX_CSTRING par_name, LEX_CSTRING _new_name)
|
||||
:name(par_name), new_name(_new_name), default_value(NULL), alter_if_exists(false) {}
|
||||
/**
|
||||
Used to make a clone of this object for ALTER/CREATE TABLE
|
||||
@sa comment for Key_part_spec::clone
|
||||
*/
|
||||
Alter_column *clone(MEM_ROOT *mem_root) const
|
||||
{ return new (mem_root) Alter_column(*this); }
|
||||
bool is_rename()
|
||||
{
|
||||
DBUG_ASSERT(!new_name.str || !default_value);
|
||||
return new_name.str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user