2016-06-10 04:44:25 +08:00
|
|
|
/* contrib/seg/seg--1.1.sql */
|
2002-07-31 01:34:37 +08:00
|
|
|
|
2011-10-13 03:45:03 +08:00
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
|
|
\echo Use "CREATE EXTENSION seg" to load this file. \quit
|
|
|
|
|
2007-11-11 11:25:35 +08:00
|
|
|
-- Create the user-defined type for 1-D floating point intervals (seg)
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_in(cstring)
|
2002-08-22 08:01:51 +08:00
|
|
|
RETURNS seg
|
2000-12-12 04:40:33 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_out(seg)
|
2002-08-22 08:01:51 +08:00
|
|
|
RETURNS cstring
|
2000-12-12 04:40:33 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
CREATE TYPE seg (
|
2002-10-19 02:41:22 +08:00
|
|
|
INTERNALLENGTH = 12,
|
|
|
|
INPUT = seg_in,
|
|
|
|
OUTPUT = seg_out
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
COMMENT ON TYPE seg IS
|
|
|
|
'floating point interval ''FLOAT .. FLOAT'', ''.. FLOAT'', ''FLOAT ..'' or ''FLOAT''';
|
|
|
|
|
|
|
|
--
|
|
|
|
-- External C-functions for R-tree methods
|
|
|
|
--
|
|
|
|
|
|
|
|
-- Left/Right methods
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_over_left(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_over_left(seg, seg) IS
|
2005-06-27 08:48:07 +08:00
|
|
|
'overlaps or is left of';
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_over_right(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_over_right(seg, seg) IS
|
2005-06-27 08:48:07 +08:00
|
|
|
'overlaps or is right of';
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_left(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_left(seg, seg) IS
|
|
|
|
'is left of';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_right(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_right(seg, seg) IS
|
|
|
|
'is right of';
|
|
|
|
|
|
|
|
|
2005-06-27 08:48:07 +08:00
|
|
|
-- Scalar comparison methods
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_lt(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_lt(seg, seg) IS
|
|
|
|
'less than';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_le(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_le(seg, seg) IS
|
|
|
|
'less than or equal';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_gt(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_gt(seg, seg) IS
|
|
|
|
'greater than';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_ge(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_ge(seg, seg) IS
|
|
|
|
'greater than or equal';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_contains(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_contains(seg, seg) IS
|
|
|
|
'contains';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_contained(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_contained(seg, seg) IS
|
|
|
|
'contained in';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_overlap(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_overlap(seg, seg) IS
|
|
|
|
'overlaps';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_same(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_same(seg, seg) IS
|
|
|
|
'same as';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_different(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_different(seg, seg) IS
|
|
|
|
'different';
|
|
|
|
|
|
|
|
-- support routines for indexing
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_cmp(seg, seg)
|
2003-09-14 10:18:49 +08:00
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2003-09-14 10:18:49 +08:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION seg_cmp(seg, seg) IS 'btree comparison function';
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_union(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS seg
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_inter(seg, seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS seg
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_size(seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
-- miscellaneous
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_center(seg)
|
2008-04-19 02:43:09 +08:00
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2008-04-19 02:43:09 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_upper(seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION seg_lower(seg)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- OPERATORS
|
|
|
|
--
|
|
|
|
|
|
|
|
CREATE OPERATOR < (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_lt,
|
|
|
|
COMMUTATOR = '>',
|
|
|
|
NEGATOR = '>=',
|
|
|
|
RESTRICT = scalarltsel,
|
|
|
|
JOIN = scalarltjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <= (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_le,
|
|
|
|
COMMUTATOR = '>=',
|
|
|
|
NEGATOR = '>',
|
|
|
|
RESTRICT = scalarltsel,
|
|
|
|
JOIN = scalarltjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR > (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_gt,
|
|
|
|
COMMUTATOR = '<',
|
|
|
|
NEGATOR = '<=',
|
|
|
|
RESTRICT = scalargtsel,
|
|
|
|
JOIN = scalargtjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR >= (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_ge,
|
|
|
|
COMMUTATOR = '<=',
|
|
|
|
NEGATOR = '<',
|
|
|
|
RESTRICT = scalargtsel,
|
|
|
|
JOIN = scalargtjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR << (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_left,
|
|
|
|
COMMUTATOR = '>>',
|
|
|
|
RESTRICT = positionsel,
|
|
|
|
JOIN = positionjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR &< (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_over_left,
|
|
|
|
RESTRICT = positionsel,
|
|
|
|
JOIN = positionjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR && (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_overlap,
|
|
|
|
COMMUTATOR = '&&',
|
2005-06-27 08:48:07 +08:00
|
|
|
RESTRICT = areasel,
|
|
|
|
JOIN = areajoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR &> (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_over_right,
|
|
|
|
RESTRICT = positionsel,
|
|
|
|
JOIN = positionjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR >> (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_right,
|
|
|
|
COMMUTATOR = '<<',
|
|
|
|
RESTRICT = positionsel,
|
|
|
|
JOIN = positionjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR = (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_same,
|
|
|
|
COMMUTATOR = '=',
|
|
|
|
NEGATOR = '<>',
|
|
|
|
RESTRICT = eqsel,
|
|
|
|
JOIN = eqjoinsel,
|
2003-09-14 10:18:49 +08:00
|
|
|
MERGES
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <> (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_different,
|
|
|
|
COMMUTATOR = '<>',
|
|
|
|
NEGATOR = '=',
|
|
|
|
RESTRICT = neqsel,
|
|
|
|
JOIN = neqjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
2006-09-11 01:36:52 +08:00
|
|
|
CREATE OPERATOR @> (
|
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_contains,
|
|
|
|
COMMUTATOR = '<@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <@ (
|
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_contained,
|
|
|
|
COMMUTATOR = '@>',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
-- obsolete:
|
2000-12-12 04:40:33 +08:00
|
|
|
CREATE OPERATOR @ (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_contains,
|
|
|
|
COMMUTATOR = '~',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~ (
|
2002-10-19 02:41:22 +08:00
|
|
|
LEFTARG = seg,
|
|
|
|
RIGHTARG = seg,
|
|
|
|
PROCEDURE = seg_contained,
|
|
|
|
COMMUTATOR = '@',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
2000-12-12 04:40:33 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- define the GiST support methods
|
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.
2016-01-20 01:04:32 +08:00
|
|
|
CREATE FUNCTION gseg_consistent(internal,seg,smallint,oid,internal)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_compress(internal)
|
2010-11-24 04:27:50 +08:00
|
|
|
RETURNS internal
|
2002-10-19 02:41:22 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_decompress(internal)
|
2010-11-24 04:27:50 +08:00
|
|
|
RETURNS internal
|
2002-10-19 02:41:22 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_penalty(internal,internal,internal)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_picksplit(internal, internal)
|
2002-10-19 02:41:22 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_union(internal, internal)
|
2010-11-24 04:27:50 +08:00
|
|
|
RETURNS seg
|
2002-10-19 02:41:22 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gseg_same(seg, seg, internal)
|
2010-11-24 04:27:50 +08:00
|
|
|
RETURNS internal
|
2002-10-19 02:41:22 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-15 01:34:37 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-12 04:40:33 +08:00
|
|
|
|
|
|
|
|
2003-09-14 10:18:49 +08:00
|
|
|
-- Create the operator classes for indexing
|
|
|
|
|
|
|
|
CREATE OPERATOR CLASS seg_ops
|
|
|
|
DEFAULT FOR TYPE seg USING btree AS
|
|
|
|
OPERATOR 1 < ,
|
|
|
|
OPERATOR 2 <= ,
|
|
|
|
OPERATOR 3 = ,
|
|
|
|
OPERATOR 4 >= ,
|
|
|
|
OPERATOR 5 > ,
|
|
|
|
FUNCTION 1 seg_cmp(seg, seg);
|
2002-07-31 01:34:37 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR CLASS gist_seg_ops
|
2010-11-24 04:27:50 +08:00
|
|
|
DEFAULT FOR TYPE seg USING gist
|
2002-10-19 02:41:22 +08:00
|
|
|
AS
|
2002-07-31 01:34:37 +08:00
|
|
|
OPERATOR 1 << ,
|
|
|
|
OPERATOR 2 &< ,
|
|
|
|
OPERATOR 3 && ,
|
|
|
|
OPERATOR 4 &> ,
|
|
|
|
OPERATOR 5 >> ,
|
|
|
|
OPERATOR 6 = ,
|
2006-09-11 01:36:52 +08:00
|
|
|
OPERATOR 7 @> ,
|
|
|
|
OPERATOR 8 <@ ,
|
|
|
|
OPERATOR 13 @ ,
|
|
|
|
OPERATOR 14 ~ ,
|
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.
2016-01-20 01:04:32 +08:00
|
|
|
FUNCTION 1 gseg_consistent (internal, seg, smallint, oid, internal),
|
2004-03-30 23:45:33 +08:00
|
|
|
FUNCTION 2 gseg_union (internal, internal),
|
2002-08-22 08:01:51 +08:00
|
|
|
FUNCTION 3 gseg_compress (internal),
|
|
|
|
FUNCTION 4 gseg_decompress (internal),
|
|
|
|
FUNCTION 5 gseg_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gseg_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gseg_same (seg, seg, internal);
|