Fix Makefile PG version check breaking on pre-release versions#32
Fix Makefile PG version check breaking on pre-release versions#32maqeel75 wants to merge 1 commit into
Conversation
The check-pg-version target derived pg_version_num with a regex that
required a MAJOR.MINOR dotted format. PostgreSQL pre-release builds
report a version like "19beta1" with no dot, so the substitution did
not match and left the full descriptive string in place.
On Debian/Ubuntu, pg_config --version also appends a distro suffix,
e.g. "PostgreSQL 19beta1 (Ubuntu 19~beta1-1.noble)". The unmatched
string then flowed into the shell test as:
if [ 19beta1 (Ubuntu 19~beta1-1.noble) -lt 14 ]; then
which fails under dash (/bin/sh on Debian/Ubuntu) with:
/bin/sh: 1: Syntax error: "(" unexpected (expecting "then")
breaking the PG19 .deb build. (RPM builds happened to survive only
because their version string has no parenthetical suffix.)
Parse just the leading major-version integer and quote the value in
the test so it is robust for both pre-release and stable versions on
dash and bash.
Up to standards ✅🟢 Issues
|
📝 WalkthroughWalkthroughThe Makefile's PostgreSQL version compatibility check was modified to extract only the leading major version number from 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Makefile (1)
66-76: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueLGTM — regex correctly isolates the major version for pre-release strings.
The anchored
sed -E 's/^PostgreSQL ([0-9]+).*/\1/'properly extracts just the leading integer from strings likePostgreSQL 19beta1 (Ubuntu 19~beta1-1.noble), and quoting"$(pg_version_num)"in the-lttest avoids the dash word-splitting failure described in the PR. This matches the documentedpg_config --versionoutput format (PostgreSQL MAJOR.MINORor pre-release variants).One minor defensive note: if
pg_config --versionoutput ever lacks the literalPostgreSQLprefix (unexpected but not impossible across future toolchains/packagers), the anchored substitution silently no-ops andpg_version_numbecomes non-numeric, causing the shell-lttest to fail with a generic "integer expression expected" error instead of the intended message. Not a blocker given the current well-established output format.web_search: pg_config --version output format
Confirmed the standard output format is "The output displays the “14.6” version of PostgreSQL that is currently installed in Ubuntu.", i.e., prefixed with "PostgreSQL".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Makefile` around lines 66 - 76, Add defensive validation to handle edge cases where the pg_config --version output lacks the expected PostgreSQL prefix and the pg_version_num variable fails to extract a valid numeric value. Modify the check-pg-version target to validate that pg_version_num contains a numeric value before performing the -lt comparison, and provide a clear error message (e.g., indicating that pg_config output format is unexpected) if validation fails, rather than allowing the generic "integer expression expected" error to surface to users.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Makefile`:
- Around line 66-76: Add defensive validation to handle edge cases where the
pg_config --version output lacks the expected PostgreSQL prefix and the
pg_version_num variable fails to extract a valid numeric value. Modify the
check-pg-version target to validate that pg_version_num contains a numeric value
before performing the -lt comparison, and provide a clear error message (e.g.,
indicating that pg_config output format is unexpected) if validation fails,
rather than allowing the generic "integer expression expected" error to surface
to users.
Problem
The
check-pg-versiontarget derivespg_version_numwith a regex that requires aMAJOR.MINORdotted format:PostgreSQL pre-release builds report a version like
19beta1— no dot — so the substitution does not match and the full descriptive string is left in place.On Debian/Ubuntu,
pg_config --versionalso appends a distro suffix, e.g.:The unmatched string then flows into the shell test as:
which fails under
dash(/bin/shon Debian/Ubuntu):This breaks the PostgreSQL 19
.debbuild. RPM builds happened to survive only because the RHEL version string has no parenthetical suffix (PostgreSQL 19beta1), so the numeric test quietly no-op'd and theiffell through.Note the extension's C sources compile cleanly against PG19 on both platforms — this is purely a version-check parsing bug.
Fix
Parse just the leading major-version integer and quote the value in the test, so it is robust for both pre-release and stable versions under
dashandbash:Verification
Parsed major +
[ … -lt 14 ]underdashfor each real version string:pg_config --versionPostgreSQL 19beta1 (Ubuntu 19~beta1-1.noble)19PostgreSQL 19beta119PostgreSQL 17.617PostgreSQL 14.12 (Debian 14.12-1)14PostgreSQL 13.213