]> granicus.if.org Git - postgis/commitdiff
Add check for liblwgeom version mismatch in postgis_full_version()
authorSandro Santilli <strk@keybit.net>
Thu, 1 Oct 2015 20:09:57 +0000 (20:09 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 1 Oct 2015 20:09:57 +0000 (20:09 +0000)
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
liblwgeom/liblwgeom.h.in
liblwgeom/lwgeom_api.c
postgis/lwgeom_functions_basic.c
postgis/postgis.sql.in

index 653b78a0ee577168d216c5369331dadbc0f38873..60d7a38fa5dd2938df2020eb1d3feae484263dc6 100644 (file)
@@ -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
index c580f5b7e4fb8b2f4604911e3343921db37597ac..f417c32c1c44ba603c04dbdab2ab65329c1ece7b 100644 (file)
@@ -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.
 */
index 1e9fcd8fd5bd10451f085758b10784a5d31dfb30..ae0b50ad339ee02f6343347bdcb94dbaa57c11a3 100644 (file)
 #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
index 09fc1984863738b0c2f5cfffe02037d4797cec03..c2345937c7e43d1e77144fcc07c91bb92c9ba2ee 100644 (file)
@@ -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)
 {
index c862be4b2d64db46c91ebe83312caa3b751a45fe..3e9407d94520fba52afdce883892c004c80c2a88 100644 (file)
@@ -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;