Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7317e64

Browse files
committed
Add some opfamily support functions to lsyscache.c
Add get_opfamily_method() and get_opfamily_member_for_cmptype() inlsyscache.c. No callers yet, but we'll add some soon. This is partof generalizing some parts of the code away from having btreehardcoded 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
1 parent122a9af commit7317e64

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

‎src/backend/utils/cache/lsyscache.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,28 @@ get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,
184184
returnresult;
185185
}
186186

187+
/*
188+
* get_opfamily_member_for_cmptype
189+
*Get the OID of the operator that implements the specified comparison
190+
*type with the specified datatypes for the specified opfamily.
191+
*
192+
* Returns InvalidOid if there is no mapping for the comparison type or no
193+
* pg_amop entry for the given keys.
194+
*/
195+
Oid
196+
get_opfamily_member_for_cmptype(Oidopfamily,Oidlefttype,Oidrighttype,
197+
CompareTypecmptype)
198+
{
199+
Oidopmethod;
200+
StrategyNumberstrategy;
201+
202+
opmethod=get_opfamily_method(opfamily);
203+
strategy=IndexAmTranslateCompareType(cmptype,opmethod,opfamily, true);
204+
if (!strategy)
205+
returnInvalidOid;
206+
returnget_opfamily_member(opfamily,lefttype,righttype,strategy);
207+
}
208+
187209
/*
188210
* get_ordering_op_properties
189211
*Given the OID of an ordering operator (a btree "<" or ">" operator),
@@ -1288,6 +1310,28 @@ get_opclass_method(Oid opclass)
12881310

12891311
/*---------- OPFAMILY CACHE ---------- */
12901312

1313+
/*
1314+
* get_opfamily_method
1315+
*
1316+
*Returns the OID of the index access method the opfamily is for.
1317+
*/
1318+
Oid
1319+
get_opfamily_method(Oidopfid)
1320+
{
1321+
HeapTupletp;
1322+
Form_pg_opfamilyopfform;
1323+
Oidresult;
1324+
1325+
tp=SearchSysCache1(OPFAMILYOID,ObjectIdGetDatum(opfid));
1326+
if (!HeapTupleIsValid(tp))
1327+
elog(ERROR,"cache lookup failed for operator family %u",opfid);
1328+
opfform= (Form_pg_opfamily)GETSTRUCT(tp);
1329+
1330+
result=opfform->opfmethod;
1331+
ReleaseSysCache(tp);
1332+
returnresult;
1333+
}
1334+
12911335
char*
12921336
get_opfamily_name(Oidopfid,boolmissing_ok)
12931337
{

‎src/include/utils/lsyscache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#defineLSYSCACHE_H
1515

1616
#include"access/attnum.h"
17+
#include"access/cmptype.h"
1718
#include"access/htup.h"
1819
#include"nodes/pg_list.h"
1920

@@ -74,6 +75,8 @@ extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
7475
Oid*righttype);
7576
externOidget_opfamily_member(Oidopfamily,Oidlefttype,Oidrighttype,
7677
int16strategy);
78+
externOidget_opfamily_member_for_cmptype(Oidopfamily,Oidlefttype,Oidrighttype,
79+
CompareTypecmptype);
7780
externboolget_ordering_op_properties(Oidopno,
7881
Oid*opfamily,Oid*opcintype,int16*strategy);
7982
externOidget_equality_op_for_ordering_op(Oidopno,bool*reverse);
@@ -108,6 +111,7 @@ extern Oidget_opclass_input_type(Oid opclass);
108111
externboolget_opclass_opfamily_and_input_type(Oidopclass,
109112
Oid*opfamily,Oid*opcintype);
110113
externOidget_opclass_method(Oidopclass);
114+
externOidget_opfamily_method(Oidopfid);
111115
externchar*get_opfamily_name(Oidopfid,boolmissing_ok);
112116
externRegProcedureget_opcode(Oidopno);
113117
externchar*get_opname(Oidopno);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp