Hi Currently it's possible to do:
ALTER TABLE foo RENAME COLUMN bar TO baz; ALTER FOREIGN TABLE ft_foo RENAME COLUMN bar TO baz; and: ALTER TABLE foo RENAME CONSTRAINT alice TO bob; but for some reason not: ALTER FOREIGN TABLE ft_foo RENAME CONSTRAINT alice TO bob; even though ALTER FOREIGN TABLE ... ADD / DROP CONSTRAINT is possible. I appreciate this is very niche, but I ran into it when working intensively with foreign tables and was annoyed enough to start writing a patch. I can't see any reason not to do this, the code change is fairly small, and ALTER FOREIGN TABLE has other non-standard extensions anyway. I should note that "ALTER TABLE ... RENAME CONSTRAINT" does work on all table-like objects [*]; this wasn't obvious to me when I first ran into the issue, and it seems inconsistent that "OWNER TO" works with both "ALTER TABLE" and "ALTER FOREIGN TABLE". [*] https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-DESC-RENAME The attached patch implements this; note I had to do a bit of refactoring in tcop/utility.c to ensure the correct command tag is returned. Patch includes test, documentation and psql tab completion (the latter also adds support for related ALTER FOREIGN TABLE grammar items, as it would be harder not to add them; it is not meant as an attempt to add all missing ALTER FOREIGN TABLE items). Regards Ian Barwick
v1-0001-Support-ALTER-FOREIGN-TABLE-.-RENAME-CONSTRAINT.patch
Description: Binary data
