3 -- Adjust this setting to control where the objects get created.
4 SET search_path
= public;
6 -- Create the user-defined type for 1-D floating point intervals (seg)
9 CREATE OR REPLACE FUNCTION seg_in(cstring
)
12 LANGUAGE C
STRICT IMMUTABLE;
14 CREATE OR REPLACE FUNCTION seg_out(seg
)
17 LANGUAGE C
STRICT IMMUTABLE;
25 COMMENT ON TYPE seg
IS
26 'floating point interval ''FLOAT .. FLOAT'', ''.. FLOAT'', ''FLOAT ..'' or ''FLOAT''';
29 -- External C-functions for R-tree methods
34 CREATE OR REPLACE FUNCTION seg_over_left(seg
, seg
)
37 LANGUAGE C
STRICT IMMUTABLE;
39 COMMENT ON FUNCTION seg_over_left(seg
, seg
) IS
40 'overlaps or is left of';
42 CREATE OR REPLACE FUNCTION seg_over_right(seg
, seg
)
45 LANGUAGE C
STRICT IMMUTABLE;
47 COMMENT ON FUNCTION seg_over_right(seg
, seg
) IS
48 'overlaps or is right of';
50 CREATE OR REPLACE FUNCTION seg_left(seg
, seg
)
53 LANGUAGE C
STRICT IMMUTABLE;
55 COMMENT ON FUNCTION seg_left(seg
, seg
) IS
58 CREATE OR REPLACE FUNCTION seg_right(seg
, seg
)
61 LANGUAGE C
STRICT IMMUTABLE;
63 COMMENT ON FUNCTION seg_right(seg
, seg
) IS
67 -- Scalar comparison methods
69 CREATE OR REPLACE FUNCTION seg_lt(seg
, seg
)
72 LANGUAGE C
STRICT IMMUTABLE;
74 COMMENT ON FUNCTION seg_lt(seg
, seg
) IS
77 CREATE OR REPLACE FUNCTION seg_le(seg
, seg
)
80 LANGUAGE C
STRICT IMMUTABLE;
82 COMMENT ON FUNCTION seg_le(seg
, seg
) IS
85 CREATE OR REPLACE FUNCTION seg_gt(seg
, seg
)
88 LANGUAGE C
STRICT IMMUTABLE;
90 COMMENT ON FUNCTION seg_gt(seg
, seg
) IS
93 CREATE OR REPLACE FUNCTION seg_ge(seg
, seg
)
96 LANGUAGE C
STRICT IMMUTABLE;
98 COMMENT ON FUNCTION seg_ge(seg
, seg
) IS
99 'greater than or equal';
101 CREATE OR REPLACE FUNCTION seg_contains(seg
, seg
)
104 LANGUAGE C
STRICT IMMUTABLE;
106 COMMENT ON FUNCTION seg_contains(seg
, seg
) IS
109 CREATE OR REPLACE FUNCTION seg_contained(seg
, seg
)
112 LANGUAGE C
STRICT IMMUTABLE;
114 COMMENT ON FUNCTION seg_contained(seg
, seg
) IS
117 CREATE OR REPLACE FUNCTION seg_overlap(seg
, seg
)
120 LANGUAGE C
STRICT IMMUTABLE;
122 COMMENT ON FUNCTION seg_overlap(seg
, seg
) IS
125 CREATE OR REPLACE FUNCTION seg_same(seg
, seg
)
128 LANGUAGE C
STRICT IMMUTABLE;
130 COMMENT ON FUNCTION seg_same(seg
, seg
) IS
133 CREATE OR REPLACE FUNCTION seg_different(seg
, seg
)
136 LANGUAGE C
STRICT IMMUTABLE;
138 COMMENT ON FUNCTION seg_different(seg
, seg
) IS
141 -- support routines for indexing
143 CREATE OR REPLACE FUNCTION seg_cmp(seg
, seg
)
146 LANGUAGE C
STRICT IMMUTABLE;
148 COMMENT ON FUNCTION seg_cmp(seg
, seg
) IS 'btree comparison function';
150 CREATE OR REPLACE FUNCTION seg_union(seg
, seg
)
153 LANGUAGE C
STRICT IMMUTABLE;
155 CREATE OR REPLACE FUNCTION seg_inter(seg
, seg
)
158 LANGUAGE C
STRICT IMMUTABLE;
160 CREATE OR REPLACE FUNCTION seg_size(seg
)
163 LANGUAGE C
STRICT IMMUTABLE;
167 CREATE OR REPLACE FUNCTION seg_center(seg
)
170 LANGUAGE C
STRICT IMMUTABLE;
172 CREATE OR REPLACE FUNCTION seg_upper(seg
)
175 LANGUAGE C
STRICT IMMUTABLE;
177 CREATE OR REPLACE FUNCTION seg_lower(seg
)
180 LANGUAGE C
STRICT IMMUTABLE;
193 RESTRICT = scalarltsel
,
194 JOIN = scalarltjoinsel
203 RESTRICT = scalarltsel
,
204 JOIN = scalarltjoinsel
213 RESTRICT = scalargtsel
,
214 JOIN = scalargtjoinsel
223 RESTRICT = scalargtsel
,
224 JOIN = scalargtjoinsel
230 PROCEDURE = seg_left
,
232 RESTRICT = positionsel
,
233 JOIN = positionjoinsel
239 PROCEDURE = seg_over_left
,
240 RESTRICT = positionsel
,
241 JOIN = positionjoinsel
247 PROCEDURE = seg_overlap
,
256 PROCEDURE = seg_over_right
,
257 RESTRICT = positionsel
,
258 JOIN = positionjoinsel
264 PROCEDURE = seg_right
,
266 RESTRICT = positionsel
,
267 JOIN = positionjoinsel
273 PROCEDURE = seg_same
,
284 PROCEDURE = seg_different
,
294 PROCEDURE = seg_contains
,
303 PROCEDURE = seg_contained
,
313 PROCEDURE = seg_contains
,
322 PROCEDURE = seg_contained
,
329 -- define the GiST support methods
330 CREATE OR REPLACE FUNCTION gseg_consistent(internal
,seg
,int,oid
,internal
)
333 LANGUAGE C
IMMUTABLE STRICT;
335 CREATE OR REPLACE FUNCTION gseg_compress(internal
)
338 LANGUAGE C
IMMUTABLE STRICT;
340 CREATE OR REPLACE FUNCTION gseg_decompress(internal
)
343 LANGUAGE C
IMMUTABLE STRICT;
345 CREATE OR REPLACE FUNCTION gseg_penalty(internal
,internal
,internal
)
348 LANGUAGE C
IMMUTABLE STRICT;
350 CREATE OR REPLACE FUNCTION gseg_picksplit(internal
, internal
)
353 LANGUAGE C
IMMUTABLE STRICT;
355 CREATE OR REPLACE FUNCTION gseg_union(internal
, internal
)
358 LANGUAGE C
IMMUTABLE STRICT;
360 CREATE OR REPLACE FUNCTION gseg_same(seg
, seg
, internal
)
363 LANGUAGE C
IMMUTABLE STRICT;
366 -- Create the operator classes for indexing
368 CREATE OPERATOR CLASS seg_ops
369 DEFAULT FOR TYPE seg
USING btree
AS
375 FUNCTION 1 seg_cmp(seg
, seg
);
377 CREATE OPERATOR CLASS gist_seg_ops
378 DEFAULT FOR TYPE seg
USING gist
390 FUNCTION 1 gseg_consistent (internal
, seg
, int, oid
, internal
),
391 FUNCTION 2 gseg_union (internal
, internal
),
392 FUNCTION 3 gseg_compress (internal
),
393 FUNCTION 4 gseg_decompress (internal
),
394 FUNCTION 5 gseg_penalty (internal
, internal
, internal
),
395 FUNCTION 6 gseg_picksplit (internal
, internal
),
396 FUNCTION 7 gseg_same (seg
, seg
, internal
);