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`
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
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
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
* 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@'