2016-06-09 23:44:25 +03:00
|
|
|
/* contrib/cube/cube--1.2.sql */
|
2002-07-30 21:34:37 +04:00
|
|
|
|
2011-10-12 23:45:03 +04:00
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
|
|
\echo Use "CREATE EXTENSION cube" to load this file. \quit
|
|
|
|
|
2007-11-11 06:25:35 +03:00
|
|
|
-- Create the user-defined type for N-dimensional boxes
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_in(cstring)
|
2002-08-22 04:01:51 +04:00
|
|
|
RETURNS cube
|
2000-12-11 23:39:15 +03:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(float8[], float8[]) RETURNS cube
|
2006-07-26 03:23:45 +04:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_a_f8_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2006-07-26 03:23:45 +04:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(float8[]) RETURNS cube
|
2006-07-26 03:23:45 +04:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_a_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2006-07-26 03:23:45 +04:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_out(cube)
|
2002-08-22 04:01:51 +04:00
|
|
|
RETURNS cstring
|
2000-12-11 23:39:15 +03:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
|
|
|
CREATE TYPE cube (
|
2002-10-18 22:41:22 +04:00
|
|
|
INTERNALLENGTH = variable,
|
|
|
|
INPUT = cube_in,
|
2005-06-27 05:19:43 +04:00
|
|
|
OUTPUT = cube_out,
|
|
|
|
ALIGNMENT = double
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
COMMENT ON TYPE cube IS 'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
|
|
|
--
|
|
|
|
-- External C-functions for R-tree methods
|
|
|
|
--
|
|
|
|
|
|
|
|
-- Comparison methods
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_eq(cube, cube)
|
2003-09-14 05:52:25 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-09-14 05:52:25 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION cube_eq(cube, cube) IS 'same as';
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_ne(cube, cube)
|
2003-09-14 05:52:25 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-09-14 05:52:25 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION cube_ne(cube, cube) IS 'different';
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_lt(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
COMMENT ON FUNCTION cube_lt(cube, cube) IS 'lower than';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_gt(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2002-10-18 22:41:22 +04:00
|
|
|
COMMENT ON FUNCTION cube_gt(cube, cube) IS 'greater than';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_le(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMENT ON FUNCTION cube_le(cube, cube) IS 'lower than or equal to';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_ge(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMENT ON FUNCTION cube_ge(cube, cube) IS 'greater than or equal to';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_cmp(cube, cube)
|
2003-09-14 05:52:25 +04:00
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-09-14 05:52:25 +04:00
|
|
|
|
|
|
|
COMMENT ON FUNCTION cube_cmp(cube, cube) IS 'btree comparison function';
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_contains(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMENT ON FUNCTION cube_contains(cube, cube) IS 'contains';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_contained(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMENT ON FUNCTION cube_contained(cube, cube) IS 'contained in';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_overlap(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMENT ON FUNCTION cube_overlap(cube, cube) IS 'overlaps';
|
2000-12-11 23:39:15 +03:00
|
|
|
|
|
|
|
-- support routines for indexing
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_union(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS cube
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_inter(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS cube
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_size(cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
-- Misc N-dimensional functions
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_subset(cube, int4[])
|
2006-07-26 03:23:45 +04:00
|
|
|
RETURNS cube
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2006-07-26 03:23:45 +04:00
|
|
|
|
2000-12-11 23:39:15 +03:00
|
|
|
-- proximity routines
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_distance(cube, cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2002-08-30 03:03:58 +04:00
|
|
|
|
2015-12-18 14:38:27 +03:00
|
|
|
CREATE FUNCTION distance_chebyshev(cube, cube)
|
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2015-12-18 14:38:27 +03:00
|
|
|
|
|
|
|
CREATE FUNCTION distance_taxicab(cube, cube)
|
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2015-12-18 14:38:27 +03:00
|
|
|
|
2002-08-30 03:03:58 +04:00
|
|
|
-- Extracting elements functions
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_dim(cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS int4
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2002-08-30 03:03:58 +04:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_ll_coord(cube, int4)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2002-08-30 03:03:58 +04:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_ur_coord(cube, int4)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2002-08-30 03:03:58 +04:00
|
|
|
|
2015-12-18 14:38:27 +03:00
|
|
|
CREATE FUNCTION cube_coord(cube, int4)
|
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2015-12-18 14:38:27 +03:00
|
|
|
|
|
|
|
CREATE FUNCTION cube_coord_llur(cube, int4)
|
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2015-12-18 14:38:27 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(float8) RETURNS cube
|
2003-02-13 08:26:50 +03:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-02-13 08:26:50 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(float8, float8) RETURNS cube
|
2003-02-13 08:26:50 +03:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_f8_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-02-13 08:26:50 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(cube, float8) RETURNS cube
|
2003-02-13 08:26:50 +03:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_c_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-02-13 08:26:50 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube(cube, float8, float8) RETURNS cube
|
2003-02-13 08:26:50 +03:00
|
|
|
AS 'MODULE_PATHNAME', 'cube_c_f8_f8'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2003-02-13 08:26:50 +03:00
|
|
|
|
2002-08-30 03:03:58 +04:00
|
|
|
-- Test if cube is also a point
|
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_is_point(cube)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2002-08-30 03:03:58 +04:00
|
|
|
|
|
|
|
-- Increasing the size of a cube by a radius in at least n dimensions
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION cube_enlarge(cube, float8, int4)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS cube
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
|
|
|
--
|
|
|
|
-- OPERATORS
|
|
|
|
--
|
|
|
|
|
|
|
|
CREATE OPERATOR < (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_lt,
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMUTATOR = '>', NEGATOR = '>=',
|
2002-10-18 22:41:22 +04:00
|
|
|
RESTRICT = scalarltsel, JOIN = scalarltjoinsel
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR > (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_gt,
|
2003-09-14 05:52:25 +04:00
|
|
|
COMMUTATOR = '<', NEGATOR = '<=',
|
|
|
|
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <= (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_le,
|
|
|
|
COMMUTATOR = '>=', NEGATOR = '>',
|
|
|
|
RESTRICT = scalarltsel, JOIN = scalarltjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR >= (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_ge,
|
|
|
|
COMMUTATOR = '<=', NEGATOR = '<',
|
2002-10-18 22:41:22 +04:00
|
|
|
RESTRICT = scalargtsel, JOIN = scalargtjoinsel
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR && (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_overlap,
|
|
|
|
COMMUTATOR = '&&',
|
2005-06-27 05:19:43 +04:00
|
|
|
RESTRICT = areasel, JOIN = areajoinsel
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR = (
|
2003-09-14 05:52:25 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_eq,
|
2002-10-18 22:41:22 +04:00
|
|
|
COMMUTATOR = '=', NEGATOR = '<>',
|
|
|
|
RESTRICT = eqsel, JOIN = eqjoinsel,
|
2003-09-14 05:52:25 +04:00
|
|
|
MERGES
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <> (
|
2003-09-14 05:52:25 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_ne,
|
2002-10-18 22:41:22 +04:00
|
|
|
COMMUTATOR = '<>', NEGATOR = '=',
|
|
|
|
RESTRICT = neqsel, JOIN = neqjoinsel
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
2006-09-10 21:36:52 +04:00
|
|
|
CREATE OPERATOR @> (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
|
|
|
|
COMMUTATOR = '<@',
|
|
|
|
RESTRICT = contsel, JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <@ (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contained,
|
|
|
|
COMMUTATOR = '@>',
|
|
|
|
RESTRICT = contsel, JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2015-12-18 14:38:27 +03:00
|
|
|
CREATE OPERATOR -> (
|
|
|
|
LEFTARG = cube, RIGHTARG = int, PROCEDURE = cube_coord
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~> (
|
|
|
|
LEFTARG = cube, RIGHTARG = int, PROCEDURE = cube_coord_llur
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <#> (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = distance_taxicab,
|
|
|
|
COMMUTATOR = '<#>'
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <-> (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_distance,
|
|
|
|
COMMUTATOR = '<->'
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <=> (
|
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = distance_chebyshev,
|
|
|
|
COMMUTATOR = '<=>'
|
|
|
|
);
|
|
|
|
|
2006-09-10 21:36:52 +04:00
|
|
|
-- these are obsolete/deprecated:
|
2000-12-11 23:39:15 +03:00
|
|
|
CREATE OPERATOR @ (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
|
|
|
|
COMMUTATOR = '~',
|
|
|
|
RESTRICT = contsel, JOIN = contjoinsel
|
2000-12-11 23:39:15 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR ~ (
|
2002-10-18 22:41:22 +04:00
|
|
|
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contained,
|
|
|
|
COMMUTATOR = '@',
|
|
|
|
RESTRICT = contsel, JOIN = contjoinsel
|
2000-12-11 23:39:15 +03: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-19 20:04:32 +03:00
|
|
|
CREATE FUNCTION g_cube_consistent(internal,cube,smallint,oid,internal)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_compress(internal)
|
2010-11-23 23:27:50 +03:00
|
|
|
RETURNS internal
|
2002-10-18 22:41:22 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_decompress(internal)
|
2010-11-23 23:27:50 +03:00
|
|
|
RETURNS internal
|
2002-10-18 22:41:22 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_penalty(internal,internal,internal)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_picksplit(internal, internal)
|
2002-10-18 22:41:22 +04:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_union(internal, internal)
|
2010-11-23 23:27:50 +03:00
|
|
|
RETURNS cube
|
2002-10-18 22:41:22 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2011-02-14 05:24:14 +03:00
|
|
|
CREATE FUNCTION g_cube_same(cube, cube, internal)
|
2010-11-23 23:27:50 +03:00
|
|
|
RETURNS internal
|
2002-10-18 22:41:22 +04:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
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-19 20:04:32 +03:00
|
|
|
CREATE FUNCTION g_cube_distance (internal, cube, smallint, oid, internal)
|
|
|
|
RETURNS float8
|
2015-12-18 14:38:27 +03:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-06-14 20:34:37 +03:00
|
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
2000-12-11 23:39:15 +03:00
|
|
|
|
2003-09-14 05:52:25 +04:00
|
|
|
-- Create the operator classes for indexing
|
|
|
|
|
|
|
|
CREATE OPERATOR CLASS cube_ops
|
|
|
|
DEFAULT FOR TYPE cube USING btree AS
|
|
|
|
OPERATOR 1 < ,
|
|
|
|
OPERATOR 2 <= ,
|
|
|
|
OPERATOR 3 = ,
|
|
|
|
OPERATOR 4 >= ,
|
|
|
|
OPERATOR 5 > ,
|
|
|
|
FUNCTION 1 cube_cmp(cube, cube);
|
2002-07-30 21:34:37 +04:00
|
|
|
|
|
|
|
CREATE OPERATOR CLASS gist_cube_ops
|
|
|
|
DEFAULT FOR TYPE cube USING gist AS
|
|
|
|
OPERATOR 3 && ,
|
|
|
|
OPERATOR 6 = ,
|
2006-09-10 21:36:52 +04:00
|
|
|
OPERATOR 7 @> ,
|
|
|
|
OPERATOR 8 <@ ,
|
|
|
|
OPERATOR 13 @ ,
|
|
|
|
OPERATOR 14 ~ ,
|
2015-12-18 14:38:27 +03:00
|
|
|
OPERATOR 15 ~> (cube, int) FOR ORDER BY float_ops,
|
|
|
|
OPERATOR 16 <#> (cube, cube) FOR ORDER BY float_ops,
|
|
|
|
OPERATOR 17 <-> (cube, cube) FOR ORDER BY float_ops,
|
|
|
|
OPERATOR 18 <=> (cube, cube) FOR ORDER BY float_ops,
|
|
|
|
|
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-19 20:04:32 +03:00
|
|
|
FUNCTION 1 g_cube_consistent (internal, cube, smallint, oid, internal),
|
2004-03-30 19:45:33 +04:00
|
|
|
FUNCTION 2 g_cube_union (internal, internal),
|
2002-08-22 04:01:51 +04:00
|
|
|
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),
|
2015-12-18 14:38:27 +03:00
|
|
|
FUNCTION 7 g_cube_same (cube, cube, internal),
|
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-19 20:04:32 +03:00
|
|
|
FUNCTION 8 g_cube_distance (internal, cube, smallint, oid, internal);
|