mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Refactor "ALTER some-obj SET SCHEMA" implementation
Instead of having each object type implement the catalog munging independently, centralize knowledge about how to do it and expand the existing table in objectaddress.c with enough data about each object type to support this operation. Author: KaiGai Kohei Tweaks by me Reviewed by Robert Haas
This commit is contained in:
@ -423,56 +423,3 @@ AlterOperatorOwner_internal(Relation rel, Oid operOid, Oid newOwnerId)
|
||||
|
||||
heap_freetuple(tup);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute ALTER OPERATOR SET SCHEMA
|
||||
*/
|
||||
void
|
||||
AlterOperatorNamespace(List *names, List *argtypes, const char *newschema)
|
||||
{
|
||||
List *operatorName = names;
|
||||
TypeName *typeName1 = (TypeName *) linitial(argtypes);
|
||||
TypeName *typeName2 = (TypeName *) lsecond(argtypes);
|
||||
Oid operOid,
|
||||
nspOid;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||
|
||||
Assert(list_length(argtypes) == 2);
|
||||
operOid = LookupOperNameTypeNames(NULL, operatorName,
|
||||
typeName1, typeName2,
|
||||
false, -1);
|
||||
|
||||
/* get schema OID */
|
||||
nspOid = LookupCreationNamespace(newschema);
|
||||
|
||||
AlterObjectNamespace(rel, OPEROID, -1,
|
||||
operOid, nspOid,
|
||||
Anum_pg_operator_oprname,
|
||||
Anum_pg_operator_oprnamespace,
|
||||
Anum_pg_operator_oprowner,
|
||||
ACL_KIND_OPER);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
||||
Oid
|
||||
AlterOperatorNamespace_oid(Oid operOid, Oid newNspOid)
|
||||
{
|
||||
Oid oldNspOid;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(OperatorRelationId, RowExclusiveLock);
|
||||
|
||||
oldNspOid = AlterObjectNamespace(rel, OPEROID, -1,
|
||||
operOid, newNspOid,
|
||||
Anum_pg_operator_oprname,
|
||||
Anum_pg_operator_oprnamespace,
|
||||
Anum_pg_operator_oprowner,
|
||||
ACL_KIND_OPER);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return oldNspOid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user