From 4ff8a6d0f022621fd395843fea85b3cf0451e864 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 10 Feb 2012 19:49:53 +0000 Subject: [PATCH] Report SVN revision in PostGIS_Full_Version (#1518) git-svn-id: http://svn.osgeo.org/postgis/trunk@9149 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/lwgeom_functions_basic.c | 17 +++++++++++++++-- postgis/postgis.sql.in.c | 10 ++++++++++ postgis_config.h.in | 8 +++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 4883cb7d6..31ed0793c 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -36,6 +36,7 @@ Datum postgis_autocache_bbox(PG_FUNCTION_ARGS); Datum postgis_scripts_released(PG_FUNCTION_ARGS); Datum postgis_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); Datum postgis_lib_build_date(PG_FUNCTION_ARGS); Datum LWGEOM_length2d_linestring(PG_FUNCTION_ARGS); @@ -145,6 +146,16 @@ Datum postgis_lib_version(PG_FUNCTION_ARGS) PG_RETURN_TEXT_P(result); } +PG_FUNCTION_INFO_V1(postgis_svn_version); +Datum postgis_svn_version(PG_FUNCTION_ARGS) +{ + text *result; + char ver[256]; + snprintf(ver, 256, "%d", SVNREV); + result = cstring2text(ver); + PG_RETURN_TEXT_P(result); +} + PG_FUNCTION_INFO_V1(postgis_lib_build_date); Datum postgis_lib_build_date(PG_FUNCTION_ARGS) { @@ -156,8 +167,10 @@ Datum postgis_lib_build_date(PG_FUNCTION_ARGS) PG_FUNCTION_INFO_V1(postgis_scripts_released); Datum postgis_scripts_released(PG_FUNCTION_ARGS) { - char *ver = POSTGIS_SCRIPTS_VERSION; - text *result = cstring2text(ver); + char ver[256]; + text *result; + snprintf(ver, 256, "%s.%s r%d", POSTGIS_MAJOR_VERSION, POSTGIS_MINOR_VERSION, SVNREV); + result = cstring2text(ver); PG_RETURN_TEXT_P(result); } diff --git a/postgis/postgis.sql.in.c b/postgis/postgis.sql.in.c index 92e8d6c76..a4bcaab90 100644 --- a/postgis/postgis.sql.in.c +++ b/postgis/postgis.sql.in.c @@ -2302,6 +2302,10 @@ CREATE OR REPLACE FUNCTION postgis_lib_version() RETURNS text AS 'MODULE_PATHNAME' LANGUAGE 'C' IMMUTABLE; -- a new lib will require a new session +CREATE OR REPLACE FUNCTION postgis_svn_version() RETURNS text + AS 'MODULE_PATHNAME' + LANGUAGE 'C' IMMUTABLE; + -- NOTE: starting at 1.1.0 this is the same of postgis_lib_version() CREATE OR REPLACE FUNCTION postgis_scripts_released() RETURNS text AS 'MODULE_PATHNAME' @@ -2331,6 +2335,7 @@ CREATE OR REPLACE FUNCTION postgis_full_version() RETURNS text AS $$ DECLARE libver text; + svnver text; projver text; geosver text; gdalver text; @@ -2354,6 +2359,7 @@ BEGIN SELECT postgis_uses_stats() INTO usestats; SELECT postgis_scripts_installed() INTO dbproc; SELECT postgis_scripts_released() INTO relproc; + SELECT postgis_svn_version() INTO svnver; fullver = 'POSTGIS="' || libver || '"'; @@ -2372,6 +2378,10 @@ BEGIN IF libxmlver IS NOT NULL THEN fullver = fullver || ' LIBXML="' || libxmlver || '"'; END IF; + + IF svnver IS NOT NULL THEN + fullver = fullver || ' SVN_REVISION=' || svnver; + END IF; IF usestats THEN fullver = fullver || ' USE_STATS'; diff --git a/postgis_config.h.in b/postgis_config.h.in index 0012b735e..cff57a693 100644 --- a/postgis_config.h.in +++ b/postgis_config.h.in @@ -1,5 +1,7 @@ /* postgis_config.h.in. Generated from configure.ac by autoheader. */ +#include "svnrevision.h" + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS @@ -127,12 +129,12 @@ /* PostGIS major version */ #undef POSTGIS_MAJOR_VERSION -/* PostGIS micro version */ -#undef POSTGIS_MICRO_VERSION - /* PostGIS minor version */ #undef POSTGIS_MINOR_VERSION +/* PostGIS micro version */ +#undef POSTGIS_MICRO_VERSION + /* PostgreSQL server version */ #undef POSTGIS_PGSQL_VERSION -- 2.40.0