From bdb9371c797a1895b4872f83b48dd2ec710612fb Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Sun, 26 Jul 2026 13:52:10 -0500 Subject: [PATCH 1/2] Fix pgtle.sh rejecting non-numeric version aliases like 'stable' (#57) extract_version_from_filename() required every version segment to start with a digit ([0-9][0-9.]*), so extensions using the persistent 'stable' pseudo-version convention (default_version = 'stable', with files like sql/--stable.sql and sql/--1.0.0--stable.sql) failed with "Cannot parse version from filename". pg_tle itself treats extension versions as opaque strings - check_valid_version_name() in pg_tle's tleextension.c only forbids empty strings, "--", and leading/trailing "-", with no numeric requirement. Widened the regex to the same rule: each version segment is now [^-]+(-[^-]+)*, matching how default_version is already treated everywhere else in pgxntool. Unrelated to this: pgtle.sh separately does real numeric version comparison in parse_version()/version_to_number()/get_version_dir(), but that parses pg_tle's own installed version to pick a capability tier (1.0.0-1.4.0 / 1.4.0-1.5.0 / 1.5.0+), not the extension's version - the digit-only regex here appears to have been copied from that unrelated logic. --- HISTORY.asc | 13 +++++++++++++ pgtle.sh | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/HISTORY.asc b/HISTORY.asc index b0894da..d0471ab 100644 --- a/HISTORY.asc +++ b/HISTORY.asc @@ -1,3 +1,16 @@ +STABLE +------ +== Fix `pgtle.sh` rejecting non-numeric version aliases like `stable` +`extract_version_from_filename()` required every version segment to start +with a digit, so extensions using the persistent `stable` pseudo-version +convention (`default_version = 'stable'`, with files like +`sql/--stable.sql` and `sql/--1.0.0--stable.sql`) failed outright +with "Cannot parse version from filename". pg_tle itself treats extension +versions as opaque strings (`check_valid_version_name()` in pg_tle's +`tleextension.c` only forbids empty strings, `--`, and leading/trailing `-`), +so the digit-only regex was pgxntool's own unnecessary restriction. Widened +to accept any version segment matching that same, more permissive rule. + 2.1.0 ----- == Fix setup.sh / pgxntool-sync.sh / update-setup-files.sh inside a git worktree diff --git a/pgtle.sh b/pgtle.sh index 124ca84..e6229fd 100755 --- a/pgtle.sh +++ b/pgtle.sh @@ -593,10 +593,18 @@ extract_version_from_filename() { # Match patterns: # - ext--1.0.0 → FROM_VERSION=1.0.0, TO_VERSION="" # - ext--1.0.0--2.0.0 → FROM_VERSION=1.0.0, TO_VERSION=2.0.0 + # - ext--stable → FROM_VERSION=stable, TO_VERSION="" (pg_tle treats + # versions as opaque strings; see check_valid_version_name() in + # pg_tle's tleextension.c, which only forbids empty strings, "--", + # and leading/trailing "-" — no numeric requirement) + # + # Each version segment is [^-]+(-[^-]+)* : one or more non-dash runs + # joined by single dashes, so a segment can't be empty, start/end with + # "-", or contain "--" (which is reserved as the FROM/TO delimiter). - if [[ "$basename" =~ ^${EXTENSION}--([0-9][0-9.]*)(--([0-9][0-9.]*))?$ ]]; then + if [[ "$basename" =~ ^${EXTENSION}--([^-]+(-[^-]+)*)(--([^-]+(-[^-]+)*))?$ ]]; then FROM_VERSION="${BASH_REMATCH[1]}" - TO_VERSION="${BASH_REMATCH[3]}" # Empty for non-upgrade files + TO_VERSION="${BASH_REMATCH[4]}" # Empty for non-upgrade files return 0 else die 1 "Cannot parse version from filename: $filename From 43f7c2ee8195a656948331859adf663f15bc8f01 Mon Sep 17 00:00:00 2001 From: jnasbyupgrade Date: Sun, 26 Jul 2026 16:37:57 -0500 Subject: [PATCH 2/2] Shorten HISTORY.asc entry for #57 to match house style --- HISTORY.asc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/HISTORY.asc b/HISTORY.asc index d0471ab..08fcd1e 100644 --- a/HISTORY.asc +++ b/HISTORY.asc @@ -2,14 +2,10 @@ STABLE ------ == Fix `pgtle.sh` rejecting non-numeric version aliases like `stable` `extract_version_from_filename()` required every version segment to start -with a digit, so extensions using the persistent `stable` pseudo-version -convention (`default_version = 'stable'`, with files like -`sql/--stable.sql` and `sql/--1.0.0--stable.sql`) failed outright -with "Cannot parse version from filename". pg_tle itself treats extension -versions as opaque strings (`check_valid_version_name()` in pg_tle's -`tleextension.c` only forbids empty strings, `--`, and leading/trailing `-`), -so the digit-only regex was pgxntool's own unnecessary restriction. Widened -to accept any version segment matching that same, more permissive rule. +with a digit, so extensions using a persistent `stable` pseudo-version +(`default_version = 'stable'`) failed with "Cannot parse version from +filename". Widened to accept any non-empty, `--`-free version string, +matching how pg_tle itself treats extension versions. 2.1.0 -----