[mapserver-commits] r9781 - branches/branch-5-4/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Feb 8 22:04:27 EST 2010
Author: pramsey
Date: 2010-02-08 22:04:26 -0500 (Mon, 08 Feb 2010)
New Revision: 9781
Modified:
branches/branch-5-4/mapserver/HISTORY.TXT
branches/branch-5-4/mapserver/configure.in
branches/branch-5-4/mapserver/mappostgis.c
Log:
Determine PgSQL version in a more backwards compatible way (#3291)
Modified: branches/branch-5-4/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-4/mapserver/HISTORY.TXT 2010-02-08 22:11:50 UTC (rev 9780)
+++ branches/branch-5-4/mapserver/HISTORY.TXT 2010-02-09 03:04:26 UTC (rev 9781)
@@ -14,6 +14,8 @@
Current Version:
----------------
+- Determine PgSQL version in a more backwards compatible way (#3291)
+
- Fixed use of minfeaturesize auto with curved labels (#3151)
- Useful error message for case where PK is missing and data is
Modified: branches/branch-5-4/mapserver/configure.in
===================================================================
--- branches/branch-5-4/mapserver/configure.in 2010-02-08 22:11:50 UTC (rev 9780)
+++ branches/branch-5-4/mapserver/configure.in 2010-02-09 03:04:26 UTC (rev 9781)
@@ -1481,6 +1481,12 @@
POSTGIS_ENABLED=-DUSE_POSTGIS
POSTGIS_LIB="-L`$PG_CONFIG --libdir` -lpq"
POSTGIS_INC="-I`$PG_CONFIG --includedir`"
+
+ old_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -L`$PG_CONFIG --libdir`"
+ AC_CHECK_LIB(pq, PQserverVersion, POSTGIS_ENABLED="$POSTGIS_ENABLED -DPOSTGIS_HAS_SERVER_VERSION")
+ LDFLAGS="$old_LDFLAGS"
+
fi
AC_SUBST(POSTGIS_ENABLED,$POSTGIS_ENABLED)
Modified: branches/branch-5-4/mapserver/mappostgis.c
===================================================================
--- branches/branch-5-4/mapserver/mappostgis.c 2010-02-08 22:11:50 UTC (rev 9780)
+++ branches/branch-5-4/mapserver/mappostgis.c 2010-02-09 03:04:26 UTC (rev 9781)
@@ -394,6 +394,63 @@
/* TODO Review and clean above! */
+static int msPostGISRetrievePgVersion(PGconn *pgconn) {
+#ifndef POSTGIS_HAS_SERVER_VERSION
+ int pgVersion = 0;
+ char *strVersion = NULL;
+ char *strParts[3] = { NULL, NULL, NULL };
+ int i = 0, j = 0, len = 0;
+ int factor = 10000;
+
+ if (pgconn == NULL) {
+ msSetError(MS_QUERYERR, "Layer does not have a postgis connection.", "msPostGISRetrievePgVersion()");
+ return(MS_FAILURE);
+ }
+
+ strVersion = (char *)PQparameterStatus(pgconn, "server_version");
+ if (strVersion == NULL)
+ return(MS_FAILURE);
+
+ strVersion = strdup(strVersion);
+ if( ! strVersion )
+ return MS_FAILURE;
+ strParts[j] = strVersion;
+ j++;
+ len = strlen(strVersion);
+ for( i = 0; i < len; i++ ) {
+ if( strVersion[i] == '.' ) {
+ strVersion[i] = '\0';
+
+ if( j < 3 ) {
+ strParts[j] = strVersion + i + 1;
+ j++;
+ }
+ else {
+ free(strVersion);
+ msSetError(MS_QUERYERR, "Too many parts in version string.", "msPostGISRetrievePgVersion()");
+ return MS_FAILURE;
+ }
+ }
+ }
+
+ for( j = 0; j < 3 && strParts[j]; j++ ) {
+ if( atoi(strParts[j]) ) {
+ pgVersion += factor * atoi(strParts[j]);
+ }
+ else {
+ free(strVersion);
+ msSetError(MS_QUERYERR, "Unable to parse version string.", "msPostGISRetrievePgVersion()");
+ return MS_FAILURE;
+ }
+ factor = factor / 100;
+ }
+ free(strVersion);
+ return pgVersion;
+#else
+ return PQserverVersion(pgconn);
+#endif
+}
+
/*
** msPostGISRetrievePK()
**
@@ -439,7 +496,7 @@
msSetError(MS_QUERYERR, "Layer does not have a postgis connection.", "msPostGISRetrievePK()");
return(MS_FAILURE);
}
- pgVersion = PQserverVersion(layerinfo->pgconn);
+ pgVersion = msPostGISRetrievePgVersion(layerinfo->pgconn);
if (pgVersion < 70000) {
if (layer->debug) {
More information about the mapserver-commits
mailing list