From 50ce2bca712e35b5a546cf9e9d55661d711aadb9 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 7 Feb 2025 15:48:43 +0100 Subject: [PATCH v19.4 1/2] Change gist stategy support procedure to take "any", "any" as argument --- contrib/btree_gist/btree_gist--1.7--1.8.sql | 52 ++++++++++----------- doc/src/sgml/gist.sgml | 6 +++ src/backend/access/gist/gistutil.c | 2 +- src/backend/access/gist/gistvalidate.c | 4 +- src/include/catalog/pg_amproc.dat | 24 +++++----- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/contrib/btree_gist/btree_gist--1.7--1.8.sql b/contrib/btree_gist/btree_gist--1.7--1.8.sql index c702426deab..4ff9c43a8eb 100644 --- a/contrib/btree_gist/btree_gist--1.7--1.8.sql +++ b/contrib/btree_gist/btree_gist--1.7--1.8.sql @@ -9,79 +9,79 @@ CREATE FUNCTION gist_stratnum_btree(int) LANGUAGE C IMMUTABLE PARALLEL SAFE STRICT; ALTER OPERATOR FAMILY gist_oid_ops USING gist ADD - FUNCTION 12 (oid, oid) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_int2_ops USING gist ADD - FUNCTION 12 (int2, int2) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_int4_ops USING gist ADD - FUNCTION 12 (int4, int4) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_int8_ops USING gist ADD - FUNCTION 12 (int8, int8) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_float4_ops USING gist ADD - FUNCTION 12 (float4, float4) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_float8_ops USING gist ADD - FUNCTION 12 (float8, float8) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_timestamp_ops USING gist ADD - FUNCTION 12 (timestamp, timestamp) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist ADD - FUNCTION 12 (timestamptz, timestamptz) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_time_ops USING gist ADD - FUNCTION 12 (time, time) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_date_ops USING gist ADD - FUNCTION 12 (date, date) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_interval_ops USING gist ADD - FUNCTION 12 (interval, interval) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_cash_ops USING gist ADD - FUNCTION 12 (money, money) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_macaddr_ops USING gist ADD - FUNCTION 12 (macaddr, macaddr) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_text_ops USING gist ADD - FUNCTION 12 (text, text) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_bpchar_ops USING gist ADD - FUNCTION 12 (bpchar, bpchar) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_bytea_ops USING gist ADD - FUNCTION 12 (bytea, bytea) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_numeric_ops USING gist ADD - FUNCTION 12 (numeric, numeric) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_bit_ops USING gist ADD - FUNCTION 12 (bit, bit) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_vbit_ops USING gist ADD - FUNCTION 12 (varbit, varbit) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_inet_ops USING gist ADD - FUNCTION 12 (inet, inet) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_cidr_ops USING gist ADD - FUNCTION 12 (cidr, cidr) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_timetz_ops USING gist ADD - FUNCTION 12 (timetz, timetz) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_uuid_ops USING gist ADD - FUNCTION 12 (uuid, uuid) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_macaddr8_ops USING gist ADD - FUNCTION 12 (macaddr8, macaddr8) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_enum_ops USING gist ADD - FUNCTION 12 (anyenum, anyenum) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; ALTER OPERATOR FAMILY gist_bool_ops USING gist ADD - FUNCTION 12 (bool, bool) gist_stratnum_btree (int) ; + FUNCTION 12 ("any", "any") gist_stratnum_btree (int) ; diff --git a/doc/src/sgml/gist.sgml b/doc/src/sgml/gist.sgml index 99098ab2522..9af5a4805f6 100644 --- a/doc/src/sgml/gist.sgml +++ b/doc/src/sgml/gist.sgml @@ -1197,6 +1197,12 @@ Extensibility RETURNS smallint AS 'MODULE_PATHNAME' LANGUAGE C STRICT; + + + And the operator family registration must look like this: + +ALTER OPERATOR FAMILY my_opfamily USING gist ADD + FUNCTION 12 ("any", "any") my_stratnum(int); diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index dbc4ac639a2..fef5876d7d8 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -1101,7 +1101,7 @@ gisttranslatecmptype(CompareType cmptype, Oid opfamily, Oid opcintype) Datum result; /* Check whether the function is provided. */ - funcid = get_opfamily_proc(opfamily, opcintype, opcintype, GIST_STRATNUM_PROC); + funcid = get_opfamily_proc(opfamily, ANYOID, ANYOID, GIST_STRATNUM_PROC); if (!OidIsValid(funcid)) return InvalidStrategy; diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c index ffefa12d97a..2a49e6d20f0 100644 --- a/src/backend/access/gist/gistvalidate.c +++ b/src/backend/access/gist/gistvalidate.c @@ -140,7 +140,9 @@ gistvalidate(Oid opclassoid) break; case GIST_STRATNUM_PROC: ok = check_amproc_signature(procform->amproc, INT2OID, true, - 1, 1, INT4OID); + 1, 1, INT4OID) && + procform->amproclefttype == ANYOID && + procform->amprocrighttype == ANYOID; break; default: ereport(INFO, diff --git a/src/include/catalog/pg_amproc.dat b/src/include/catalog/pg_amproc.dat index 508f48d345c..19100482ba4 100644 --- a/src/include/catalog/pg_amproc.dat +++ b/src/include/catalog/pg_amproc.dat @@ -506,8 +506,8 @@ amprocrighttype => 'box', amprocnum => '7', amproc => 'gist_box_same' }, { amprocfamily => 'gist/box_ops', amproclefttype => 'box', amprocrighttype => 'box', amprocnum => '8', amproc => 'gist_box_distance' }, -{ amprocfamily => 'gist/box_ops', amproclefttype => 'box', - amprocrighttype => 'box', amprocnum => '12', +{ amprocfamily => 'gist/box_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, { amprocfamily => 'gist/poly_ops', amproclefttype => 'polygon', amprocrighttype => 'polygon', amprocnum => '1', @@ -528,8 +528,8 @@ { amprocfamily => 'gist/poly_ops', amproclefttype => 'polygon', amprocrighttype => 'polygon', amprocnum => '8', amproc => 'gist_poly_distance' }, -{ amprocfamily => 'gist/poly_ops', amproclefttype => 'polygon', - amprocrighttype => 'polygon', amprocnum => '12', +{ amprocfamily => 'gist/poly_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, { amprocfamily => 'gist/circle_ops', amproclefttype => 'circle', amprocrighttype => 'circle', amprocnum => '1', @@ -549,8 +549,8 @@ { amprocfamily => 'gist/circle_ops', amproclefttype => 'circle', amprocrighttype => 'circle', amprocnum => '8', amproc => 'gist_circle_distance' }, -{ amprocfamily => 'gist/circle_ops', amproclefttype => 'circle', - amprocrighttype => 'circle', amprocnum => '12', +{ amprocfamily => 'gist/circle_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, { amprocfamily => 'gist/tsvector_ops', amproclefttype => 'tsvector', amprocrighttype => 'tsvector', amprocnum => '1', @@ -606,8 +606,8 @@ { amprocfamily => 'gist/range_ops', amproclefttype => 'anyrange', amprocrighttype => 'anyrange', amprocnum => '7', amproc => 'range_gist_same' }, -{ amprocfamily => 'gist/range_ops', amproclefttype => 'anyrange', - amprocrighttype => 'anyrange', amprocnum => '12', +{ amprocfamily => 'gist/range_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, { amprocfamily => 'gist/network_ops', amproclefttype => 'inet', amprocrighttype => 'inet', amprocnum => '1', @@ -625,8 +625,8 @@ amprocrighttype => 'inet', amprocnum => '7', amproc => 'inet_gist_same' }, { amprocfamily => 'gist/network_ops', amproclefttype => 'inet', amprocrighttype => 'inet', amprocnum => '9', amproc => 'inet_gist_fetch' }, -{ amprocfamily => 'gist/network_ops', amproclefttype => 'inet', - amprocrighttype => 'inet', amprocnum => '12', +{ amprocfamily => 'gist/network_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, { amprocfamily => 'gist/multirange_ops', amproclefttype => 'anymultirange', amprocrighttype => 'anymultirange', amprocnum => '1', @@ -646,8 +646,8 @@ { amprocfamily => 'gist/multirange_ops', amproclefttype => 'anymultirange', amprocrighttype => 'anymultirange', amprocnum => '7', amproc => 'range_gist_same' }, -{ amprocfamily => 'gist/multirange_ops', amproclefttype => 'anymultirange', - amprocrighttype => 'anymultirange', amprocnum => '12', +{ amprocfamily => 'gist/multirange_ops', amproclefttype => 'any', + amprocrighttype => 'any', amprocnum => '12', amproc => 'gist_stratnum_common' }, # gin -- 2.48.1