Mamad Purbo

Installing PostgreSQL < 8.2 With PostGIS 1.1.6

The latest PostGIS version (as of 2006/12/05) 1.1.6 cannot be built on PostgreSQL with version less than 8.2 (still RC1). Fortunately somebody on PostGIS mailing list provide a patch for this problem. I tried to apply the patch and PostGIS 1.1.6 worked like a charm on 8.0.9. Here's more or less what I did:

$ cd /opt/source/postgresql-8.0.9/contrib
$ tar xvfz postgis-1.1.6.tar.gz
$ cd postgis-1.1.6
$ vi patch.lwgeom_gist.c


Then paste the following patch to the newly created patch file:

--- lwgeom/lwgeom_gist.c (revision 2528)
+++ lwgeom/lwgeom_gist.c (working copy)
@@ -542,14 +542,17 @@
if (in != (PG_LWGEOM*)DatumGetPointer(entry->key))
pfree(in); /* PG_FREE_IF_COPY */

+#if USE_VERSION >= 82
gistentryinit(*retval, PointerGetDatum(rr),
entry->rel, entry->page,
-#if USE_VERSION >= 82
entry->offset,
+ FALSE);
#else
+ gistentryinit(*retval, PointerGetDatum(rr),
+ entry->rel, entry->page,
entry->offset, sizeof(BOX2DFLOAT4),
+ FALSE);
#endif
- FALSE);

}
else
@@ -557,10 +560,12 @@
#ifdef PGIS_DEBUG_GIST4
elog(NOTICE,"GIST: LWGEOM_gist_compress got a NULL key");
#endif
+
+#if USE_VERSION >= 82
gistentryinit(*retval, (Datum) 0, entry->rel,
-#if USE_VERSION >= 82
entry->page, entry->offset, FALSE);
#else
+ gistentryinit(*retval, (Datum) 0, entry->rel,
entry->page, entry->offset, 0, FALSE);
#endif
}


Apply the patch, then build PostGIS like how it should be built.

$ patch -b lwgeom/lwgeom_gist.c patch.lwgeom_gist.c
$ make
$ make install


And finally, go and find yourself a nice warm drink.