Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 395f8b9

Browse files
committed
ALTER AGGREGATE OWNER seems to have been missed by the last couple of
patches that dealt with object ownership. It wasn't updating pg_shdepend nor adjusting the aggregate's ACL. In 8.2 and up, fix this permanently by making it use AlterFunctionOwner_oid. In 8.1, the function code wasn't factored that way, so just copy and paste.
1 parent 6d61b40 commit 395f8b9

File tree

1 file changed

+3
-51
lines changed

1 file changed

+3
-51
lines changed

src/backend/commands/aggregatecmds.c

+3-51
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.45 2008/01/01 19:45:48 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.46 2008/06/08 21:09:48 tgl Exp $
1313
*
1414
* DESCRIPTION
1515
* The "DefineFoo" routines take the parse tree and pick out the
@@ -318,58 +318,10 @@ void
318318
AlterAggregateOwner(List *name, List *args, Oid newOwnerId)
319319
{
320320
Oid procOid;
321-
HeapTuple tup;
322-
Form_pg_proc procForm;
323-
Relation rel;
324-
AclResult aclresult;
325-
326-
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
327321

328322
/* Look up function and make sure it's an aggregate */
329323
procOid = LookupAggNameTypeNames(name, args, false);
330324

331-
tup = SearchSysCacheCopy(PROCOID,
332-
ObjectIdGetDatum(procOid),
333-
0, 0, 0);
334-
if (!HeapTupleIsValid(tup)) /* should not happen */
335-
elog(ERROR, "cache lookup failed for function %u", procOid);
336-
procForm = (Form_pg_proc) GETSTRUCT(tup);
337-
338-
/*
339-
* If the new owner is the same as the existing owner, consider the
340-
* command to have succeeded. This is for dump restoration purposes.
341-
*/
342-
if (procForm->proowner != newOwnerId)
343-
{
344-
/* Superusers can always do it */
345-
if (!superuser())
346-
{
347-
/* Otherwise, must be owner of the existing object */
348-
if (!pg_proc_ownercheck(procOid, GetUserId()))
349-
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
350-
NameListToString(name));
351-
352-
/* Must be able to become new owner */
353-
check_is_member_of_role(GetUserId(), newOwnerId);
354-
355-
/* New owner must have CREATE privilege on namespace */
356-
aclresult = pg_namespace_aclcheck(procForm->pronamespace,
357-
newOwnerId,
358-
ACL_CREATE);
359-
if (aclresult != ACLCHECK_OK)
360-
aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
361-
get_namespace_name(procForm->pronamespace));
362-
}
363-
364-
/*
365-
* Modify the owner --- okay to scribble on tup because it's a copy
366-
*/
367-
procForm->proowner = newOwnerId;
368-
369-
simple_heap_update(rel, &tup->t_self, tup);
370-
CatalogUpdateIndexes(rel, tup);
371-
}
372-
373-
heap_close(rel, NoLock);
374-
heap_freetuple(tup);
325+
/* The rest is just like a function */
326+
AlterFunctionOwner_oid(procOid, newOwnerId);
375327
}

0 commit comments

Comments
 (0)