1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-15 05:46:52 +03:00

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
This commit is contained in:
Peter Eisentraut
2025-01-24 22:58:13 +01:00
parent a5709b5bb2
commit 43493cceda
10 changed files with 40 additions and 98 deletions

View File

@@ -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 ---------- */
/*