|
9 | 9 | * |
10 | 10 | * |
11 | 11 | * 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 $ |
13 | 13 | * |
14 | 14 | * DESCRIPTION |
15 | 15 | * The "DefineFoo" routines take the parse tree and pick out the |
@@ -318,58 +318,10 @@ void |
318 | 318 | AlterAggregateOwner(List *name, List *args, Oid newOwnerId) |
319 | 319 | { |
320 | 320 | Oid procOid; |
321 | | - HeapTuple tup; |
322 | | - Form_pg_proc procForm; |
323 |
8000
| - Relation rel; |
324 | | - AclResult aclresult; |
325 | | - |
326 | | - rel = heap_open(ProcedureRelationId, RowExclusiveLock); |
327 | 321 |
|
328 | 322 | /* Look up function and make sure it's an aggregate */ |
329 | 323 | procOid = LookupAggNameTypeNames(name, args, false); |
330 | 324 |
|
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()) |
<
8000
td data-grid-cell-id="diff-5e0cd5d71fd02d906a86504c8d5508483b2cdd8ca259c8ed1b2131cab36687a0-346-324-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">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); |
375 | 327 | } |
0 commit comments