From bca4cfd1b8837ced9b74a04267861cac8003fbc6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 12 Mar 2025 13:45:39 +0100 Subject: [PATCH v21.2 1/4] Add get_opfamily_method() --- src/backend/utils/cache/lsyscache.c | 22 ++++++++++++++++++++++ src/include/utils/lsyscache.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 80c5a3fcfb7..9f7c0315052 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -1288,6 +1288,28 @@ get_opclass_method(Oid opclass) /* ---------- OPFAMILY CACHE ---------- */ +/* + * get_opfamily_method + * + * Returns the OID of the index access method the opfamily is for. + */ +Oid +get_opfamily_method(Oid opfid) +{ + HeapTuple tp; + Form_pg_opfamily opfform; + Oid result; + + tp = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid)); + if (!HeapTupleIsValid(tp)) + elog(ERROR, "cache lookup failed for operator family %u", opfid); + opfform = (Form_pg_opfamily) GETSTRUCT(tp); + + result = opfform->opfmethod; + ReleaseSysCache(tp); + return result; +} + char * get_opfamily_name(Oid opfid, bool missing_ok) { diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 6fab7aa6009..271eac2f0e1 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -108,6 +108,7 @@ extern Oid get_opclass_input_type(Oid opclass); extern bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype); extern Oid get_opclass_method(Oid opclass); +extern Oid get_opfamily_method(Oid opfid); extern char *get_opfamily_name(Oid opfid, bool missing_ok); extern RegProcedure get_opcode(Oid opno); extern char *get_opname(Oid opno); -- 2.48.1