From f64f498afb572de4f8cb85ddf33d55a5d64cb2c1 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 5 Jul 2021 15:35:10 +0900 Subject: [PATCH] Be more flexible when parsing the output from pg_config --version The string may not always start with "PostgreSQL" when building against non-community versions. Life would be much easier here if there was an option like "pg_config --version-number" or similar. --- configure | 6 +++--- configure.in | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index f270e1f1..8189a88f 100755 --- a/configure +++ b/configure @@ -1811,11 +1811,11 @@ 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/') + $SED -e 's/^[^0-9]\+ \([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/') + $SED -e 's/^[^0-9]\+ \([0-9]*\)\.\([0-9]*\)\([a-zA-Z0-9.]*\)$/\1.\2/') if test -z "$version_num"; then as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5 @@ -1829,7 +1829,7 @@ if test "$major_version_num" -lt '10'; then fi else version_num=$(echo "$pgac_pg_config_version"| - $SED -e 's/^PostgreSQL \(.\+\)$/\1/') + $SED -e 's/^[^0-9]\+ \(.\+\)$/\1/') if test -z "$version_num"; then as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5 diff --git a/configure.in b/configure.in index 0719cbf4..7b3f206d 100644 --- a/configure.in +++ b/configure.in @@ -19,11 +19,11 @@ 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/') + $SED -e 's/^[[^0-9]]\+ \([[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/') + $SED -e 's/^[[^0-9]]\+ \([[0-9]]*\)\.\([[0-9]]*\)\([[a-zA-Z0-9.]]*\)$/\1.\2/') if test -z "$version_num"; then AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?]) @@ -37,7 +37,7 @@ if test "$major_version_num" -lt '10'; then fi else version_num=$(echo "$pgac_pg_config_version"| - $SED -e 's/^PostgreSQL \(.\+\)$/\1/') + $SED -e 's/^[[^0-9]]\+ \(.\+\)$/\1/') if test -z "$version_num"; then AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?])