aboutsummaryrefslogtreecommitdiff
path: root/contrib/rtree_gist/rtree_gist.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-24 00:18:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-24 00:18:52 +0000
commit9a09248eddf12339677169064c88e4df11e5077f (patch)
treeff29984a029e973b85b2869de2c115399c7c6b07 /contrib/rtree_gist/rtree_gist.c
parentdea41174b205ee592d46c074518b38d97b8b90c2 (diff)
downloadpostgresql-9a09248eddf12339677169064c88e4df11e5077f.tar.gz
postgresql-9a09248eddf12339677169064c88e4df11e5077f.zip
Fix rtree and contrib/rtree_gist search behavior for the 1-D box and
polygon operators (<<, &<, >>, &>). Per ideas originally put forward by andrew@supernews and later rediscovered by moi. This patch just fixes the existing opclasses, and does not add any new behavior as I proposed earlier; that can be sorted out later. In principle this could be back-patched, since it changes only search behavior and not system catalog entries nor rtree index contents. I'm not currently planning to do that, though, since I think it could use more testing.
Diffstat (limited to 'contrib/rtree_gist/rtree_gist.c')
-rw-r--r--contrib/rtree_gist/rtree_gist.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c
index 55a480915fb..f4ce58460fb 100644
--- a/contrib/rtree_gist/rtree_gist.c
+++ b/contrib/rtree_gist/rtree_gist.c
@@ -2,12 +2,12 @@
*
* rtree_gist.c
* pg_amproc entries for GiSTs over 2-D boxes.
- * This gives R-tree behavior, with Guttman's poly-time split algorithm.
*
+ * This gives R-tree behavior, with Guttman's poly-time split algorithm.
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.12 2005/05/25 21:40:40 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.13 2005/06/24 00:18:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,7 +78,7 @@ gbox_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
/*
- * * if entry is not leaf, use gbox_internal_consistent, * else use
+ * if entry is not leaf, use rtree_internal_consistent, else use
* gbox_leaf_consistent
*/
if (!(DatumGetPointer(entry->key) != NULL && query))
@@ -509,8 +509,9 @@ gpoly_consistent(PG_FUNCTION_ARGS)
bool result;
/*
- * * if entry is not leaf, use gbox_internal_consistent, * else use
- * gbox_leaf_consistent
+ * Since the operators are marked lossy anyway, we can just use
+ * rtree_internal_consistent even at leaf nodes. (This works
+ * in part because the index entries are bounding Boxes not polygons.)
*/
if (!(DatumGetPointer(entry->key) != NULL && query))
PG_RETURN_BOOL(FALSE);
@@ -536,15 +537,19 @@ rtree_internal_consistent(BOX *key,
switch (strategy)
{
case RTLeftStrategyNumber:
+ retval = !DatumGetBool(DirectFunctionCall2(box_overright, PointerGetDatum(key), PointerGetDatum(query)));
+ break;
case RTOverLeftStrategyNumber:
- retval = DatumGetBool(DirectFunctionCall2(box_overleft, PointerGetDatum(key), PointerGetDatum(query)));
+ retval = !DatumGetBool(DirectFunctionCall2(box_right, PointerGetDatum(key), PointerGetDatum(query)));
break;
case RTOverlapStrategyNumber:
retval = DatumGetBool(DirectFunctionCall2(box_overlap, PointerGetDatum(key), PointerGetDatum(query)));
break;
case RTOverRightStrategyNumber:
+ retval = !DatumGetBool(DirectFunctionCall2(box_left, PointerGetDatum(key), PointerGetDatum(query)));
+ break;
case RTRightStrategyNumber:
- retval = DatumGetBool(DirectFunctionCall2(box_right, PointerGetDatum(key), PointerGetDatum(query)));
+ retval = !DatumGetBool(DirectFunctionCall2(box_overleft, PointerGetDatum(key), PointerGetDatum(query)));
break;
case RTSameStrategyNumber:
case RTContainsStrategyNumber: