From 277411655ee3f7753433376af8bbefa1a98380ab Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Wed, 5 Aug 2026 19:16:05 +0200 Subject: pgruntime: fix `psql --version` parsing on Ubuntu This currently breaks all repeated calls to WithTestDB (i.e., all users where more than two packages call WithTestDB) within GH Actions. --- CHANGELOG.md | 6 ++++++ pgruntime/testdb.go | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 181176a..638d50d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ SPDX-FileCopyrightText: 2026 Stefan Majewsky SPDX-License-Identifier: Apache-2.0 --> +# v1.13.1 (TBD) + +Changes: + +- pgruntime: Fix PostgreSQL version detection on Linux distributions with nonstandard `psql --version` output. + # v1.13.0 (2026-08-01) Changes: diff --git a/pgruntime/testdb.go b/pgruntime/testdb.go index 808784c..aa10c66 100644 --- a/pgruntime/testdb.go +++ b/pgruntime/testdb.go @@ -181,10 +181,13 @@ func wipeDBIfMajorUpgrade(testdbPath string) error { return fmt.Errorf("could not run `psql --version`: %w", err) } - // output from `psql --version` should look like e.g. "psql (PostgreSQL) 18.4" -> we want just the version number part + // output from `psql --version` should look like e.g. + // "psql (PostgreSQL) 18.4" (seen on Arch Linux) + // "psql (PostgreSQL) 18.4 (Ubuntu 18.4-0ubuntu0.26.04.1)" (seen on Ubuntu) + // -> we want just the version number part clientOutput := strings.TrimSpace(string(buf)) fields := strings.Fields(clientOutput) - if len(fields) != 3 || fields[0] != "psql" || fields[1] != "(PostgreSQL)" { + if len(fields) < 3 || fields[0] != "psql" || fields[1] != "(PostgreSQL)" { return fmt.Errorf("unexpected output from `psql --version`: %q", clientOutput) } clientVersion := fields[2] -- cgit v1.3.1