diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/pg_shdepend.c | 12 | ||||
-rw-r--r-- | src/backend/commands/opclasscmds.c | 45 |
2 files changed, 55 insertions, 2 deletions
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 7fa55d9267d..e40ce1c4469 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23.2.2 2008/04/29 19:37:13 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_shdepend.c,v 1.23.2.3 2010/07/03 13:53:38 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -26,6 +26,8 @@ #include "catalog/pg_language.h" #include "catalog/pg_namespace.h" #include "catalog/pg_operator.h" +#include "catalog/pg_opclass.h" +#include "catalog/pg_opfamily.h" #include "catalog/pg_proc.h" #include "catalog/pg_shdepend.h" #include "catalog/pg_tablespace.h" @@ -1347,6 +1349,14 @@ shdepReassignOwned(List *roleids, Oid newrole) AlterLanguageOwner_oid(sdepForm->objid, newrole); break; + case OperatorClassRelationId: + AlterOpClassOwner_oid(sdepForm->objid, newrole); + break; + + case OperatorFamilyRelationId: + AlterOpFamilyOwner_oid(sdepForm->objid, newrole); + break; + default: elog(ERROR, "unexpected classid %d", sdepForm->classid); break; diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 7957d0474d9..c7739280e09 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.58 2008/01/01 19:45:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.58.2.1 2010/07/03 13:53:38 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -1995,6 +1995,27 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId) } /* + * Change operator class owner, specified by OID + */ +void +AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId) +{ + HeapTuple tup; + Relation rel; + + rel = heap_open(OperatorClassRelationId, RowExclusiveLock); + + tup = SearchSysCacheCopy(CLAOID, ObjectIdGetDatum(opclassOid), 0, 0, 0); + 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. */ @@ -2122,6 +2143,28 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId) } /* + * Change operator family owner, specified by OID + */ +void +AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId) +{ + HeapTuple tup; + Relation rel; + + rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock); + + tup = SearchSysCacheCopy(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid), + 0, 0, 0); + 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. */ |