From 4427dbffa5d6d82e35736e6f81d12c618f9012c8 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 1 Oct 2015 20:09:57 +0000 Subject: [PATCH] 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 --- liblwgeom/Makefile.in | 4 +++- liblwgeom/liblwgeom.h.in | 3 +++ liblwgeom/lwgeom_api.c | 15 +++++++++++++++ postgis/lwgeom_functions_basic.c | 9 +++++++++ postgis/postgis.sql.in | 11 +++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/liblwgeom/Makefile.in b/liblwgeom/Makefile.in index 653b78a0e..60d7a38fa 100644 --- a/liblwgeom/Makefile.in +++ b/liblwgeom/Makefile.in @@ -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 diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index c580f5b7e..f417c32c1 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -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. */ diff --git a/liblwgeom/lwgeom_api.c b/liblwgeom/lwgeom_api.c index 1e9fcd8fd..ae0b50ad3 100644 --- a/liblwgeom/lwgeom_api.c +++ b/liblwgeom/lwgeom_api.c @@ -17,12 +17,27 @@ #include #include #include +#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 diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 09fc19848..c2345937c 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -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) { diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in index c862be4b2..3e9407d94 100644 --- a/postgis/postgis.sql.in +++ b/postgis/postgis.sql.in @@ -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; -- 2.50.1