postgresql/contrib/rtree_gist/rtree_gist.sql.in
Tom Lane b90f8f20f0 Extend r-tree operator classes to handle Y-direction tests equivalent
to the existing X-direction tests.  An rtree class now includes 4 actual
2-D tests, 4 1-D X-direction tests, and 4 1-D Y-direction tests.
This involved adding four new Y-direction test operators for each of
box and polygon; I followed the PostGIS project's lead as to the names
of these operators.
NON BACKWARDS COMPATIBLE CHANGE: the poly_overleft (&<) and poly_overright
(&>) operators now have semantics comparable to box_overleft and box_overright.
This is necessary to make r-tree indexes work correctly on polygons.
Also, I changed circle_left and circle_right to agree with box_left and
box_right --- formerly they allowed the boundaries to touch.  This isn't
actually essential given the lack of any r-tree opclass for circles, but
it seems best to sync all the definitions while we are at it.
2005-06-24 20:53:34 +00:00

114 lines
2.4 KiB
MySQL

-- Adjust this setting to control where the objects get created.
SET search_path = public;
--
--
--
-- BOX ops
--
--
--
-- define the GiST support methods
CREATE FUNCTION gbox_consistent(internal,box,int4)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gbox_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION rtree_decompress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gbox_penalty(internal,internal,internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C' STRICT;
CREATE FUNCTION gbox_picksplit(internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gbox_union(internal, internal)
RETURNS box
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gbox_same(box, box, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- create the operator class
CREATE OPERATOR CLASS gist_box_ops
DEFAULT FOR TYPE box USING gist
AS
OPERATOR 1 << ,
OPERATOR 2 &< ,
OPERATOR 3 && ,
OPERATOR 4 &> ,
OPERATOR 5 >> ,
OPERATOR 6 ~= ,
OPERATOR 7 ~ ,
OPERATOR 8 @ ,
OPERATOR 9 &<| ,
OPERATOR 10 <<| ,
OPERATOR 11 |>> ,
OPERATOR 12 |&> ,
FUNCTION 1 gbox_consistent (internal, box, int4),
FUNCTION 2 gbox_union (internal, internal),
FUNCTION 3 gbox_compress (internal),
FUNCTION 4 rtree_decompress (internal),
FUNCTION 5 gbox_penalty (internal, internal, internal),
FUNCTION 6 gbox_picksplit (internal, internal),
FUNCTION 7 gbox_same (box, box, internal);
--
--
--
-- POLYGON ops
--
--
--
-- define the GiST support methods
CREATE FUNCTION gpoly_consistent(internal,polygon,int4)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
CREATE FUNCTION gpoly_compress(internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE 'C';
-- create the operator class
CREATE OPERATOR CLASS gist_poly_ops
DEFAULT FOR TYPE polygon USING gist
AS
OPERATOR 1 << RECHECK,
OPERATOR 2 &< RECHECK,
OPERATOR 3 && RECHECK,
OPERATOR 4 &> RECHECK,
OPERATOR 5 >> RECHECK,
OPERATOR 6 ~= RECHECK,
OPERATOR 7 ~ RECHECK,
OPERATOR 8 @ RECHECK,
OPERATOR 9 &<| RECHECK,
OPERATOR 10 <<| RECHECK,
OPERATOR 11 |>> RECHECK,
OPERATOR 12 |&> RECHECK,
FUNCTION 1 gpoly_consistent (internal, polygon, int4),
FUNCTION 2 gbox_union (internal, internal),
FUNCTION 3 gpoly_compress (internal),
FUNCTION 4 rtree_decompress (internal),
FUNCTION 5 gbox_penalty (internal, internal, internal),
FUNCTION 6 gbox_picksplit (internal, internal),
FUNCTION 7 gbox_same (box, box, internal),
STORAGE box;