mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Replace AclObjectKind with ObjectType
AclObjectKind was basically just another enumeration for object types, and we already have a preferred one for that. It's only used in aclcheck_error. By using ObjectType instead, we can also give some more precise error messages, for example "index" instead of "relation". Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
@ -171,7 +171,7 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
|
||||
AttrNumber Anum_name = get_object_attnum_name(classId);
|
||||
AttrNumber Anum_namespace = get_object_attnum_namespace(classId);
|
||||
AttrNumber Anum_owner = get_object_attnum_owner(classId);
|
||||
AclObjectKind acl_kind = get_object_aclkind(classId);
|
||||
ObjectType objtype = get_object_type(classId, objectId);
|
||||
HeapTuple oldtup;
|
||||
HeapTuple newtup;
|
||||
Datum datum;
|
||||
@ -223,7 +223,7 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
|
||||
ownerId = DatumGetObjectId(datum);
|
||||
|
||||
if (!has_privs_of_role(GetUserId(), DatumGetObjectId(ownerId)))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, acl_kind, old_name);
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, objtype, old_name);
|
||||
|
||||
/* User must have CREATE privilege on the namespace */
|
||||
if (OidIsValid(namespaceId))
|
||||
@ -231,7 +231,7 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
|
||||
aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(),
|
||||
ACL_CREATE);
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
|
||||
aclcheck_error(aclresult, OBJECT_SCHEMA,
|
||||
get_namespace_name(namespaceId));
|
||||
}
|
||||
}
|
||||
@ -663,7 +663,7 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
|
||||
AttrNumber Anum_name = get_object_attnum_name(classId);
|
||||
AttrNumber Anum_namespace = get_object_attnum_namespace(classId);
|
||||
AttrNumber Anum_owner = get_object_attnum_owner(classId);
|
||||
AclObjectKind acl_kind = get_object_aclkind(classId);
|
||||
ObjectType objtype = get_object_type(classId, objid);
|
||||
Oid oldNspOid;
|
||||
Datum name,
|
||||
namespace;
|
||||
@ -719,13 +719,13 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
|
||||
ownerId = DatumGetObjectId(owner);
|
||||
|
||||
if (!has_privs_of_role(GetUserId(), ownerId))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, acl_kind,
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
|
||||
NameStr(*(DatumGetName(name))));
|
||||
|
||||
/* User must have CREATE privilege on new namespace */
|
||||
aclresult = pg_namespace_aclcheck(nspOid, GetUserId(), ACL_CREATE);
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
|
||||
aclcheck_error(aclresult, OBJECT_SCHEMA,
|
||||
get_namespace_name(nspOid));
|
||||
}
|
||||
|
||||
@ -942,7 +942,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
|
||||
/* Superusers can bypass permission checks */
|
||||
if (!superuser())
|
||||
{
|
||||
AclObjectKind aclkind = get_object_aclkind(classId);
|
||||
ObjectType objtype = get_object_type(classId, objectId);
|
||||
|
||||
/* must be owner */
|
||||
if (!has_privs_of_role(GetUserId(), old_ownerId))
|
||||
@ -963,7 +963,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
|
||||
HeapTupleGetOid(oldtup));
|
||||
objname = namebuf;
|
||||
}
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, aclkind, objname);
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, objtype, objname);
|
||||
}
|
||||
/* Must be able to become new owner */
|
||||
check_is_member_of_role(GetUserId(), new_ownerId);
|
||||
@ -976,7 +976,7 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
|
||||
aclresult = pg_namespace_aclcheck(namespaceId, new_ownerId,
|
||||
ACL_CREATE);
|
||||
if (aclresult != ACLCHECK_OK)
|
||||
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
|
||||
aclcheck_error(aclresult, OBJECT_SCHEMA,
|
||||
get_namespace_name(namespaceId));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user