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

Commit32edf73

Browse files
committed
Rename gist stratnum support function
Commit7406ab6 added a gist support function that we internallyrefer to by the symbol GIST_STRATNUM_PROC. This translated from"well-known" strategy numbers to opfamily-specific strategy numbers.However, we later (commit630f9a4) changed this to fit intoindex-AM-level compare type mapping, so this function actually nowmaps from compare type to opfamily-specific strategy numbers. So thisname is no longer fitting.Moreover, the index AM level also supports the opposite, a function tomap from strategy number to compare type. This is currently notsupported in gist, but one might wonder what this function is supposedto be called when it is added.This patch changes the naming of the gist-level functionality to bemore in line with the index-AM-level functionality. This makes sensebecause these are essentially the same thing on different levels.This also changes the names of the externally visible functions thatare provided for use as such a support function.Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com>Discussion:https://www.postgresql.org/message-id/37ebb1d9-9036-485f-a215-e55435689917%40eisentraut.org
1 parent5231ed8 commit32edf73

File tree

14 files changed

+92
-81
lines changed

14 files changed

+92
-81
lines changed

‎contrib/btree_gist/btree_gist--1.7--1.8.sql‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,85 @@
33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"ALTER EXTENSION btree_gist UPDATE TO '1.8'" to load this file. \quit
55

6-
CREATEFUNCTIONgist_stratnum_btree(int)
6+
CREATEFUNCTIONgist_translate_cmptype_btree(int)
77
RETURNSsmallint
88
AS'MODULE_PATHNAME'
99
LANGUAGE C IMMUTABLE PARALLEL SAFE STRICT;
1010

1111
ALTEROPERATOR FAMILY gist_oid_ops USING gist ADD
12-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
12+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
1313

1414
ALTEROPERATOR FAMILY gist_int2_ops USING gist ADD
15-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
15+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
1616

1717
ALTEROPERATOR FAMILY gist_int4_ops USING gist ADD
18-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
18+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
1919

2020
ALTEROPERATOR FAMILY gist_int8_ops USING gist ADD
21-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
21+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
2222

2323
ALTEROPERATOR FAMILY gist_float4_ops USING gist ADD
24-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
24+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
2525

2626
ALTEROPERATOR FAMILY gist_float8_ops USING gist ADD
27-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
27+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
2828

2929
ALTEROPERATOR FAMILY gist_timestamp_ops USING gist ADD
30-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
30+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
3131

3232
ALTEROPERATOR FAMILY gist_timestamptz_ops USING gist ADD
33-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
33+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
3434

3535
ALTEROPERATOR FAMILY gist_time_ops USING gist ADD
36-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
36+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
3737

3838
ALTEROPERATOR FAMILY gist_date_ops USING gist ADD
39-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
39+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
4040

4141
ALTEROPERATOR FAMILY gist_interval_ops USING gist ADD
42-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
42+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
4343

4444
ALTEROPERATOR FAMILY gist_cash_ops USING gist ADD
45-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
45+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
4646

4747
ALTEROPERATOR FAMILY gist_macaddr_ops USING gist ADD
48-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
48+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
4949

5050
ALTEROPERATOR FAMILY gist_text_ops USING gist ADD
51-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
51+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
5252

5353
ALTEROPERATOR FAMILY gist_bpchar_ops USING gist ADD
54-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
54+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
5555

5656
ALTEROPERATOR FAMILY gist_bytea_ops USING gist ADD
57-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
57+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
5858

5959
ALTEROPERATOR FAMILY gist_numeric_ops USING gist ADD
60-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
60+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
6161

6262
ALTEROPERATOR FAMILY gist_bit_ops USING gist ADD
63-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
63+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
6464

6565
ALTEROPERATOR FAMILY gist_vbit_ops USING gist ADD
66-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
66+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
6767

6868
ALTEROPERATOR FAMILY gist_inet_ops USING gist ADD
69-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
69+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
7070

7171
ALTEROPERATOR FAMILY gist_cidr_ops USING gist ADD
72-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
72+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
7373

7474
ALTEROPERATOR FAMILY gist_timetz_ops USING gist ADD
75-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
75+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
7676

7777
ALTEROPERATOR FAMILY gist_uuid_ops USING gist ADD
78-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
78+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
7979

8080
ALTEROPERATOR FAMILY gist_macaddr8_ops USING gist ADD
81-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
81+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
8282

8383
ALTEROPERATOR FAMILY gist_enum_ops USING gist ADD
84-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
84+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;
8585

8686
ALTEROPERATOR FAMILY gist_bool_ops USING gist ADD
87-
FUNCTION12 ("any","any")gist_stratnum_btree (int) ;
87+
FUNCTION12 ("any","any")gist_translate_cmptype_btree (int) ;

