From 0f3be7e62a11ce68a0d893da99f060246e8838f9 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 14 Oct 2008 18:59:05 +0000 Subject: [PATCH] ifdef pgsql 7.2 back to original behavior, since sliced detoasting is not supported. git-svn-id: http://svn.osgeo.org/postgis/branches/1.3@3104 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/lwgeom_gist.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lwgeom/lwgeom_gist.c b/lwgeom/lwgeom_gist.c index 004b3989f..6755fc39a 100644 --- a/lwgeom/lwgeom_gist.c +++ b/lwgeom/lwgeom_gist.c @@ -592,8 +592,11 @@ Datum LWGEOM_gist_consistent(PG_FUNCTION_ARGS) PG_LWGEOM *query ; /* lwgeom serialized form */ StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); bool result; - uchar *serialized_lwgeom; BOX2DFLOAT4 box; +#if USE_VERSION > 72 + /* For sliced de-toasting code */ + uchar *serialized_lwgeom; +#endif #ifdef PGIS_DEBUG_CALLS elog(NOTICE,"GIST: LWGEOM_gist_consistent called"); @@ -605,6 +608,24 @@ Datum LWGEOM_gist_consistent(PG_FUNCTION_ARGS) PG_RETURN_BOOL(false); /* null query - this is screwy! */ } +#if USE_VERSION <= 72 + /* + ** PgSQL 7.2 doesn't support sliced detoasting. + */ + query = (PG_LWGEOM*)PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); + + if ( ! (DatumGetPointer(entry->key) != NULL && query) ) + { + PG_FREE_IF_COPY(query, 1); + elog(ERROR, "LWGEOM_gist_consistent got either NULL query or entry->key"); + PG_RETURN_BOOL(FALSE); + } + if ( ! getbox2d_p(SERIALIZED_FORM(query), &box) ) + { + PG_FREE_IF_COPY(query, 1); + PG_RETURN_BOOL(FALSE); + } +#else /* ** First pull only a small amount of the tuple, enough to ** get the bounding box, if one exists. @@ -637,6 +658,7 @@ Datum LWGEOM_gist_consistent(PG_FUNCTION_ARGS) PG_RETURN_BOOL(FALSE); } } +#endif if (GIST_LEAF(entry)) result = lwgeom_rtree_leaf_consistent((BOX2DFLOAT4 *) -- 2.49.0