[postgis-devel] Re: PostgreSQL HEAD array changes

Michael Fuhr mike at fuhr.org
Fri Nov 18 17:40:21 PST 2005


On Thu, Nov 17, 2005 at 05:55:23PM -0700, Michael Fuhr wrote:
> A change was recently committed to PostgreSQL HEAD (8.2devel) that
> affects arrays; among other things it removes the ARR_OVERHEAD macro
> that PostGIS uses.

More on this: to run under the latest PostgreSQL HEAD (8.2devel),
PostGIS needs to do a couple of things (conditionally starting with
PostgreSQL 8.2):

* Use ARR_OVERHEAD_NONULLS instead of ARR_OVERHEAD.  Otherwise
  the compiler raises an "implicit declaration of function `ARR_OVERHEAD'"
  warning and the runtime linker fails to load liblwgeom.so with
  an error like "symbol ARR_OVERHEAD: referenced symbol not found."

* Set an array structure's dataoffset field to 0 to indicate
  that the array doesn't contain NULLs.  Otherwise a segfault
  might result.

I've attached a patch to PostGIS HEAD that shows these changes; the
same changes should probably be applied to the 1.0 branch.  Defining
ARR_OVERHEAD(x) as ARR_OVERHEAD_NONULLS(x) might not be the best
decision, but at least the patch shows what needs to change to get
PostGIS working under PostgreSQL HEAD.  I leave it to better
programmers than myself to decide what's best :-)

The version-determining code in Makefile.config.in could probably
use some restructuring -- it keeps creeping to the right with every
new version of PostgreSQL.

-- 
Michael Fuhr
-------------- next part --------------
Index: Makefile.config.in
===================================================================
RCS file: /home/cvs/postgis/postgis/Makefile.config.in,v
retrieving revision 1.21
diff -c -r1.21 Makefile.config.in
*** Makefile.config.in	1 Nov 2005 17:11:20 -0000	1.21
--- Makefile.config.in	19 Nov 2005 01:21:14 -0000
***************
*** 165,171 ****
  				ifneq ($(findstring 8.0,$(VERSION)),)
  					USE_VERSION=80
  				else
! 					USE_VERSION=81
  				endif
  			endif
  		endif
--- 165,175 ----
  				ifneq ($(findstring 8.0,$(VERSION)),)
  					USE_VERSION=80
  				else
! 					ifneq ($(findstring 8.1,$(VERSION)),)
! 						USE_VERSION=81
! 					else
! 						USE_VERSION=82
! 					endif
  				endif
  			endif
  		endif
Index: lwgeom/lwgeom_functions_basic.c
===================================================================
RCS file: /home/cvs/postgis/postgis/lwgeom/lwgeom_functions_basic.c,v
retrieving revision 1.125
diff -c -r1.125 lwgeom_functions_basic.c
*** lwgeom/lwgeom_functions_basic.c	18 Nov 2005 10:16:21 -0000	1.125
--- lwgeom/lwgeom_functions_basic.c	19 Nov 2005 01:21:15 -0000
***************
*** 15,20 ****
--- 15,24 ----
  #include "profile.h"
  #include "wktparse.h"
  
+ #if USE_VERSION >= 82
+ #  define ARR_OVERHEAD(x) ARR_OVERHEAD_NONULLS(x)
+ #endif
+ 
  //#define PGIS_DEBUG 1
  
  Datum LWGEOM_mem_size(PG_FUNCTION_ARGS);
***************
*** 2119,2124 ****
--- 2123,2131 ----
  #if USE_VERSION > 72
  		result->elemtype = oid;
  #endif
+ #if USE_VERSION >= 82
+ 		result->dataoffset = 0;
+ #endif
  		memcpy(ARR_DIMS(result), &nelems, sizeof(int));
  		memcpy(ARR_LBOUND(result), &lbs, sizeof(int));
  		memcpy(ARR_DATA_PTR(result), geom, geom->size);


More information about the postgis-devel mailing list