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:
27
src/backend/utils/cache/lsyscache.c
vendored
27
src/backend/utils/cache/lsyscache.c
vendored
@@ -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 ---------- */
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user