diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 301420c401d..571990eef9b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.239 2008/01/02 23:34:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.240 2008/01/17 18:56:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1659,13 +1659,13 @@ renamerel(Oid myrelid, const char *newrelname, ObjectType reltype) * or ALTER INDEX is used to rename a sequence or view. */ relkind = targetrelation->rd_rel->relkind; - if (reltype == OBJECT_SEQUENCE && relkind != 'S') + if (reltype == OBJECT_SEQUENCE && relkind != RELKIND_SEQUENCE) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a sequence", RelationGetRelationName(targetrelation)))); - if (reltype == OBJECT_VIEW && relkind != 'v') + if (reltype == OBJECT_VIEW && relkind != RELKIND_VIEW) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a view", @@ -1712,6 +1712,17 @@ renamerel(Oid myrelid, const char *newrelname, ObjectType reltype) TypeRename(targetrelation->rd_rel->reltype, newrelname, namespaceId); /* + * Also rename the associated constraint, if any. + */ + if (relkind == RELKIND_INDEX) + { + Oid constraintId = get_index_constraint(myrelid); + + if (OidIsValid(constraintId)) + RenameConstraintById(constraintId, newrelname); + } + + /* * Close rel, but keep exclusive lock! */ relation_close(targetrelation, NoLock); |