提交 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,6 +5422,19 @@ public class Parser { ...@@ -5422,6 +5422,19 @@ public class Parser {
} }
return command; return command;
} else if (readIf("RENAME")) { } else if (readIf("RENAME")) {
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"); read("TO");
String newName = readIdentifierWithSchema(table.getSchema() String newName = readIdentifierWithSchema(table.getSchema()
.getName()); .getName());
...@@ -5432,6 +5445,7 @@ public class Parser { ...@@ -5432,6 +5445,7 @@ public class Parser {
command.setNewTableName(newName); command.setNewTableName(newName);
command.setHidden(readIf("HIDDEN")); command.setHidden(readIf("HIDDEN"));
return command; 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论