Skip to content

Fix parallel-build SQL corruption, remote hardcoding, and add safety checks#61

Open
jnasbyupgrade wants to merge 5 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-buildsystem-batch
Open

Fix parallel-build SQL corruption, remote hardcoding, and add safety checks#61
jnasbyupgrade wants to merge 5 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix-buildsystem-batch

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Adds a Configuration Variables section to README.asc documenting all override variables, and HISTORY.asc entries for the user-visible changes above.

Related pgxntool-test PR: Postgres-Extensions/pgxntool-test#31

Fixes #7, #14, #19, #28, #50, #53.

…checks (Postgres-Extensions#7, Postgres-Extensions#14, Postgres-Extensions#19, Postgres-Extensions#28, Postgres-Extensions#50, Postgres-Extensions#53)

- Fix a real data-corruption bug: versioned SQL file generation used
  `>` truncate followed by `>>` append across two recipe lines, so a
  rule that fires twice in one `make` run (e.g. reached via two
  dependency chains under parallel make) silently doubled the file's
  content. Now written atomically via a single subshell redirect (Postgres-Extensions#19)
- `make test` never failed on a stale `test/expected/` file left
  behind after renaming/removing a test; new `check-stale-expected`
  target (run as part of `TEST_DEPS`) catches orphaned `.out` files in
  `test/sql`/`test/expected` and `test/build`/`test/build/expected` (Postgres-Extensions#14)
- Tagging targets (`tag`/`rmtag`/`forcetag`/`dist`) hardcoded the
  `origin` remote, silently re-tagging the wrong repo for maintainers
  whose `origin` is a personal fork; now configurable via
  `PGXN_REMOTE ?= origin` (Postgres-Extensions#53)
- `EXTENSION_VERSION_FILES` renamed to `EXTENSION_CURRENT_VERSION_FILES`
  — the old name implied all version files for an extension, but it
  only ever holds the current/most-recent file per extension (Postgres-Extensions#28)
- `base.mk` had no include guard, so double-inclusion (e.g. an
  extension's own `.mk` module including it alongside the Makefile's
  own include) redefined every target with overriding-recipe warnings;
  now wrapped in an `ifndef`/`endif` guard (Postgres-Extensions#50)
- `make clean`'s `EXTRA_CLEAN` targeted a nonexistent top-level
  `results/` instead of the real `$(TESTOUT)/results/` (Postgres-Extensions#7)

Verified with a full test suite run (206/206 passing, 0 skips) against
the dedicated pg_tle-preloaded cluster.

Changes only in pgxntool. No related changes in pgxntool-test.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ddb8024c-cf52-4841-a3b8-a0fcd1c98787

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ive, document all override variables, add HISTORY entries

- check-stale-expected (Postgres-Extensions#14) false-flagged pg_regress's alternate
  expected-output files (test_0.out .. test_9.out -- a real,
  widely-used convention: pg_tle's own test suite ships
  pg_tle_perms_1.out/pg_tle_versions_1.out, as do pgtap/pglogical).
  Now strips a trailing _N before checking for a matching .sql.
- Consolidate EXTRA_CLEAN's filter-out and += into a single assignment
  (no reason they needed to be separate lines)
- Add a `Configuration Variables` section to README.asc documenting
  every override variable in base.mk (PGXN_REMOTE, ASCIIDOC,
  PG_CONFIG, TESTDIR, TESTOUT, PGXNTOOL_VERIFY_RESULTS_MODE, and the
  three PGXNTOOL_ENABLE_* flags, PGXNTOOL_NO_PGXS_INCLUDE) -- previously
  only scattered partially across the doc, with several undocumented
  entirely
- Add HISTORY.asc entries for the user-visible changes in this PR,
  most importantly the EXTENSION_VERSION_FILES rename since it can
  break a Makefile that references the old name directly

Changes only in pgxntool. Related changes in pgxntool-test:
- New test/standard/*.bats coverage for Postgres-Extensions#7, Postgres-Extensions#14, Postgres-Extensions#19, Postgres-Extensions#50, Postgres-Extensions#53
  (see paired pgxntool-test PR)

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
… it after pg_regress, rename to EXTENSION__CURRENT_VERSION__FILES

- check-stale-expected's logic moved to check-stale-expected.sh (enough
  code to warrant a real script over an inline recipe). The base/alt
  filename computation no longer tracks a separate found/not-found
  flag -- $base is always resolved to the right value before the one
  existence check.
- check-stale-expected now depends on `installcheck` directly, so it
  runs after pg_regress rather than before. TEST_DEPS list position
  doesn't guarantee ordering between unrelated prerequisites; an
  explicit dependency edge does.
- EXTENSION_CURRENT_VERSION_FILES renamed to
  EXTENSION__CURRENT_VERSION__FILES for clearer segmentation.
- README.asc: converted the Configuration Variables section from
  AsciiDoc labeled lists to `===` subsections per variable, and flagged
  the yes/no-only variables with a `*` marker plus an explanatory note,
  instead of repeating the constraint in every entry.
- Tightened the two new HISTORY.asc entries that were more verbose than
  the rest of the changelog's style.

Changes only in pgxntool. Related changes in pgxntool-test:
- Rewrote the check-stale-expected ordering test to verify the new
  dependency-based ordering via `make -n test` dry-run, and to prove
  make test only fails on a stale file after pg_regress has actually
  produced results
- Added check-stale-expected.sh to the dist file-count manifest

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This PR was getting too large; the rename is independent of the other
fixes here (check-stale-expected, the parallel-build race, PGXN_REMOTE,
the include guard) and doesn't need any test changes, so it's cleaner
as its own PR straight from EXTENSION_VERSION_FILES to
EXTENSION__CURRENT_VERSION__FILES.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…re TEST_DEPS at the target, validate expected/ file types, add enable toggles

- Moved check-stale-expected.sh to test/bin/check-stale-expected.sh
  (fixed its lib.sh source path accordingly)
- TEST_DEPS += check-stale-expected now lives directly under the
  target's own definition, not down in the TEST_DEPS assembly section
  -- the base `TEST_DEPS = testdeps` assignment moved up ahead of it so
  the += there is well-defined
- check-stale-expected.sh: added comments explaining the nullglob
  guard and the pg_regress alternate-file (_N.out) convention; removed
  the redundant existence check that decided whether to strip a _N
  suffix -- recognizing the pattern is pure string matching and doesn't
  need a stat call, so there's now exactly one existence check per file
  (documented tradeoff: a real test literally named foo_1 with no
  foo.sql would be misflagged -- accepted as vanishingly rare)
- expected/ is now also checked for non-*.out files (stray editor
  files, .orig files, etc.), a distinct failure class from an orphaned
  .out file with its own message and exit-code bit, independently
  disable-able via PGXNTOOL_CHECK_EXPECTED_FILE_TYPES
- Added PGXNTOOL_ENABLE_CHECK_STALE_EXPECTED to make the whole check a
  no-op if wanted, following the same pattern as the other
  PGXNTOOL_ENABLE_* variables; documented both new variables in
  README.asc, plus a note pointing at Postgres-Extensions#30 for the larger
  override-any-recipe question this doesn't attempt to solve
- README.asc: split PGXNTOOL_VERIFY_RESULTS_MODE's two modes into their
  own subsections instead of one paragraph

Changes only in pgxntool. Related changes in pgxntool-test:
- Update dist-expected-files.txt for the new script path
- Extend check-stale-expected.bats for the new file-type check and
  both enable/disable toggles; fix the ordering test to filter out
  test-build's own (unrelated) pg_regress invocation, which the
  TEST_DEPS reordering above exposed

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
jnasbyupgrade added a commit to jnasbyupgrade/pgxntool that referenced this pull request Jul 26, 2026
…ostgres-Extensions#28)

The old name implied it listed every version file for an extension; it
actually only ever holds the current/most-recent one per extension.
Split out of Postgres-Extensions#61 to keep that PR's scope down.

If your Makefile references EXTENSION_VERSION_FILES directly (e.g. to
add extra dependencies to DATA), update it to
EXTENSION__CURRENT_VERSION__FILES.

Changes only in pgxntool. Related changes in pgxntool-test:
- Update the one code comment referencing the old name in
  test/sequential/02-dist.bats

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
jnasbyupgrade added a commit to jnasbyupgrade/pgxntool that referenced this pull request Jul 26, 2026
…ostgres-Extensions#28)

The old name implied it listed every version file for an extension; it
actually only ever holds the current/most-recent one per extension.
Split out of Postgres-Extensions#61 to keep that PR's scope down.

If your Makefile references EXTENSION_VERSION_FILES directly (e.g. to
add extra dependencies to DATA), update it to
EXTENSION__CURRENT_VERSION__FILES.

Changes only in pgxntool. Related changes in pgxntool-test:
- Update the one code comment referencing the old name in
  test/sequential/02-dist.bats

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
jnasbyupgrade added a commit to jnasbyupgrade/pgxntool that referenced this pull request Jul 26, 2026
…ostgres-Extensions#28)

The old name implied it listed every version file for an extension; it
actually only ever holds the current/most-recent one per extension.
Split out of Postgres-Extensions#61 to keep that PR's scope down.

If your Makefile references EXTENSION_VERSION_FILES directly (e.g. to
add extra dependencies to DATA), update it to
EXTENSION__CURRENT_VERSION__FILES.

Changes only in pgxntool. Related changes in pgxntool-test:
- Update the one code comment referencing the old name in
  test/sequential/02-dist.bats

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

results/ is used as a clean target instead of test/results/

1 participant