diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2020-03-03 13:50:32 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2020-03-03 13:50:32 +0300 |
commit | fa8ad7543947f5c74dece982d42bab59b6479449 (patch) | |
tree | d40ac2133feb08ce8b10e77d8180443768dfc99c /sql/sql_yacc.yy | |
parent | a99c93a7fafd3f47212ec385afa8011bcec052bc (diff) | |
download | mariadb-git-fa8ad7543947f5c74dece982d42bab59b6479449.tar.gz |
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
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f24da3ed412..1d4a8a7e228 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7705,13 +7705,12 @@ alter_list_item: } | ALTER opt_column opt_if_exists_table_element field_ident SET DEFAULT column_default_expr { - if (unlikely(Lex->add_alter_list($4.str, $7, $3))) + if (unlikely(Lex->add_alter_list($4, $7, $3))) MYSQL_YYABORT; } | ALTER opt_column opt_if_exists_table_element field_ident DROP DEFAULT { - if (unlikely(Lex->add_alter_list($4.str, (Virtual_column_info*) 0, - $3))) + if (unlikely(Lex->add_alter_list($4, (Virtual_column_info*) 0, $3))) MYSQL_YYABORT; } | RENAME opt_to table_ident @@ -7728,6 +7727,11 @@ alter_list_item: lex->name= $3->table; lex->alter_info.flags|= ALTER_RENAME; } + | RENAME COLUMN_SYM ident TO_SYM ident + { + if (unlikely(Lex->add_alter_list($3, $5))) + MYSQL_YYABORT; + } | CONVERT_SYM TO_SYM charset charset_name_or_default opt_collate { if (!$4) |