|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.166 2005/08/04 01:09:28 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.167 2005/08/22 17:38:20 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -5307,23 +5307,27 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing) |
5307 | 5307 | /* skip permission checks when recursing to index or toast table */ |
5308 | 5308 | if (!recursing) |
5309 | 5309 | { |
5310 | | -OidnamespaceOid=tuple_class->relnamespace; |
5311 | | -AclResultaclresult; |
5312 | | - |
5313 | | -/* Otherwise, must be owner of the existing object */ |
5314 | | -if (!pg_class_ownercheck(relationOid,GetUserId())) |
5315 | | -aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS, |
5316 | | -RelationGetRelationName(target_rel)); |
5317 | | - |
5318 | | -/* Must be able to become new owner */ |
5319 | | -check_is_member_of_role(GetUserId(),newOwnerId); |
5320 | | - |
5321 | | -/* New owner must have CREATE privilege on namespace */ |
5322 | | -aclresult=pg_namespace_aclcheck(namespaceOid,newOwnerId, |
5323 | | -ACL_CREATE); |
5324 | | -if (aclresult!=ACLCHECK_OK) |
5325 | | -aclcheck_error(aclresult,ACL_KIND_NAMESPACE, |
5326 | | -get_namespace_name(namespaceOid)); |
| 5310 | +/* Superusers can always do it */ |
| 5311 | +if (!superuser()) |
| 5312 | +{ |
| 5313 | +OidnamespaceOid=tuple_class->relnamespace; |
| 5314 | +AclResultaclresult; |
| 5315 | + |
| 5316 | +/* Otherwise, must be owner of the existing object */ |
| 5317 | +if (!pg_class_ownercheck(relationOid,GetUserId())) |
| 5318 | +aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_CLASS, |
| 5319 | +RelationGetRelationName(target_rel)); |
| 5320 | + |
| 5321 | +/* Must be able to become new owner */ |
| 5322 | +check_is_member_of_role(GetUserId(),newOwnerId); |
| 5323 | + |
| 5324 | +/* New owner must have CREATE privilege on namespace */ |
| 5325 | +aclresult=pg_namespace_aclcheck(namespaceOid,newOwnerId, |
| 5326 | +ACL_CREATE); |
| 5327 | +if (aclresult!=ACLCHECK_OK) |
| 5328 | +aclcheck_error(aclresult,ACL_KIND_NAMESPACE, |
| 5329 | +get_namespace_name(namespaceOid)); |
| 5330 | +} |
5327 | 5331 | } |
5328 | 5332 |
|
5329 | 5333 | memset(repl_null,' ',sizeof(repl_null)); |
|