Commit 4fc5b664 authored by Sandro Santilli's avatar Sandro Santilli

Refuse to load PostGIS in an untargeted PostgreSQL version

Helps user finding out what problems they have when this happens

git-svn-id: http://svn.osgeo.org/postgis/trunk@17341 b70326c6-7e19-0410-871a-916f4a2858ee
parent 82b562f0
Pipeline #51665154 passed with stage
in 24 minutes and 52 seconds
......@@ -466,6 +466,7 @@ if test "x$LIBLWGEOM_ONLY" = "xno"; then
fi
POSTGIS_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
POSTGIS_PGSQL_HR_VERSION="$PGSQL_MAJOR_VERSION.$PGSQL_MINOR_VERSION"
PGSQL_PKGLIBDIR=`"$PG_CONFIG" --pkglibdir`
PGSQL_LIBDIR=`"$PG_CONFIG" --libdir`
......@@ -550,6 +551,8 @@ if test "x$LIBLWGEOM_ONLY" = "xno"; then
AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_VERSION], [$POSTGIS_PGSQL_VERSION], [PostgreSQL server version])
AC_SUBST([POSTGIS_PGSQL_VERSION])
AC_DEFINE_UNQUOTED([POSTGIS_PGSQL_HR_VERSION], [$POSTGIS_PGSQL_HR_VERSION], [PostgreSQL human readable server version])
AC_SUBST([POSTGIS_PGSQL_HR_VERSION])
AC_SUBST([HAVE_SPGIST])
fi dnl LIBLWGEOM_ONLY != no
......
......@@ -25,6 +25,27 @@
BEGIN;
SET LOCAL client_min_messages TO warning;
DO $$
DECLARE
pgver text;
BEGIN
SELECT substring(version(), 'PostgreSQL ([0-9\.]+)') INTO pgver;
IF POSTGIS_PGSQL_VERSION::text != ( SELECT CASE
WHEN split_part(s,'.',1)::integer > 9
THEN split_part(s,'.',1) || '0'
ELSE
split_part(s,'.', 1) || split_part(s,'.', 2)
END
FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s )
THEN
RAISE EXCEPTION 'PostGIS built for PostgreSQL % cannot be loaded in PostgreSQL %',
POSTGIS_PGSQL_HR_VERSION, pgver;
END IF;
END;
$$;
-- Check that no other postgis is installed
DO $$
DECLARE
......@@ -2952,7 +2973,7 @@ BEGIN
fullver = fullver || ' PGSQL="' || pgsql_scr_ver || '"';
IF pgsql_scr_ver != pgsql_ver THEN
fullver = fullver || ' (procs need upgrade for use with "' || pgsql_ver || '")';
fullver = fullver || ' (procs need upgrade for use with PostgreSQL "' || pgsql_ver || '")';
END IF;
IF geosver IS NOT NULL THEN
......
......@@ -7,6 +7,7 @@
* Define just the version numbers; otherwise we get some strange substitutions in postgis.sql.in
*/
#define POSTGIS_PGSQL_VERSION @POSTGIS_PGSQL_VERSION@
#define POSTGIS_PGSQL_HR_VERSION @POSTGIS_PGSQL_HR_VERSION@
#define POSTGIS_GEOS_VERSION @POSTGIS_GEOS_VERSION@
#define POSTGIS_PROJ_VERSION @POSTGIS_PROJ_VERSION@
#define POSTGIS_LIB_VERSION '@POSTGIS_LIB_VERSION@'
......
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