mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
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.
This commit is contained in:
@@ -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:
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user