diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-08-05 19:16:05 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-08-05 19:16:10 +0200 |
| commit | 277411655ee3f7753433376af8bbefa1a98380ab (patch) | |
| tree | 9393b695430b07874b529d7b78914e3e2a1bcc35 | |
| parent | 197c01ef7119c4a9bfec4cf3793d90496ea5868f (diff) | |
| download | go-gg-277411655ee3f7753433376af8bbefa1a98380ab.tar.gz | |
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.
| -rw-r--r-- | CHANGELOG.md | 6 | ||||
| -rw-r--r-- | 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 <majewsky@gmx.net> 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] |
