Commit 4427dbff authored by Sandro Santilli's avatar Sandro Santilli

Add check for liblwgeom version mismatch in postgis_full_version()

Adds a postgis_liblwgeom_version() function accessible to SQL.

git-svn-id: http://svn.osgeo.org/postgis/trunk@14171 b70326c6-7e19-0410-871a-916f4a2858ee
parent f9c6a422
Pipeline #160919 skipped
......@@ -23,6 +23,8 @@ SHELL = @SHELL@
INSTALL = $(SHELL) ../install-sh
LIBTOOL = @LIBTOOL@
SOVER = @POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
IFACE_CURRENT = @LIBLWGEOM_CURRENT@
IFACE_AGE = @LIBLWGEOM_AGE@
IFACE_REV = @LIBLWGEOM_REV@
......@@ -162,7 +164,7 @@ $(LT_OBJS): ../postgis_config.h ../postgis_svn_revision.h $(SA_HEADERS)
liblwgeom.la: $(LT_OBJS)
$(LIBTOOL) --tag=CC --mode=link $(CC) -rpath $(libdir) $(LT_OBJS) \
-version-info $(VERSION_INFO) $(LDFLAGS) -o $@
-release $(SOVER) -version-info $(VERSION_INFO) $(LDFLAGS) -o $@
maintainer-clean: clean
rm -f lwin_wkt_lex.c
......
......@@ -52,6 +52,9 @@
#define LIBLWGEOM_VERSION_MINOR "@POSTGIS_MINOR_VERSION@"
#define LIBLWGEOM_GEOS_VERSION "@POSTGIS_GEOS_VERSION@"
/** Return lwgeom version string (not to be freed) */
const char* lwgeom_version(void);
/**
* Return types for functions with status returns.
*/
......
......@@ -17,12 +17,27 @@
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include "../postgis_svn_revision.h"
/*
* Lower this to reduce integrity checks
*/
#define PARANOIA_LEVEL 1
const char *
lwgeom_version()
{
static char *ptr = NULL;
static char buf[256];
if ( ! ptr )
{
ptr = buf;
snprintf(ptr, 256, LIBLWGEOM_VERSION" r%d", POSTGIS_SVN_REVISION);
}
return ptr;
}
/**********************************************************************
* BOX routines
......
......@@ -34,6 +34,7 @@ Datum postgis_uses_stats(PG_FUNCTION_ARGS);
Datum postgis_autocache_bbox(PG_FUNCTION_ARGS);
Datum postgis_scripts_released(PG_FUNCTION_ARGS);
Datum postgis_version(PG_FUNCTION_ARGS);
Datum postgis_liblwgeom_version(PG_FUNCTION_ARGS);
Datum postgis_lib_version(PG_FUNCTION_ARGS);
Datum postgis_svn_version(PG_FUNCTION_ARGS);
Datum postgis_libxml_version(PG_FUNCTION_ARGS);
......@@ -138,6 +139,14 @@ Datum postgis_version(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P(result);
}
PG_FUNCTION_INFO_V1(postgis_liblwgeom_version);
Datum postgis_liblwgeom_version(PG_FUNCTION_ARGS)
{
const char *ver = lwgeom_version();
text *result = cstring2text(ver);
PG_RETURN_TEXT_P(result);
}
PG_FUNCTION_INFO_V1(postgis_lib_version);
Datum postgis_lib_version(PG_FUNCTION_ARGS)
{
......
......@@ -2683,6 +2683,10 @@ CREATE OR REPLACE FUNCTION postgis_version() RETURNS text
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_liblwgeom_version() RETURNS text
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_proj_version() RETURNS text
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE;
......@@ -2738,6 +2742,7 @@ DECLARE
cgalver text;
gdalver text;
libxmlver text;
liblwgeomver text;
dbproc text;
relproc text;
fullver text;
......@@ -2771,6 +2776,7 @@ BEGIN
WHEN undefined_function THEN
sfcgalver := NULL;
END;
SELECT postgis_liblwgeom_version() INTO liblwgeomver;
SELECT postgis_libxml_version() INTO libxmlver;
SELECT postgis_scripts_installed() INTO dbproc;
SELECT postgis_scripts_released() INTO relproc;
......@@ -2811,6 +2817,11 @@ BEGIN
fullver = fullver || '"';
IF liblwgeomver != relproc THEN
fullver = fullver || ' (liblwgeom version mismatch: "' || liblwgeomver || '")';
END IF;
IF geosver IS NOT NULL THEN
fullver = fullver || ' GEOS="' || geosver || '"';
END IF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment