Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit395f8b9

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_shdependnor adjusting the aggregate's ACL. In 8.2 and up, fix this permanentlyby making it use AlterFunctionOwner_oid. In 8.1, the function code wasn'tfactored that way, so just copy and paste.
1 parent6d61b40 commit395f8b9

File tree

1 file changed

+3
-51
lines changed

1 file changed

+3
-51
lines changed

‎src/backend/commands/aggregatecmds.c

Lines changed: 3 additions & 51 deletions
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:48momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.46 2008/06/08 21:09:48tgl 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,OidnewOwnerId)
319319
{
320320
OidprocOid;
321-
HeapTupletup;
322-
Form_pg_procprocForm;
323-
Relationrel;
324-
AclResultaclresult;
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)

[8]ページ先頭

©2009-2025 Movatter.jp