diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2011-12-22 22:43:56 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2011-12-22 22:43:56 +0200 |
commit | f90dd28062db2128a340fbe02f55829f15ab5561 (patch) | |
tree | 06636b98c913bfde151cc5ce2d62649f4a14eedb /src/backend/commands | |
parent | 8d15e3ec4fcb735875a8a70a09ec0c62153c3329 (diff) |
Add ALTER DOMAIN ... RENAME
You could already rename domains using ALTER TYPE, but with this new
command it is more consistent with how other commands treat domains as
a subcategory of types.
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/alter.c | 3 | ||||
-rw-r--r-- | src/backend/commands/typecmds.c | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 8513837fa10..cc11858d174 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -134,8 +134,9 @@ ExecRenameStmt(RenameStmt *stmt) RenameTSConfiguration(stmt->object, stmt->newname); break; + case OBJECT_DOMAIN: case OBJECT_TYPE: - RenameType(stmt->object, stmt->newname); + RenameType(stmt); break; default: diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index ea8f7f099a2..811273a01d7 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -3074,8 +3074,10 @@ GetDomainConstraints(Oid typeOid) * Execute ALTER TYPE RENAME */ void -RenameType(List *names, const char *newTypeName) +RenameType(RenameStmt *stmt) { + List *names = stmt->object; + const char *newTypeName = stmt->newname; TypeName *typename; Oid typeOid; Relation rel; @@ -3099,6 +3101,13 @@ RenameType(List *names, const char *newTypeName) aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TYPE, format_type_be(typeOid)); + /* ALTER DOMAIN used on a non-domain? */ + if (stmt->renameType == OBJECT_DOMAIN && typTup->typtype != TYPTYPE_DOMAIN) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("\"%s\" is not a domain", + format_type_be(typeOid)))); + /* * If it's a composite type, we need to check that it really is a * free-standing composite type, and not a table's rowtype. We want people |