Skip to content

Commit 979766c

Browse files
committed
Correct the command tags for ALTER ... RENAME COLUMN.
Previously ALTER MATERIALIZED VIEW / FOREIGN TABLE ... RENAME COLUMN ... returned "ALTER TABLE" as a command tag. This commit fixes them so that they return "ALTER MATERIALIZED VIEW" and "ALTER FOREIGN TABLE" as command tags, respectively. This issue exists in all supported versions, but we don't back-patch this because it's not enough of a bug to justify taking any compatibility risks for. Otherwise, the back-patch would cause minor version update to break, for example, the existing event trigger functions using TG_TAG. Author: Fujii Masao Reviewed-by: Ibrar Ahmed Discussion: https://postgr.es/m/CAHGQGwGUaC03FFdTFoHsCuDrrNvFvNVQ6xyd40==P25WvuBJjg@mail.gmail.com
1 parent a386942 commit 979766c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/backend/tcop/utility.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2399,7 +2399,14 @@ CreateCommandTag(Node *parsetree)
23992399
break;
24002400

24012401
case T_RenameStmt:
2402-
tag = AlterObjectTypeCommandTag(((RenameStmt *) parsetree)->renameType);
2402+
/*
2403+
* When the column is renamed, the command tag is created
2404+
* from its relation type
2405+
*/
2406+
tag = AlterObjectTypeCommandTag(
2407+
((RenameStmt *) parsetree)->renameType == OBJECT_COLUMN ?
2408+
((RenameStmt *) parsetree)->relationType :
2409+
((RenameStmt *) parsetree)->renameType);
24032410
break;
24042411

24052412
case T_AlterObjectDependsStmt:

0 commit comments

Comments
 (0)