Commit 9ff60273 authored by Tom Lane's avatar Tom Lane

Fix assorted inconsistencies in GiST opclass support function declarations.

The conventions specified by the GiST SGML documentation were widely
ignored.  For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum.  None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures.  So let's try to instill
some consistency here.

Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types).  Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same.  So I've specified a convention
that that's what to do always.

Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that.  Standardize
on telling the truth, instead.

Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".

Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.

Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.

So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion.  Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
parent 53c949c1
This diff is collapsed.
......@@ -304,7 +304,7 @@ CREATE OPERATOR ~ (
-- define the GiST support methods
CREATE FUNCTION g_cube_consistent(internal,cube,int,oid,internal)
CREATE FUNCTION g_cube_consistent(internal,cube,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -339,8 +339,8 @@ RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION g_cube_distance (internal, cube, smallint, oid)
RETURNS internal
CREATE FUNCTION g_cube_distance (internal, cube, smallint, oid, internal)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -368,11 +368,11 @@ CREATE OPERATOR CLASS gist_cube_ops
OPERATOR 17 <-> (cube, cube) FOR ORDER BY float_ops,
OPERATOR 18 <=> (cube, cube) FOR ORDER BY float_ops,
FUNCTION 1 g_cube_consistent (internal, cube, int, oid, internal),
FUNCTION 1 g_cube_consistent (internal, cube, smallint, oid, internal),
FUNCTION 2 g_cube_union (internal, internal),
FUNCTION 3 g_cube_compress (internal),
FUNCTION 4 g_cube_decompress (internal),
FUNCTION 5 g_cube_penalty (internal, internal, internal),
FUNCTION 6 g_cube_picksplit (internal, internal),
FUNCTION 7 g_cube_same (cube, cube, internal),
FUNCTION 8 g_cube_distance (internal, cube, smallint, oid);
FUNCTION 8 g_cube_distance (internal, cube, smallint, oid, internal);
......@@ -486,16 +486,16 @@ AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ghstore_union(internal, internal)
RETURNS internal
RETURNS ghstore
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ghstore_same(internal, internal, internal)
CREATE FUNCTION ghstore_same(ghstore, ghstore, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ghstore_consistent(internal,internal,int,oid,internal)
CREATE FUNCTION ghstore_consistent(internal,hstore,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -510,13 +510,13 @@ AS
--OPERATOR 8 <@ ,
OPERATOR 13 @ ,
--OPERATOR 14 ~ ,
FUNCTION 1 ghstore_consistent (internal, internal, int, oid, internal),
FUNCTION 1 ghstore_consistent (internal, hstore, smallint, oid, internal),
FUNCTION 2 ghstore_union (internal, internal),
FUNCTION 3 ghstore_compress (internal),
FUNCTION 4 ghstore_decompress (internal),
FUNCTION 5 ghstore_penalty (internal, internal, internal),
FUNCTION 6 ghstore_picksplit (internal, internal),
FUNCTION 7 ghstore_same (internal, internal, internal),
FUNCTION 7 ghstore_same (ghstore, ghstore, internal),
STORAGE ghstore;
-- GIN support
......
......@@ -358,7 +358,7 @@ CREATE OPERATOR & (
--------------
-- define the GiST support methods
CREATE FUNCTION g_int_consistent(internal,_int4,int,oid,internal)
CREATE FUNCTION g_int_consistent(internal,_int4,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -405,7 +405,7 @@ DEFAULT FOR TYPE _int4 USING gist AS
OPERATOR 13 @,
OPERATOR 14 ~,
OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_int_consistent (internal, _int4, int, oid, internal),
FUNCTION 1 g_int_consistent (internal, _int4, smallint, oid, internal),
FUNCTION 2 g_int_union (internal, internal),
FUNCTION 3 g_int_compress (internal),
FUNCTION 4 g_int_decompress (internal),
......@@ -435,7 +435,7 @@ CREATE TYPE intbig_gkey (
OUTPUT = _intbig_out
);
CREATE FUNCTION g_intbig_consistent(internal,internal,int,oid,internal)
CREATE FUNCTION g_intbig_consistent(internal,_int4,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -461,11 +461,11 @@ AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION g_intbig_union(internal, internal)
RETURNS _int4
RETURNS intbig_gkey
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION g_intbig_same(internal, internal, internal)
CREATE FUNCTION g_intbig_same(intbig_gkey, intbig_gkey, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -482,13 +482,13 @@ AS
OPERATOR 13 @,
OPERATOR 14 ~,
OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_intbig_consistent (internal, internal, int, oid, internal),
FUNCTION 1 g_intbig_consistent (internal, _int4, smallint, oid, internal),
FUNCTION 2 g_intbig_union (internal, internal),
FUNCTION 3 g_intbig_compress (internal),
FUNCTION 4 g_intbig_decompress (internal),
FUNCTION 5 g_intbig_penalty (internal, internal, internal),
FUNCTION 6 g_intbig_picksplit (internal, internal),
FUNCTION 7 g_intbig_same (internal, internal, internal),
FUNCTION 7 g_intbig_same (intbig_gkey, intbig_gkey, internal),
STORAGE intbig_gkey;
--GIN
......
......@@ -496,7 +496,7 @@ CREATE TYPE ltree_gist (
);
CREATE FUNCTION ltree_consistent(internal,internal,int2,oid,internal)
CREATE FUNCTION ltree_consistent(internal,ltree,int2,oid,internal)
RETURNS bool as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ltree_compress(internal)
......@@ -512,9 +512,9 @@ CREATE FUNCTION ltree_picksplit(internal, internal)
RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ltree_union(internal, internal)
RETURNS int4 as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
RETURNS ltree_gist as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ltree_same(internal, internal, internal)
CREATE FUNCTION ltree_same(ltree_gist, ltree_gist, internal)
RETURNS internal as 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR CLASS gist_ltree_ops
......@@ -532,13 +532,13 @@ CREATE OPERATOR CLASS gist_ltree_ops
OPERATOR 15 @ (ltxtquery, ltree) ,
OPERATOR 16 ? (ltree, _lquery) ,
OPERATOR 17 ? (_lquery, ltree) ,
FUNCTION 1 ltree_consistent (internal, internal, int2, oid, internal),
FUNCTION 1 ltree_consistent (internal, ltree, int2, oid, internal),
FUNCTION 2 ltree_union (internal, internal),
FUNCTION 3 ltree_compress (internal),
FUNCTION 4 ltree_decompress (internal),
FUNCTION 5 ltree_penalty (internal, internal, internal),
FUNCTION 6 ltree_picksplit (internal, internal),
FUNCTION 7 ltree_same (internal, internal, internal),
FUNCTION 7 ltree_same (ltree_gist, ltree_gist, internal),
STORAGE ltree_gist;
......@@ -822,7 +822,7 @@ CREATE OPERATOR ?@ (
);
--GiST support for ltree[]
CREATE FUNCTION _ltree_consistent(internal,internal,int2,oid,internal)
CREATE FUNCTION _ltree_consistent(internal,_ltree,int2,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -843,11 +843,11 @@ AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION _ltree_union(internal, internal)
RETURNS int4
RETURNS ltree_gist
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION _ltree_same(internal, internal, internal)
CREATE FUNCTION _ltree_same(ltree_gist, ltree_gist, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -862,11 +862,11 @@ CREATE OPERATOR CLASS gist__ltree_ops
OPERATOR 15 @ (ltxtquery, _ltree),
OPERATOR 16 ? (_ltree, _lquery),
OPERATOR 17 ? (_lquery, _ltree),
FUNCTION 1 _ltree_consistent (internal, internal, int2, oid, internal),
FUNCTION 1 _ltree_consistent (internal, _ltree, int2, oid, internal),
FUNCTION 2 _ltree_union (internal, internal),
FUNCTION 3 _ltree_compress (internal),
FUNCTION 4 ltree_decompress (internal),
FUNCTION 5 _ltree_penalty (internal, internal, internal),
FUNCTION 6 _ltree_picksplit (internal, internal),
FUNCTION 7 _ltree_same (internal, internal, internal),
FUNCTION 7 _ltree_same (ltree_gist, ltree_gist, internal),
STORAGE ltree_gist;
......@@ -67,12 +67,12 @@ CREATE TYPE gtrgm (
);
-- support functions for gist
CREATE FUNCTION gtrgm_consistent(internal,text,int,oid,internal)
CREATE FUNCTION gtrgm_consistent(internal,text,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION gtrgm_distance(internal,text,int,oid)
CREATE FUNCTION gtrgm_distance(internal,text,smallint,oid,internal)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -97,8 +97,8 @@ RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION gtrgm_union(bytea, internal)
RETURNS _int4
CREATE FUNCTION gtrgm_union(internal, internal)
RETURNS gtrgm
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -112,8 +112,8 @@ CREATE OPERATOR CLASS gist_trgm_ops
FOR TYPE text USING gist
AS
OPERATOR 1 % (text, text),
FUNCTION 1 gtrgm_consistent (internal, text, int, oid, internal),
FUNCTION 2 gtrgm_union (bytea, internal),
FUNCTION 1 gtrgm_consistent (internal, text, smallint, oid, internal),
FUNCTION 2 gtrgm_union (internal, internal),
FUNCTION 3 gtrgm_compress (internal),
FUNCTION 4 gtrgm_decompress (internal),
FUNCTION 5 gtrgm_penalty (internal, internal, internal),
......@@ -130,7 +130,7 @@ ALTER OPERATOR FAMILY gist_trgm_ops USING gist ADD
OPERATOR 2 <-> (text, text) FOR ORDER BY pg_catalog.float_ops,
OPERATOR 3 pg_catalog.~~ (text, text),
OPERATOR 4 pg_catalog.~~* (text, text),
FUNCTION 8 (text, text) gtrgm_distance (internal, text, int, oid);
FUNCTION 8 (text, text) gtrgm_distance (internal, text, smallint, oid, internal);
-- Add operators that are new in 9.3.
......
......@@ -326,7 +326,7 @@ CREATE OPERATOR ~ (
-- define the GiST support methods
CREATE FUNCTION gseg_consistent(internal,seg,int,oid,internal)
CREATE FUNCTION gseg_consistent(internal,seg,smallint,oid,internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
......@@ -386,7 +386,7 @@ AS
OPERATOR 8 <@ ,
OPERATOR 13 @ ,
OPERATOR 14 ~ ,
FUNCTION 1 gseg_consistent (internal, seg, int, oid, internal),
FUNCTION 1 gseg_consistent (internal, seg, smallint, oid, internal),
FUNCTION 2 gseg_union (internal, internal),
FUNCTION 3 gseg_compress (internal),
FUNCTION 4 gseg_decompress (internal),
......
......@@ -389,7 +389,7 @@ CREATE OPERATOR CLASS gist_tsvector_ops
FOR TYPE tsvector USING gist
AS
OPERATOR 1 @@ (tsvector, tsquery),
FUNCTION 1 gtsvector_consistent (internal, gtsvector, int, oid, internal),
FUNCTION 1 gtsvector_consistent (internal, tsvector, smallint, oid, internal),
FUNCTION 2 gtsvector_union (internal, internal),
FUNCTION 3 gtsvector_compress (internal),
FUNCTION 4 gtsvector_decompress (internal),
......@@ -536,7 +536,7 @@ FOR TYPE tsquery USING gist
AS
OPERATOR 7 @> (tsquery, tsquery),
OPERATOR 8 <@ (tsquery, tsquery),
FUNCTION 1 gtsquery_consistent (internal, internal, int, oid, internal),
FUNCTION 1 gtsquery_consistent (internal, tsquery, smallint, oid, internal),
FUNCTION 2 gtsquery_union (internal, internal),
FUNCTION 3 gtsquery_compress (internal),
FUNCTION 4 gtsquery_decompress (internal),
......
......@@ -359,9 +359,20 @@ my_consistent(PG_FUNCTION_ARGS)
the value being looked up in the index. The <literal>StrategyNumber</>
parameter indicates which operator of your operator class is being
applied &mdash; it matches one of the operator numbers in the
<command>CREATE OPERATOR CLASS</> command. Depending on what operators
you have included in the class, the data type of <varname>query</> could
vary with the operator, but the above skeleton assumes it doesn't.
<command>CREATE OPERATOR CLASS</> command.
</para>
<para>
Depending on which operators you have included in the class, the data
type of <varname>query</> could vary with the operator, since it will
be whatever type is on the righthand side of the operator, which might
be different from the indexed data type appearing on the lefthand side.
(The above code skeleton assumes that only one type is possible; if
not, fetching the <varname>query</> argument value would have to depend
on the operator.) It is recommended that the SQL declaration of
the <function>consistent</> function use the opclass's indexed data
type for the <varname>query</> argument, even though the actual type
might be something else depending on the operator.
</para>
</listitem>
......@@ -381,7 +392,7 @@ my_consistent(PG_FUNCTION_ARGS)
<programlisting>
CREATE OR REPLACE FUNCTION my_union(internal, internal)
RETURNS internal
RETURNS storage_type
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
</programlisting>
......@@ -434,9 +445,21 @@ my_union(PG_FUNCTION_ARGS)
</para>
<para>
The <function>union</> implementation function should return a
pointer to newly <function>palloc()</>ed memory. You can't just
return whatever the input is.
The result of the <function>union</> function must be a value of the
index's storage type, whatever that is (it might or might not be
different from the indexed column's type). The <function>union</>
function should return a pointer to newly <function>palloc()</>ed
memory. You can't just return the input value as-is, even if there is
no type change.
</para>
<para>
As shown above, the <function>union</> function's
first <type>internal</> argument is actually
a <structname>GistEntryVector</> pointer. The second argument is a
pointer to an integer variable, which can be ignored. (It used to be
required that the <function>union</> function store the size of its
result value into that variable, but this is no longer necessary.)
</para>
</listitem>
</varlistentry>
......@@ -576,6 +599,12 @@ my_penalty(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(penalty);
}
</programlisting>
For historical reasons, the <function>penalty</> function doesn't
just return a <type>float</> result; instead it has to store the value
at the location indicated by the third argument. The return
value per se is ignored, though it's conventional to pass back the
address of that argument.
</para>
<para>
......@@ -615,9 +644,9 @@ Datum
my_picksplit(PG_FUNCTION_ARGS)
{
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
OffsetNumber maxoff = entryvec-&gt;n - 1;
GISTENTRY *ent = entryvec-&gt;vector;
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
int i,
nbytes;
OffsetNumber *left,
......@@ -683,6 +712,11 @@ my_picksplit(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(v);
}
</programlisting>
Notice that the <function>picksplit</> function's result is delivered
by modifying the passed-in <structname>v</> structure. The return
value per se is ignored, though it's conventional to pass back the
address of <structname>v</>.
</para>
<para>
......@@ -700,13 +734,15 @@ my_picksplit(PG_FUNCTION_ARGS)
<listitem>
<para>
Returns true if two index entries are identical, false otherwise.
(An <quote>index entry</> is a value of the index's storage type,
not necessarily the original indexed column's type.)
</para>
<para>
The <acronym>SQL</> declaration of the function must look like this:
<programlisting>
CREATE OR REPLACE FUNCTION my_same(internal, internal, internal)
CREATE OR REPLACE FUNCTION my_same(storage_type, storage_type, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
......@@ -731,7 +767,9 @@ my_same(PG_FUNCTION_ARGS)
For historical reasons, the <function>same</> function doesn't
just return a Boolean result; instead it has to store the flag
at the location indicated by the third argument.
at the location indicated by the third argument. The return
value per se is ignored, though it's conventional to pass back the
address of that argument.
</para>
</listitem>
</varlistentry>
......@@ -756,7 +794,7 @@ my_same(PG_FUNCTION_ARGS)
The <acronym>SQL</> declaration of the function must look like this:
<programlisting>
CREATE OR REPLACE FUNCTION my_distance(internal, data_type, smallint, oid)
CREATE OR REPLACE FUNCTION my_distance(internal, data_type, smallint, oid, internal)
RETURNS float8
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
......@@ -824,7 +862,7 @@ my_distance(PG_FUNCTION_ARGS)
<term><function>fetch</></term>
<listitem>
<para>
Converts the compressed index representation of the data item into the
Converts the compressed index representation of a data item into the
original data type, for index-only scans. The returned data must be an
exact, non-lossy copy of the originally indexed value.
</para>
......@@ -840,11 +878,12 @@ LANGUAGE C STRICT;
</programlisting>
The argument is a pointer to a <structname>GISTENTRY</> struct. On
entry, its 'key' field contains a non-NULL leaf datum in its
entry, its <structfield>key</> field contains a non-NULL leaf datum in
compressed form. The return value is another <structname>GISTENTRY</>
struct, whose 'key' field contains the same datum in the original,
uncompressed form. If the opclass' compress function does nothing for
leaf entries, the fetch method can return the argument as is.
struct, whose <structfield>key</> field contains the same datum in its
original, uncompressed form. If the opclass's compress function does
nothing for leaf entries, the <function>fetch</> method can return the
argument as-is.
</para>
<para>
......@@ -879,8 +918,8 @@ my_fetch(PG_FUNCTION_ARGS)
<para>
If the compress method is lossy for leaf entries, the operator class
cannot support index-only scans, and must not define a 'fetch'
function.
cannot support index-only scans, and must not define
a <function>fetch</> function.
</para>
</listitem>
......
......@@ -289,7 +289,7 @@ CREATE OPERATOR CLASS gist__int_ops
OPERATOR 7 @&gt;,
OPERATOR 8 &lt;@,
OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_int_consistent (internal, _int4, int, oid, internal),
FUNCTION 1 g_int_consistent (internal, _int4, smallint, oid, internal),
FUNCTION 2 g_int_union (internal, internal),
FUNCTION 3 g_int_compress (internal),
FUNCTION 4 g_int_decompress (internal),
......
......@@ -217,7 +217,7 @@ gistindex_keytest(IndexScanDesc scan,
key->sk_collation,
PointerGetDatum(&de),
key->sk_argument,
Int32GetDatum(key->sk_strategy),
Int16GetDatum(key->sk_strategy),
ObjectIdGetDatum(key->sk_subtype),
PointerGetDatum(&recheck));
......@@ -280,7 +280,7 @@ gistindex_keytest(IndexScanDesc scan,
key->sk_collation,
PointerGetDatum(&de),
key->sk_argument,
Int32GetDatum(key->sk_strategy),
Int16GetDatum(key->sk_strategy),
ObjectIdGetDatum(key->sk_subtype),
PointerGetDatum(&recheck));
*recheck_distances_p |= recheck;
......
......@@ -1489,12 +1489,10 @@ gist_point_distance(PG_FUNCTION_ARGS)
* This is a lower bound estimate of distance from point to indexed geometric
* type.
*/
Datum
gist_bbox_distance(PG_FUNCTION_ARGS)
static double
gist_bbox_distance(GISTENTRY *entry, Datum query,
StrategyNumber strategy, bool *recheck)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
bool *recheck = (bool *) PG_GETARG_POINTER(4);
double distance;
StrategyNumber strategyGroup = strategy / GeoStrategyNumberOffset;
......@@ -1506,12 +1504,44 @@ gist_bbox_distance(PG_FUNCTION_ARGS)
case PointStrategyNumberGroup:
distance = computeDistance(false,
DatumGetBoxP(entry->key),
PG_GETARG_POINT_P(1));
DatumGetPointP(query));
break;
default:
elog(ERROR, "unknown strategy number: %d", strategy);
elog(ERROR, "unrecognized strategy number: %d", strategy);
distance = 0.0; /* keep compiler quiet */
}
return distance;
}
Datum
gist_circle_distance(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
Datum query = PG_GETARG_DATUM(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4);
double distance;
distance = gist_bbox_distance(entry, query, strategy, recheck);
PG_RETURN_FLOAT8(distance);
}
Datum
gist_poly_distance(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
Datum query = PG_GETARG_DATUM(1);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4);
double distance;
distance = gist_bbox_distance(entry, query, strategy, recheck);
PG_RETURN_FLOAT8(distance);
}
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201601171
#define CATALOG_VERSION_NO 201601191
#endif
......@@ -217,7 +217,7 @@ DATA(insert ( 2595 718 718 4 2580 ));
DATA(insert ( 2595 718 718 5 2581 ));
DATA(insert ( 2595 718 718 6 2582 ));
DATA(insert ( 2595 718 718 7 2584 ));
DATA(insert ( 2595 718 718 8 3288 ));
DATA(insert ( 2595 718 718 8 3280 ));
DATA(insert ( 3655 3614 3614 1 3654 ));
DATA(insert ( 3655 3614 3614 2 3651 ));
DATA(insert ( 3655 3614 3614 3 3648 ));
......
This diff is collapsed.
......@@ -417,12 +417,13 @@ extern Datum gist_box_same(PG_FUNCTION_ARGS);
extern Datum gist_box_fetch(PG_FUNCTION_ARGS);
extern Datum gist_poly_compress(PG_FUNCTION_ARGS);
extern Datum gist_poly_consistent(PG_FUNCTION_ARGS);
extern Datum gist_poly_distance(PG_FUNCTION_ARGS);
extern Datum gist_circle_compress(PG_FUNCTION_ARGS);
extern Datum gist_circle_consistent(PG_FUNCTION_ARGS);
extern Datum gist_circle_distance(PG_FUNCTION_ARGS);
extern Datum gist_point_compress(PG_FUNCTION_ARGS);
extern Datum gist_point_consistent(PG_FUNCTION_ARGS);
extern Datum gist_point_distance(PG_FUNCTION_ARGS);
extern Datum gist_bbox_distance(PG_FUNCTION_ARGS);
extern Datum gist_point_fetch(PG_FUNCTION_ARGS);
......
......@@ -291,8 +291,8 @@ WHERE p1.prorettype = 'internal'::regtype AND NOT
-- Look for functions that return a polymorphic type and do not have any
-- polymorphic argument. Calls of such functions would be unresolvable
-- at parse time. As of 9.6 this query should find only some input functions
-- and GiST support functions associated with these pseudotypes.
SELECT p1.oid, p1.proname
FROM pg_proc as p1
WHERE p1.prorettype IN
......@@ -305,8 +305,8 @@ WHERE p1.prorettype IN
'anyenum'::regtype = ANY (p1.proargtypes) OR
'anyrange'::regtype = ANY (p1.proargtypes))
ORDER BY 2;
oid | proname
------+----------------
oid | proname
------+------------------
2296 | anyarray_in
2502 | anyarray_recv
2312 | anyelement_in
......@@ -317,9 +317,10 @@ ORDER BY 2;
2400 | array_recv
3506 | enum_in
3532 | enum_recv
3876 | range_gist_union
3834 | range_in
3836 | range_recv
(12 rows)
(13 rows)
-- Look for functions that accept cstring and are neither datatype input
-- functions nor encoding conversion functions. It's almost never a good
......
......@@ -237,8 +237,8 @@ WHERE p1.prorettype = 'internal'::regtype AND NOT
-- Look for functions that return a polymorphic type and do not have any
-- polymorphic argument. Calls of such functions would be unresolvable
-- at parse time. As of 9.6 this query should find only some input functions
-- and GiST support functions associated with these pseudotypes.
SELECT p1.oid, p1.proname
FROM pg_proc as p1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment