From: David Blasby Date: Thu, 8 Apr 2004 17:00:27 +0000 (+0000) Subject: Changed ggeometry_consistent to be aware of NULL queries. Ie. X-Git-Tag: pgis_0_8_2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e56eaf020d7b6a86875c3066e0cb04dc24c85261;p=postgis Changed ggeometry_consistent to be aware of NULL queries. Ie. select * from where the_geom && null::geometry; This tends to happen when you're joining two tables using && and the table has NULLs in it. git-svn-id: http://svn.osgeo.org/postgis/trunk@502 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis_gist_72.c b/postgis_gist_72.c index b1a1eb543..7ca841cf9 100644 --- a/postgis_gist_72.c +++ b/postgis_gist_72.c @@ -11,6 +11,13 @@ * ********************************************************************** * $Log$ + * Revision 1.9 2004/04/08 17:00:27 dblasby + * Changed ggeometry_consistent to be aware of NULL queries. Ie. + * select * from
where the_geom && null::geometry; + * + * This tends to happen when you're joining two tables using && and the table + * has NULLs in it. + * * Revision 1.8 2004/03/05 18:16:47 strk * Applied Mark Cave-Ayland patch * @@ -158,16 +165,26 @@ PG_FUNCTION_INFO_V1(ggeometry_consistent); Datum ggeometry_consistent(PG_FUNCTION_ARGS) { GISTENTRY *entry = (GISTENTRY*) PG_GETARG_POINTER(0); - GEOMETRY *query = (GEOMETRY*) PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); + GEOMETRY *query ; StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); BOX *thebox; bool result; - + /* ** if entry is not leaf, use rtree_internal_consistent, ** else use rtree_leaf_consistent */ + if ( ( (Pointer *) PG_GETARG_DATUM(1) ) == NULL) + { + //elog(NOTICE,"ggeometry_consistent:: got null query!"); + PG_RETURN_BOOL(false); // null query - this is screwy! + } + + query = (GEOMETRY*) PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); + + + #ifdef DEBUG_GIST elog(NOTICE,"GIST: ggeometry_consistent called\n"); fflush( stdout ); @@ -179,16 +196,16 @@ Datum ggeometry_consistent(PG_FUNCTION_ARGS) thebox = convert_box3d_to_box( &(query->bvol) ); if (GIST_LEAF(entry)) - result = rtree_leaf_consistent((BOX *) DatumGetPointer(entry->key), thebox, strategy ); + result = rtree_leaf_consistent((BOX *) DatumGetPointer(entry->key), thebox, strategy ); else result = rtree_internal_consistent((BOX *) DatumGetPointer(entry->key), thebox, strategy ); - + PG_FREE_IF_COPY(query, 1); PG_RETURN_BOOL(result); } -static bool +static bool rtree_internal_consistent(BOX *key, BOX *query, StrategyNumber strategy) @@ -226,7 +243,7 @@ rtree_internal_consistent(BOX *key, } -static bool +static bool rtree_leaf_consistent(BOX *key, BOX *query, StrategyNumber strategy)