Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2025-01-24 21:58:13 +0000
committerPeter Eisentraut2025-02-01 09:42:58 +0000
commit43493cceda2fb75e07a63cec46000407661d505d (patch)
tree0c8c0f8d1a109ccd7fb7b4ec45ced857e379f0fe /src/backend/utils/cache
parenta5709b5bb293a554913c4b1f6a9c58d1915ba3f7 (diff)
Add get_opfamily_name() function
This refactors and simplifies various existing code to make use of the new function. Reviewed-by: Mark Dilger <mark.dilger@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r--src/backend/utils/cache/lsyscache.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 7a9af03c960..bcfa5cb4add 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -30,6 +30,7 @@
#include "catalog/pg_language.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
+#include "catalog/pg_opfamily.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_publication.h"
@@ -1273,6 +1274,32 @@ get_opclass_method(Oid opclass)
return result;
}
+/* ---------- OPFAMILY CACHE ---------- */
+
+char *
+get_opfamily_name(Oid opfid, bool missing_ok)
+{
+ HeapTuple tup;
+ char *opfname;
+ Form_pg_opfamily opfform;
+
+ tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfid));
+
+ if (!HeapTupleIsValid(tup))
+ {
+ if (!missing_ok)
+ elog(ERROR, "cache lookup failed for operator family %u", opfid);
+ return NULL;
+ }
+
+ opfform = (Form_pg_opfamily) GETSTRUCT(tup);
+ opfname = pstrdup(NameStr(opfform->opfname));
+
+ ReleaseSysCache(tup);
+
+ return opfname;
+}
+
/* ---------- OPERATOR CACHE ---------- */
/*