Improve PostgreSQL version detection

Need to consider different numbering system from PostgreSQL 10.
This commit is contained in:
Ian Barwick
2017-04-19 10:12:52 +09:00
parent e306eb213b
commit 2704ab0536
2 changed files with 47 additions and 21 deletions

15
configure vendored
View File

@@ -1803,6 +1803,11 @@ if test -z "$PG_CONFIG"; then
fi
pgac_pg_config_version=$($PG_CONFIG --version 2>/dev/null)
major_version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \([0-9]\{1,2\}\).*$/\1/')
if test "$major_version_num" -lt '10'; then
version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \([0-9]*\)\.\([0-9]*\)\([a-zA-Z0-9.]*\)$/\1.\2/')
@@ -1815,10 +1820,18 @@ version_num_int=$(echo "$version_num"|
if test "$version_num_int" -lt '93'; then
as_fn_error $? "repmgr is not compatible with detected PostgreSQL version: $version_num" "$LINENO" 5
fi
else
version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \(.\+\)$/\1/')
if test -z "$version_num"; then
as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5
$as_echo "$as_me: building against PostgreSQL $version_num" >&6;}
fi
# add includedir to prerequisites, so tests for headers can succeed
CPPFLAGS="-I$($PG_CONFIG --includedir-server) $CFLAGS"

View File

@@ -15,6 +15,11 @@ if test -z "$PG_CONFIG"; then
fi
pgac_pg_config_version=$($PG_CONFIG --version 2>/dev/null)
major_version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \([[0-9]]\{1,2\}\).*$/\1/')
if test "$major_version_num" -lt '10'; then
version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \([[0-9]]*\)\.\([[0-9]]*\)\([[a-zA-Z0-9.]]*\)$/\1.\2/')
@@ -27,9 +32,17 @@ version_num_int=$(echo "$version_num"|
if test "$version_num_int" -lt '93'; then
AC_MSG_ERROR([repmgr is not compatible with detected PostgreSQL version: $version_num])
else
AC_MSG_NOTICE([building against PostgreSQL $version_num])
fi
else
version_num=$(echo "$pgac_pg_config_version"|
$SED -e 's/^PostgreSQL \(.\+\)$/\1/')
if test -z "$version_num"; then
AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?])
fi
fi
AC_MSG_NOTICE([building against PostgreSQL $version_num])
# add includedir to prerequisites, so tests for headers can succeed
CPPFLAGS="-I$($PG_CONFIG --includedir-server) $CFLAGS"