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

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

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