[postgis] Odd Insert Problem

Frank Warmerdam warmerdam at pobox.com
Tue Jun 19 14:26:26 PDT 2001

Paul Ramsey wrote:
> Frank,
> The problem occurs identically on our linux installation, so it is
> definitately an architecture issue. I suspect that some judicious
> ifndefs using the information from postgis.h will clear it up. Dave has
> it under the debugger right now.
> Paul


The error seems to be in the assumptions about 4 vs. 8 byte alignment.  It
seems that under linux stuff only needs to be four byte aligned. 

Strangely I found the polygons did work under pgaccess, a tcl/tk frontend
to Postgresql.  Tracking this down the difference was that the geometry
objects in geometry_out() happened to be four byte aligned in one case (the
broken case), and happened to be eight byte aligned when accessed from 

I believe that this logic to "eight byte align" the pts pointers is not
appropriate on the linux architecture.  It seems you will need some sort
of build time logic to determine if this operation is required on a 
per-platform basis. 

            if ((int32) pts != (((int32)pts>>3)<<3) )
                pts = (POINT3D *) ((char *) pts + 4);

I printed out the values of some stuff from psql (wrong):

First point in polygon:(0.000000000000,0.000000000000,0.000000000000)
First Point Offset: 84:0x8217db0:0x8217d5c  <-- geometry

>From pgaccess:
First point in polygon:(0.000000000000,4.000000000000,0.000000000000)
First Point Offset: 80:0x8218748:0x82186f8

In the pgaccess case the geometry pointer fell on an eight byte
boundary, so no adjustment was done.  In the psql case the offset
to the pts within the record was "adjusted" to achieve eight byte
alighnment but it really shouldn't have been. 

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com


Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the postgis-users mailing list