mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
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.
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* rtree_gist.c
|
||||
* pg_amproc entries for GiSTs over 2-D boxes.
|
||||
* pg_amproc entries for GiSTs over 2-D boxes and polygons.
|
||||
*
|
||||
* This gives R-tree behavior, with Guttman's poly-time split algorithm.
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.13 2005/06/24 00:18:52 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.14 2005/06/24 20:53:29 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -23,8 +23,8 @@ typedef Datum (*BINARY_UNION) (Datum, Datum, int *);
|
||||
typedef float (*SIZE_BOX) (Datum);
|
||||
|
||||
/*
|
||||
** box ops
|
||||
*/
|
||||
* box ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gbox_compress);
|
||||
PG_FUNCTION_INFO_V1(gbox_union);
|
||||
PG_FUNCTION_INFO_V1(gbox_picksplit);
|
||||
@ -43,8 +43,8 @@ static bool gbox_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy);
|
||||
static float size_box(Datum box);
|
||||
|
||||
/*
|
||||
** Polygon ops
|
||||
*/
|
||||
* Polygon ops
|
||||
*/
|
||||
PG_FUNCTION_INFO_V1(gpoly_compress);
|
||||
PG_FUNCTION_INFO_V1(gpoly_consistent);
|
||||
|
||||
@ -52,8 +52,8 @@ Datum gpoly_compress(PG_FUNCTION_ARGS);
|
||||
Datum gpoly_consistent(PG_FUNCTION_ARGS);
|
||||
|
||||
/*
|
||||
** Common rtree-function (for all ops)
|
||||
*/
|
||||
* Common rtree-function (for all ops)
|
||||
*/
|
||||
static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy);
|
||||
|
||||
PG_FUNCTION_INFO_V1(rtree_decompress);
|
||||
@ -441,6 +441,18 @@ gbox_leaf_consistent(BOX *key,
|
||||
case RTContainedByStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_contained, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTOverBelowStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_overbelow, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTBelowStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_below, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTAboveStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_above, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTOverAboveStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_overabove, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
default:
|
||||
retval = FALSE;
|
||||
}
|
||||
@ -558,6 +570,18 @@ rtree_internal_consistent(BOX *key,
|
||||
case RTContainedByStrategyNumber:
|
||||
retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTOverBelowStrategyNumber:
|
||||
retval = !DatumGetBool(DirectFunctionCall2(box_above, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTBelowStrategyNumber:
|
||||
retval = !DatumGetBool(DirectFunctionCall2(box_overabove, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTAboveStrategyNumber:
|
||||
retval = !DatumGetBool(DirectFunctionCall2(box_overbelow, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
case RTOverAboveStrategyNumber:
|
||||
retval = !DatumGetBool(DirectFunctionCall2(box_below, PointerGetDatum(key), PointerGetDatum(query)));
|
||||
break;
|
||||
default:
|
||||
retval = FALSE;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ LANGUAGE 'C';
|
||||
CREATE FUNCTION gbox_penalty(internal,internal,internal)
|
||||
RETURNS internal
|
||||
AS 'MODULE_PATHNAME'
|
||||
LANGUAGE 'C' with (isstrict);
|
||||
LANGUAGE 'C' STRICT;
|
||||
|
||||
CREATE FUNCTION gbox_picksplit(internal, internal)
|
||||
RETURNS internal
|
||||
@ -56,6 +56,10 @@ AS
|
||||
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),
|
||||
@ -95,6 +99,10 @@ AS
|
||||
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),
|
||||
|
Reference in New Issue
Block a user