‎contrib/btree_gist/btree_gist.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PG_MODULE_MAGIC_EXT(
1515
PG_FUNCTION_INFO_V1(gbt_decompress);
1616
PG_FUNCTION_INFO_V1(gbtreekey_in);
1717
PG_FUNCTION_INFO_V1(gbtreekey_out);
18-
PG_FUNCTION_INFO_V1(gist_stratnum_btree);
18+
PG_FUNCTION_INFO_V1(gist_translate_cmptype_btree);
1919

2020
/**************************************************
2121
* In/Out for keys
@@ -62,7 +62,7 @@ gbt_decompress(PG_FUNCTION_ARGS)
6262
* Returns the btree number for supported operators, otherwise invalid.
6363
*/
6464
Datum
65-
gist_stratnum_btree(PG_FUNCTION_ARGS)
65+
gist_translate_cmptype_btree(PG_FUNCTION_ARGS)
6666
{
6767
CompareTypecmptype=PG_GETARG_INT32(0);
6868

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
-- test stratnum support func
2-
SELECTgist_stratnum_btree(7);
3-
gist_stratnum_btree
4-
---------------------
5-
0
1+
-- test stratnumtranslationsupport func
2+
SELECTgist_translate_cmptype_btree(7);
3+
gist_translate_cmptype_btree
4+
------------------------------
5+
0
66
(1 row)
77

8-
SELECTgist_stratnum_btree(3);
9-
gist_stratnum_btree
10-
---------------------
11-
3
8+
SELECTgist_translate_cmptype_btree(3);
9+
gist_translate_cmptype_btree
10+
------------------------------
11+
3
1212
(1 row)
1313

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
-- test stratnum support func
2-
SELECTgist_stratnum_btree(7);
3-
SELECTgist_stratnum_btree(3);
1+
-- test stratnumtranslationsupport func
2+
SELECTgist_translate_cmptype_btree(7);
3+
SELECTgist_translate_cmptype_btree(3);

‎doc/src/sgml/gist.sgml‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ my_sortsupport(PG_FUNCTION_ARGS)
11701170
</varlistentry>
11711171

11721172
<varlistentry>
1173-
<term><function>stratnum</function></term>
1173+
<term><function>translate_cmptype</function></term>
11741174
<listitem>
11751175
<para>
11761176
Given a <literal>CompareType</literal> value from
@@ -1188,12 +1188,23 @@ my_sortsupport(PG_FUNCTION_ARGS)
11881188
non-<literal>WITHOUT OVERLAPS</literal> part(s) of an index constraint.
11891189
</para>
11901190

1191+
<para>
1192+
This support function corresponds to the index access method callback
1193+
function <structfield>amtranslatecmptype</structfield> (see <xref
1194+
linkend="index-functions"/>). The
1195+
<structfield>amtranslatecmptype</structfield> callback function for
1196+
GiST indexes merely calls down to the
1197+
<function>translate_cmptype</function> support function of the
1198+
respective operator family, since the GiST index access method has no
1199+
fixed strategy numbers itself.
1200+
</para>
1201+
11911202
<para>
11921203
The <acronym>SQL</acronym> declaration of the function must look like
11931204
this:
11941205

11951206
<programlisting>
1196-
CREATE OR REPLACE FUNCTIONmy_stratnum(integer)
1207+
CREATE OR REPLACE FUNCTIONmy_translate_cmptype(integer)
11971208
RETURNS smallint
11981209
AS 'MODULE_PATHNAME'
11991210
LANGUAGE C STRICT;
@@ -1202,18 +1213,18 @@ LANGUAGE C STRICT;
12021213
And the operator family registration must look like this:
12031214
<programlisting>
12041215
ALTER OPERATOR FAMILY my_opfamily USING gist ADD
1205-
FUNCTION 12 ("any", "any")my_stratnum(int);
1216+
FUNCTION 12 ("any", "any")my_translate_cmptype(int);
12061217
</programlisting>
12071218
</para>
12081219

12091220
<para>
12101221
The matching code in the C module could then follow this skeleton:
12111222

12121223
<programlisting>
1213-
PG_FUNCTION_INFO_V1(my_stratnum);
1224+
PG_FUNCTION_INFO_V1(my_translate_cmptype);
12141225

12151226
Datum
1216-
my_stratnum(PG_FUNCTION_ARGS)
1227+
my_translate_cmptype(PG_FUNCTION_ARGS)
12171228
{
12181229
CompareType cmptype = PG_GETARG_INT32(0);
12191230
StrategyNumber ret = InvalidStrategy;
@@ -1232,11 +1243,11 @@ my_stratnum(PG_FUNCTION_ARGS)
12321243
<para>
12331244
One translation function is provided by
12341245
<productname>PostgreSQL</productname>:
1235-
<literal>gist_stratnum_common</literal> is for operator classes that
1246+
<literal>gist_translate_cmptype_common</literal> is for operator classes that
12361247
use the <literal>RT*StrategyNumber</literal> constants.
12371248
The <literal>btree_gist</literal>
12381249
extension defines a second translation function,
1239-
<literal>gist_stratnum_btree</literal>, for operator classes that use
1250+
<literal>gist_translate_cmptype_btree</literal>, for operator classes that use
12401251
the <literal>BT*StrategyNumber</literal> constants.
12411252
</para>
12421253
</listitem>

‎doc/src/sgml/xindex.sgml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@
598598
<entry>11</entry>
599599
</row>
600600
<row>
601-
<entry><function>stratnum</function></entry>
601+
<entry><function>translate_cmptype</function></entry>
602602
<entry>translate compare types to strategy numbers
603603
used by the operator class (optional)</entry>
604604
<entry>12</entry>

‎src/backend/access/gist/gistutil.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,11 +1058,11 @@ gistGetFakeLSN(Relation rel)
10581058
}
10591059

10601060
/*
1061-
* This is a stratnum support function for GiST opclasses that use the
1062-
* RT*StrategyNumber constants.
1061+
* This is a stratnumtranslationsupport function for GiST opclasses that use
1062+
*theRT*StrategyNumber constants.
10631063
*/
10641064
Datum
1065-
gist_stratnum_common(PG_FUNCTION_ARGS)
1065+
gist_translate_cmptype_common(PG_FUNCTION_ARGS)
10661066
{
10671067
CompareTypecmptype=PG_GETARG_INT32(0);
10681068

@@ -1090,9 +1090,9 @@ gist_stratnum_common(PG_FUNCTION_ARGS)
10901090
/*
10911091
* Returns the opclass's private stratnum used for the given compare type.
10921092
*
1093-
* Calls the opclass'sGIST_STRATNUM_PROC support function, if any,
1094-
* and returns the result.
1095-
*Returns InvalidStrategy if the function is notdefined.
1093+
* Calls the opclass'sGIST_TRANSLATE_CMPTYPE_PROC support function, if any,
1094+
* and returns the result. Returns InvalidStrategy if the function is not
1095+
* defined.
10961096
*/
10971097
StrategyNumber
10981098
gisttranslatecmptype(CompareTypecmptype,Oidopfamily)
@@ -1101,7 +1101,7 @@ gisttranslatecmptype(CompareType cmptype, Oid opfamily)
11011101
Datumresult;
11021102

11031103
/* Check whether the function is provided. */
1104-
funcid=get_opfamily_proc(opfamily,ANYOID,ANYOID,GIST_STRATNUM_PROC);
1104+
funcid=get_opfamily_proc(opfamily,ANYOID,ANYOID,GIST_TRANSLATE_CMPTYPE_PROC);
11051105
if (!OidIsValid(funcid))
11061106
returnInvalidStrategy;
11071107

‎src/backend/access/gist/gistvalidate.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ gistvalidate(Oid opclassoid)
138138
ok=check_amproc_signature(procform->amproc,VOIDOID, true,
139139
1,1,INTERNALOID);
140140
break;
141-
caseGIST_STRATNUM_PROC:
141+
caseGIST_TRANSLATE_CMPTYPE_PROC:
142142
ok=check_amproc_signature(procform->amproc,INT2OID, true,
143143
1,1,INT4OID)&&
144144
procform->amproclefttype==ANYOID&&
@@ -265,7 +265,7 @@ gistvalidate(Oid opclassoid)
265265
if (i==GIST_DISTANCE_PROC||i==GIST_FETCH_PROC||
266266
i==GIST_COMPRESS_PROC||i==GIST_DECOMPRESS_PROC||
267267
i==GIST_OPTIONS_PROC||i==GIST_SORTSUPPORT_PROC||
268-
i==GIST_STRATNUM_PROC)
268+
i==GIST_TRANSLATE_CMPTYPE_PROC)
269269
continue;/* optional methods */
270270
ereport(INFO,
271271
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -336,7 +336,7 @@ gistadjustmembers(Oid opfamilyoid,
336336
caseGIST_FETCH_PROC:
337337
caseGIST_OPTIONS_PROC:
338338
caseGIST_SORTSUPPORT_PROC:
339-
caseGIST_STRATNUM_PROC:
339+
caseGIST_TRANSLATE_CMPTYPE_PROC:
340340
/* Optional, so force it to be a soft family dependency */
341341
op->ref_is_hard= false;
342342
op->ref_is_family= true;

‎src/include/access/gist.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#defineGIST_FETCH_PROC9
4141
#defineGIST_OPTIONS_PROC10
4242
#defineGIST_SORTSUPPORT_PROC11
43-
#defineGIST_STRATNUM_PROC12
43+
#defineGIST_TRANSLATE_CMPTYPE_PROC12
4444
#defineGISTNProcs12
4545

4646
/*

‎src/include/catalog/catversion.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/*yyyymmddN */
60-
#defineCATALOG_VERSION_NO202505071
60+
#defineCATALOG_VERSION_NO202506021
6161

6262
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp