mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
Add some opfamily support functions to lsyscache.c
Add get_opfamily_method() and get_opfamily_member_for_cmptype() in lsyscache.c. No callers yet, but we'll add some soon. This is part of generalizing some parts of the code away from having btree hardcoded and use CompareType instead. Author: 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:
44
src/backend/utils/cache/lsyscache.c
vendored
44
src/backend/utils/cache/lsyscache.c
vendored
@ -184,6 +184,28 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get_opfamily_member_for_cmptype
|
||||||
|
* Get the OID of the operator that implements the specified comparison
|
||||||
|
* type with the specified datatypes for the specified opfamily.
|
||||||
|
*
|
||||||
|
* Returns InvalidOid if there is no mapping for the comparison type or no
|
||||||
|
* pg_amop entry for the given keys.
|
||||||
|
*/
|
||||||
|
Oid
|
||||||
|
get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype,
|
||||||
|
CompareType cmptype)
|
||||||
|
{
|
||||||
|
Oid opmethod;
|
||||||
|
StrategyNumber strategy;
|
||||||
|
|
||||||
|
opmethod = get_opfamily_method(opfamily);
|
||||||
|
strategy = IndexAmTranslateCompareType(cmptype, opmethod, opfamily, true);
|
||||||
|
if (!strategy)
|
||||||
|
return InvalidOid;
|
||||||
|
return get_opfamily_member(opfamily, lefttype, righttype, strategy);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_ordering_op_properties
|
* get_ordering_op_properties
|
||||||
* Given the OID of an ordering operator (a btree "<" or ">" operator),
|
* Given the OID of an ordering operator (a btree "<" or ">" operator),
|
||||||
@ -1288,6 +1310,28 @@ get_opclass_method(Oid opclass)
|
|||||||
|
|
||||||
/* ---------- OPFAMILY CACHE ---------- */
|
/* ---------- 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 *
|
char *
|
||||||
get_opfamily_name(Oid opfid, bool missing_ok)
|
get_opfamily_name(Oid opfid, bool missing_ok)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#define LSYSCACHE_H
|
#define LSYSCACHE_H
|
||||||
|
|
||||||
#include "access/attnum.h"
|
#include "access/attnum.h"
|
||||||
|
#include "access/cmptype.h"
|
||||||
#include "access/htup.h"
|
#include "access/htup.h"
|
||||||
#include "nodes/pg_list.h"
|
#include "nodes/pg_list.h"
|
||||||
|
|
||||||
@ -74,6 +75,8 @@ extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
|
|||||||
Oid *righttype);
|
Oid *righttype);
|
||||||
extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
|
extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
|
||||||
int16 strategy);
|
int16 strategy);
|
||||||
|
extern Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype,
|
||||||
|
CompareType cmptype);
|
||||||
extern bool get_ordering_op_properties(Oid opno,
|
extern bool get_ordering_op_properties(Oid opno,
|
||||||
Oid *opfamily, Oid *opcintype, int16 *strategy);
|
Oid *opfamily, Oid *opcintype, int16 *strategy);
|
||||||
extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
|
extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
|
||||||
@ -108,6 +111,7 @@ extern Oid get_opclass_input_type(Oid opclass);
|
|||||||
extern bool get_opclass_opfamily_and_input_type(Oid opclass,
|
extern bool get_opclass_opfamily_and_input_type(Oid opclass,
|
||||||
Oid *opfamily, Oid *opcintype);
|
Oid *opfamily, Oid *opcintype);
|
||||||
extern Oid get_opclass_method(Oid opclass);
|
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 char *get_opfamily_name(Oid opfid, bool missing_ok);
|
||||||
extern RegProcedure get_opcode(Oid opno);
|
extern RegProcedure get_opcode(Oid opno);
|
||||||
extern char *get_opname(Oid opno);
|
extern char *get_opname(Oid opno);
|
||||||
|
Reference in New Issue
Block a user