mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +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:
@ -266,53 +266,3 @@ AlterConversionOwner_internal(Relation rel, Oid conversionOid, Oid newOwnerId)
|
||||
|
||||
heap_freetuple(tup);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute ALTER CONVERSION SET SCHEMA
|
||||
*/
|
||||
void
|
||||
AlterConversionNamespace(List *name, const char *newschema)
|
||||
{
|
||||
Oid convOid,
|
||||
nspOid;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||
|
||||
convOid = get_conversion_oid(name, false);
|
||||
|
||||
/* get schema OID */
|
||||
nspOid = LookupCreationNamespace(newschema);
|
||||
|
||||
AlterObjectNamespace(rel, CONVOID, CONNAMENSP,
|
||||
convOid, nspOid,
|
||||
Anum_pg_conversion_conname,
|
||||
Anum_pg_conversion_connamespace,
|
||||
Anum_pg_conversion_conowner,
|
||||
ACL_KIND_CONVERSION);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Change conversion schema, by oid
|
||||
*/
|
||||
Oid
|
||||
AlterConversionNamespace_oid(Oid convOid, Oid newNspOid)
|
||||
{
|
||||
Oid oldNspOid;
|
||||
Relation rel;
|
||||
|
||||
rel = heap_open(ConversionRelationId, RowExclusiveLock);
|
||||
|
||||
oldNspOid = AlterObjectNamespace(rel, CONVOID, CONNAMENSP,
|
||||
convOid, newNspOid,
|
||||
Anum_pg_conversion_conname,
|
||||
Anum_pg_conversion_connamespace,
|
||||
Anum_pg_conversion_conowner,
|
||||
ACL_KIND_CONVERSION);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return oldNspOid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user