1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Allow REASSIGNED OWNED to handle opclasses and opfamilies.

Backpatch to 8.3, which is as far back as we have opfamilies.
The opclass portion could probably be backpatched to 8.2, when
REASSIGN OWNED was added, but for now I have not done that.

Asko Tiidumaa, with minor adjustments by me.
This commit is contained in:
Robert Haas
2010-07-03 13:53:13 +00:00
parent 4b200a2769
commit b3b7d603fb
3 changed files with 57 additions and 3 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.66 2010/02/14 18:42:14 rhaas Exp $
* $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.67 2010/07/03 13:53:13 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@ -1948,6 +1948,27 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
heap_close(rel, NoLock);
}
/*
* Change operator class owner, specified by OID
*/
void
AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId)
{
HeapTuple tup;
Relation rel;
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(CLAOID, ObjectIdGetDatum(opclassOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for opclass %u", opclassOid);
AlterOpClassOwner_internal(rel, tup, newOwnerId);
heap_freetuple(tup);
heap_close(rel, NoLock);
}
/*
* The first parameter is pg_opclass, opened and suitably locked. The second
* parameter is a copy of the tuple from pg_opclass we want to modify.
@ -2070,6 +2091,27 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
heap_close(rel, NoLock);
}
/*
* Change operator family owner, specified by OID
*/
void
AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId)
{
HeapTuple tup;
Relation rel;
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for opfamily %u", opfamilyOid);
AlterOpFamilyOwner_internal(rel, tup, newOwnerId);
heap_freetuple(tup);
heap_close(rel, NoLock);
}
/*
* The first parameter is pg_opfamily, opened and suitably locked. The second
* parameter is a copy of the tuple from pg_opfamily we want to modify.