reassign_owned_opclass_opfamily.diff
application/octet-stream
Filename: reassign_owned_opclass_opfamily.diff
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/catalog/pg_shdepend.c | 10 | 0 |
| src/backend/commands/opclasscmds.c | 46 | 0 |
| src/include/commands/defrem.h | 2 | 0 |
*** a/src/backend/catalog/pg_shdepend.c
--- b/src/backend/catalog/pg_shdepend.c
***************
*** 26,31 ****
--- 26,33 ----
#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,1352 **** shdepReassignOwned(List *roleids, Oid newrole)
--- 1349,1362 ----
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;
*** a/src/backend/commands/opclasscmds.c
--- b/src/backend/commands/opclasscmds.c
***************
*** 1995,2000 **** AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
--- 1995,2023 ----
}
/*
+ * 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,2127 **** AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
--- 2145,2173 ----
}
/*
+ * 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.
*/
*** a/src/include/commands/defrem.h
--- b/src/include/commands/defrem.h
***************
*** 89,95 **** extern void RemoveAmProcEntryById(Oid entryOid);
--- 89,97 ----
extern void RenameOpClass(List *name, const char *access_method, const char *newname);
extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
extern void AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId);
+ extern void AlterOpClassOwner_oid(Oid opclassOid, Oid newOwnerId);
extern void AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId);
+ extern void AlterOpFamilyOwner_oid(Oid opfamilyOid, Oid newOwnerId);
/* commands/tsearchcmds.c */
extern void DefineTSParser(List *names, List *parameters);