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

Commit765cbfd

Browse files
committed
Refactor ALTER some-obj RENAME implementation
Remove duplicate implementations of catalog munging and miscellaneousprivilege checks. Instead rely on already existing data inobjectaddress.c to do the work.Author: KaiGai Kohei, changes by meReviewed by: Robert Haas, Álvaro Herrera, Dimitri Fontaine
1 parent8f0d8f4 commit765cbfd

19 files changed

+348
-851
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ typedef struct
8080
Oidclass_oid;/* oid of catalog */
8181
Oidoid_index_oid;/* oid of index on system oid column */
8282
intoid_catcache_id;/* id of catcache on system oid column*/
83-
intname_catcache_id;/* id of catcache on (name,namespace) */
83+
intname_catcache_id;/* id of catcache on (name,namespace),
84+
* or (name) if the object does not
85+
* live in a namespace */
8486
AttrNumberattnum_name;/* attnum of name field */
8587
AttrNumberattnum_namespace;/* attnum of namespace field */
8688
AttrNumberattnum_owner;/* attnum of owner field */

‎src/backend/commands/aggregatecmds.c

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -226,66 +226,3 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
226226
transTypeId,/* transition data type */
227227
initval);/* initial condition */
228228
}
229-
230-
231-
/*
232-
* RenameAggregate
233-
*Rename an aggregate.
234-
*/
235-
Oid
236-
RenameAggregate(List*name,List*args,constchar*newname)
237-
{
238-
OidprocOid;
239-
OidnamespaceOid;
240-
HeapTupletup;
241-
Form_pg_procprocForm;
242-
Relationrel;
243-
AclResultaclresult;
244-
245-
rel=heap_open(ProcedureRelationId,RowExclusiveLock);
246-
247-
/* Look up function and make sure it's an aggregate */
248-
procOid=LookupAggNameTypeNames(name,args, false);
249-
250-
tup=SearchSysCacheCopy1(PROCOID,ObjectIdGetDatum(procOid));
251-
if (!HeapTupleIsValid(tup))/* should not happen */
252-
elog(ERROR,"cache lookup failed for function %u",procOid);
253-
procForm= (Form_pg_proc)GETSTRUCT(tup);
254-
255-
namespaceOid=procForm->pronamespace;
256-
257-
/* make sure the new name doesn't exist */
258-
if (SearchSysCacheExists3(PROCNAMEARGSNSP,
259-
CStringGetDatum(newname),
260-
PointerGetDatum(&procForm->proargtypes),
261-
ObjectIdGetDatum(namespaceOid)))
262-
ereport(ERROR,
263-
(errcode(ERRCODE_DUPLICATE_FUNCTION),
264-
errmsg("function %s already exists in schema \"%s\"",
265-
funcname_signature_string(newname,
266-
procForm->pronargs,
267-
NIL,
268-
procForm->proargtypes.values),
269-
get_namespace_name(namespaceOid))));
270-
271-
/* must be owner */
272-
if (!pg_proc_ownercheck(procOid,GetUserId()))
273-
aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_PROC,
274-
NameListToString(name));
275-
276-
/* must have CREATE privilege on namespace */
277-
aclresult=pg_namespace_aclcheck(namespaceOid,GetUserId(),ACL_CREATE);
278-
if (aclresult!=ACLCHECK_OK)
279-
aclcheck_error(aclresult,ACL_KIND_NAMESPACE,
280-
get_namespace_name(namespaceOid));
281-
282-
/* rename */
283-
namestrcpy(&(((Form_pg_proc)GETSTRUCT(tup))->proname),newname);
284-
simple_heap_update(rel,&tup->t_self,tup);
285-
CatalogUpdateIndexes(rel,tup);
286-
287-
heap_close(rel,NoLock);
288-
heap_freetuple(tup);
289-
290-
returnprocOid;
291-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp