Skip to content

Commit c92ab3d

Browse files
committed
configure: robustly parse pg_config version for PGDG/PG18
The existing version detection relied on a strict sed pattern that could fail with PGDG-style pg_config output (e.g. "PostgreSQL 18.1 (Debian 18.1-...)"), causing ./configure to error with "Could not detect PostgreSQL version". Switch to extracting the numeric major[.minor] token from `pg_config --version` and then normalizing 10+ releases to the major version. This makes configure work reliably for PostgreSQL 18 and packaged builds across distros.
1 parent 6e314ee commit c92ab3d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

configure

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,11 +2549,13 @@ fi
25492549
25502550
# check we're building against a supported version of PostgreSQL
25512551
citusac_pg_config_version=$($PG_CONFIG --version 2>/dev/null)
2552-
version_num=$(echo "$citusac_pg_config_version"|
2553-
$SED -e 's/^PostgreSQL \([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)$/\1\2/')
2552+
# Extract major[.minor] from "PostgreSQL X[.Y] ..."
2553+
version_num=$(printf '%s\n' "$citusac_pg_config_version" \
2554+
| $SED -nE 's/^PostgreSQL[[:space:]]+([0-9]+(\.[0-9]+)?).*/\1/p')
25542555
2555-
# if PostgreSQL version starts with two digits, the major version is those digits
2556-
version_num=$(echo "$version_num"| $SED -e 's/^\([0-9]\{2\}\)\(.*\)$/\1/')
2556+
# If it starts with two digits (10+), keep only the major.
2557+
version_num=$(printf '%s\n' "$version_num" \
2558+
| $SED -E 's/^([0-9]{2}).*$/\1/')
25572559
25582560
if test -z "$version_num"; then
25592561
as_fn_error $? "Could not detect PostgreSQL version from pg_config." "$LINENO" 5

0 commit comments

Comments
 (0)