1 /* contrib/cube/cube--1.2.sql */
3 -- complain if script is sourced in psql, rather than via CREATE EXTENSION
4 \echo Use "CREATE EXTENSION cube" to load this file. \quit
6 -- Create the user-defined type for N-dimensional boxes
8 CREATE FUNCTION cube_in(cstring)
11 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
13 CREATE FUNCTION cube(float8[], float8[]) RETURNS cube
14 AS 'MODULE_PATHNAME', 'cube_a_f8_f8'
15 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
17 CREATE FUNCTION cube(float8[]) RETURNS cube
18 AS 'MODULE_PATHNAME', 'cube_a_f8'
19 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
21 CREATE FUNCTION cube_out(cube)
24 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
27 INTERNALLENGTH = variable,
33 COMMENT ON TYPE cube IS 'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
36 -- External C-functions for R-tree methods
41 CREATE FUNCTION cube_eq(cube, cube)
44 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
46 COMMENT ON FUNCTION cube_eq(cube, cube) IS 'same as';
48 CREATE FUNCTION cube_ne(cube, cube)
51 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
53 COMMENT ON FUNCTION cube_ne(cube, cube) IS 'different';
55 CREATE FUNCTION cube_lt(cube, cube)
58 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
60 COMMENT ON FUNCTION cube_lt(cube, cube) IS 'lower than';
62 CREATE FUNCTION cube_gt(cube, cube)
65 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
67 COMMENT ON FUNCTION cube_gt(cube, cube) IS 'greater than';
69 CREATE FUNCTION cube_le(cube, cube)
72 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
74 COMMENT ON FUNCTION cube_le(cube, cube) IS 'lower than or equal to';
76 CREATE FUNCTION cube_ge(cube, cube)
79 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
81 COMMENT ON FUNCTION cube_ge(cube, cube) IS 'greater than or equal to';
83 CREATE FUNCTION cube_cmp(cube, cube)
86 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
88 COMMENT ON FUNCTION cube_cmp(cube, cube) IS 'btree comparison function';
90 CREATE FUNCTION cube_contains(cube, cube)
93 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
95 COMMENT ON FUNCTION cube_contains(cube, cube) IS 'contains';
97 CREATE FUNCTION cube_contained(cube, cube)
100 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
102 COMMENT ON FUNCTION cube_contained(cube, cube) IS 'contained in';
104 CREATE FUNCTION cube_overlap(cube, cube)
107 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
109 COMMENT ON FUNCTION cube_overlap(cube, cube) IS 'overlaps';
111 -- support routines for indexing
113 CREATE FUNCTION cube_union(cube, cube)
116 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
118 CREATE FUNCTION cube_inter(cube, cube)
121 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
123 CREATE FUNCTION cube_size(cube)
126 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
129 -- Misc N-dimensional functions
131 CREATE FUNCTION cube_subset(cube, int4[])
134 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
136 -- proximity routines
138 CREATE FUNCTION cube_distance(cube, cube)
141 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
143 CREATE FUNCTION distance_chebyshev(cube, cube)
146 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
148 CREATE FUNCTION distance_taxicab(cube, cube)
151 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
153 -- Extracting elements functions
155 CREATE FUNCTION cube_dim(cube)
158 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
160 CREATE FUNCTION cube_ll_coord(cube, int4)
163 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
165 CREATE FUNCTION cube_ur_coord(cube, int4)
168 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
170 CREATE FUNCTION cube_coord(cube, int4)
173 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
175 CREATE FUNCTION cube_coord_llur(cube, int4)
178 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
180 CREATE FUNCTION cube(float8) RETURNS cube
181 AS 'MODULE_PATHNAME', 'cube_f8'
182 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
184 CREATE FUNCTION cube(float8, float8) RETURNS cube
185 AS 'MODULE_PATHNAME', 'cube_f8_f8'
186 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
188 CREATE FUNCTION cube(cube, float8) RETURNS cube
189 AS 'MODULE_PATHNAME', 'cube_c_f8'
190 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
192 CREATE FUNCTION cube(cube, float8, float8) RETURNS cube
193 AS 'MODULE_PATHNAME', 'cube_c_f8_f8'
194 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
196 -- Test if cube is also a point
198 CREATE FUNCTION cube_is_point(cube)
201 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
203 -- Increasing the size of a cube by a radius in at least n dimensions
205 CREATE FUNCTION cube_enlarge(cube, float8, int4)
208 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
215 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_lt,
216 COMMUTATOR = '>', NEGATOR = '>=',
217 RESTRICT = scalarltsel, JOIN = scalarltjoinsel
221 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_gt,
222 COMMUTATOR = '<', NEGATOR = '<=',
223 RESTRICT = scalargtsel, JOIN = scalargtjoinsel
227 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_le,
228 COMMUTATOR = '>=', NEGATOR = '>',
229 RESTRICT = scalarltsel, JOIN = scalarltjoinsel
233 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_ge,
234 COMMUTATOR = '<=', NEGATOR = '<',
235 RESTRICT = scalargtsel, JOIN = scalargtjoinsel
239 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_overlap,
241 RESTRICT = areasel, JOIN = areajoinsel
245 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_eq,
246 COMMUTATOR = '=', NEGATOR = '<>',
247 RESTRICT = eqsel, JOIN = eqjoinsel,
252 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_ne,
253 COMMUTATOR = '<>', NEGATOR = '=',
254 RESTRICT = neqsel, JOIN = neqjoinsel
258 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
260 RESTRICT = contsel, JOIN = contjoinsel
264 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contained,
266 RESTRICT = contsel, JOIN = contjoinsel
270 LEFTARG = cube, RIGHTARG = int, PROCEDURE = cube_coord
274 LEFTARG = cube, RIGHTARG = int, PROCEDURE = cube_coord_llur
277 CREATE OPERATOR <#> (
278 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = distance_taxicab,
282 CREATE OPERATOR <-> (
283 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_distance,
287 CREATE OPERATOR <=> (
288 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = distance_chebyshev,
292 -- these are obsolete/deprecated:
294 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
296 RESTRICT = contsel, JOIN = contjoinsel
300 LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contained,
302 RESTRICT = contsel, JOIN = contjoinsel
306 -- define the GiST support methods
307 CREATE FUNCTION g_cube_consistent(internal,cube,smallint,oid,internal)
310 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
312 CREATE FUNCTION g_cube_compress(internal)
315 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
317 CREATE FUNCTION g_cube_decompress(internal)
320 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
322 CREATE FUNCTION g_cube_penalty(internal,internal,internal)
325 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
327 CREATE FUNCTION g_cube_picksplit(internal, internal)
330 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
332 CREATE FUNCTION g_cube_union(internal, internal)
335 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
337 CREATE FUNCTION g_cube_same(cube, cube, internal)
340 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
342 CREATE FUNCTION g_cube_distance (internal, cube, smallint, oid, internal)
345 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
347 -- Create the operator classes for indexing
349 CREATE OPERATOR CLASS cube_ops
350 DEFAULT FOR TYPE cube USING btree AS
356 FUNCTION 1 cube_cmp(cube, cube);
358 CREATE OPERATOR CLASS gist_cube_ops
359 DEFAULT FOR TYPE cube USING gist AS
366 OPERATOR 15 ~> (cube, int) FOR ORDER BY float_ops,
367 OPERATOR 16 <#> (cube, cube) FOR ORDER BY float_ops,
368 OPERATOR 17 <-> (cube, cube) FOR ORDER BY float_ops,
369 OPERATOR 18 <=> (cube, cube) FOR ORDER BY float_ops,
371 FUNCTION 1 g_cube_consistent (internal, cube, smallint, oid, internal),
372 FUNCTION 2 g_cube_union (internal, internal),
373 FUNCTION 3 g_cube_compress (internal),
374 FUNCTION 4 g_cube_decompress (internal),
375 FUNCTION 5 g_cube_penalty (internal, internal, internal),
376 FUNCTION 6 g_cube_picksplit (internal, internal),
377 FUNCTION 7 g_cube_same (cube, cube, internal),
378 FUNCTION 8 g_cube_distance (internal, cube, smallint, oid, internal);