提交 ad857502 authored 作者: Noel Grandin's avatar Noel Grandin

Add support for PostgreSQL ALTER TABLE ... RENAME COLUMN .. TO ...

上级 7df59e43
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Add support for PostgreSQL ALTER TABLE ... RENAME COLUMN .. TO ...
</li>
<li>Improve performance of cleaning up temp tables - patch from Eric Faulhaber.
</li>
<li>Fix bug where table locks were not dropped when the connection closed
......
......@@ -5422,16 +5422,30 @@ public class Parser {
}
return command;
} else if (readIf("RENAME")) {
read("TO");
String newName = readIdentifierWithSchema(table.getSchema()
.getName());
checkSchema(table.getSchema());
AlterTableRename command = new AlterTableRename(session,
getSchema());
command.setOldTable(table);
command.setNewTableName(newName);
command.setHidden(readIf("HIDDEN"));
return command;
if (readIf("COLUMN")) {
// PostgreSQL syntax
String columnName = readColumnIdentifier();
Column column = table.getColumn(columnName);
read("TO");
AlterTableRenameColumn command = new AlterTableRenameColumn(
session);
command.setTable(table);
command.setColumn(column);
String newName = readColumnIdentifier();
command.setNewColumnName(newName);
return command;
} else {
read("TO");
String newName = readIdentifierWithSchema(table.getSchema()
.getName());
checkSchema(table.getSchema());
AlterTableRename command = new AlterTableRename(session,
getSchema());
command.setOldTable(table);
command.setNewTableName(newName);
command.setHidden(readIf("HIDDEN"));
return command;
}
} else if (readIf("DROP")) {
if (readIf("CONSTRAINT")) {
boolean ifExists = readIfExists(false);
......
......@@ -4514,7 +4514,7 @@ create index idx_n_id on test(name, id);
alter table test add constraint abc foreign key(id) references (id);
> ok
alter table test alter column id rename to i;
alter table test rename column id to i;
> ok
script NOPASSWORDS NOSETTINGS drop;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论