Repository navigation
Restore sql/test_factory--0.5.0.sql to its true historical content - #41
jnasbyupgrade wants to merge 5 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
test_factory 0.5.0 has been the released, real-world-installed version since 2017 (confirmed: no tag for it in this repo, but the "Bump version to 0.5.0" commit is nine years old, and issue Postgres-Extensions#14 itself describes a live production failure against it). Every edit to sql/test_factory.sql on fix/issue-14-clean got silently baked into this file too, via pgxntool's own auto-regeneration (it copies the base file to sql/{ext}--{version}.sql whenever default_version matches) -- retroactively rewriting what "version 0.5.0" contains without ever bumping the version number, which is exactly the anti-pattern pgxntool's own docs warn a released version's file should never be subject to. Restored to match upstream/master (verified byte-for-byte identical), i.e. what 0.5.0 has always actually contained. The issue Postgres-Extensions#14 fix itself stays intact in the base sql/test_factory.sql file, ready for whichever new version number eventually ships it -- that decision is deliberately not made here. release_status in META.in.json/META.json is already "stable" in both files; no change needed there. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The real problem wasn't just that sql/test_factory--0.5.0.sql had drifted -- it's that test_factory.control's default_version was pinned at '0.5.0' (a real, already-released version) the whole time. Per ../ai/RELEASE.md's `stable` pseudo-version convention: between releases, default_version should sit at the literal string 'stable', so ordinary source edits regenerate sql/<ext>--stable.sql (a disposable scratch file) and never touch a frozen, already-shipped version's file. Left at a real version number, every edit to sql/test_factory.sql kept silently corrupting sql/test_factory--0.5.0.sql -- exactly what happened all session, and what would happen again on the next source edit if left as-is. Set default_version = 'stable' in both test_factory.control and test_factory_pgtap.control (test_factory_pgtap.control's own `superuser = false` addition has the identical problem, one version number earlier). Regenerated sql/test_factory--stable.sql and sql/test_factory_pgtap--stable.sql from the current source (confirmed sql/test_factory--0.5.0.sql and sql/test_factory_pgtap--0.1.0.sql are untouched by this regeneration). Added sql/test_factory--0.5.0--stable.sql, the update script from the last real release to `stable`, containing the same GRANT-if-missing logic as the fresh-install fix -- required for `ALTER EXTENSION test_factory UPDATE` to have anywhere to go at all. test/install/load.sql's update-mode branch needed a real restructuring, not just a version bump: CREATE EXTENSION test_factory VERSION '0.5.0' (the FROM version, genuinely unfixed) cannot succeed as a non-superuser -- that's the original bug, unrelated to versioning -- and extension ownership can't be transferred (`ALTER EXTENSION ... OWNER TO` isn't valid syntax, confirmed), so only the role that ran the original install can ever run ALTER EXTENSION UPDATE on it. There's no reachable "different non-superuser applies this later" scenario to test. Update mode now runs entirely as the ambient role; only fresh mode switches to test_factory_installer (which already fully covers the non-superuser install path) -- moved the issue Postgres-Extensions#14 regression check into the fresh branch specifically, since it was checking the wrong thing under update mode's ambient (typically superuser) role. Verified locally on PG12 and PG17: fresh and update modes both pass, and default_version = 'stable' means `make` no longer touches sql/test_factory--0.5.0.sql or sql/test_factory_pgtap--0.1.0.sql on any future source edit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
c0ea0e8 to
3f3fa4a
Compare
assert_version() compared installed extversion against `make -s print-PGXNVERSION`, which pulls META.json's *distribution* version (still the real semver, e.g. 0.5.0) -- unaffected by test_factory.control's default_version, which this PR pins to the literal 'stable' pseudo-version between releases. A bare CREATE EXTENSION now installs at 'stable', so the two were guaranteed to mismatch: confirmed via the pg-upgrade-test CI job failing with "test_factory in '...' is 'stable', expected '0.5.0'". Switched to `make -s print-EXTENSION_test_factory_VERSION` (from pgxntool's generated control.mk, tracks default_version directly), verified locally end-to-end: a fresh CREATE EXTENSION installs at 'stable', and bin/test_existing run-suite's own version check now reports installed='stable' expected='stable' and passes. Also picked up the ERRCODE fix in sql/test_factory--stable.sql (regenerated after rebasing onto the latest fix/issue-14-clean). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
sql/test_factory--stable.sql and sql/test_factory_pgtap--stable.sql are permanently current, not a frozen release -- per ../ai/CLAUDE.md's "Version-specific SQL files" section (referenced directly from ../ai/RELEASE.md), they'd be regenerated and re-diffed on every single source edit for zero test-coverage value if tracked. Removed from git, added sql/*--stable.sql to .gitignore. sql/test_factory--0.5.0--stable.sql (the real update script) is unaffected and stays tracked -- confirmed via git check-ignore. Verified: rm'd both files, ran `make clean && make test` (fresh and update modes) from that state -- both regenerate automatically and the full suite still passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ong context Opened with "CREATE ROLE never granted..." -- language carried over from sql/test_factory.sql's own comment, where a CREATE ROLE statement exists right above it. This file has no CREATE ROLE at all (test_factory__owner already exists on any real 0.5.0 install), so that framing described an event that never happens here, confusing about why role creation was even being discussed. Rewrote it to stand on its own: the actual issue Postgres-Extensions#14 bug (never getting SET/plain membership automatically) applies to an existing install just as much as a fresh one, which is why this update script exists at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| # and re-diffed on every source edit for zero test-coverage value if | ||
| # tracked. The update script *to* stable (sql/*--<last-release>--stable.sql) | ||
| # is not affected by this and must stay committed. | ||
| sql/*--stable.sql |
There was a problem hiding this comment.
Bug: this pattern also matches the update scripts the comment above it says are exempt.
The added comment states:
The update script to stable (
sql/*--<last-release>--stable.sql) is not affected by this and must stay committed.
But in gitignore glob syntax * matches any run of characters except /, so sql/*--stable.sql also matches sql/test_factory--0.5.0--stable.sql (with * = test_factory--0.5.0) — the very file this PR adds. It's harmless right now only because that file is already tracked (git doesn't apply .gitignore to tracked paths), but the next release's analogous update script (e.g. sql/test_factory--0.6.0--stable.sql, or a future test_factory_pgtap one) would be silently skipped by git add, shipping a distribution with no upgrade path and no error anywhere.
A negation line after it fixes this — sql/*--*--stable.sql requires two separate ---delimited segments before stable.sql, so it matches only <ext>--<version>--stable.sql update scripts, not the single-segment <ext>--stable.sql files this rule is meant to ignore:
| sql/*--stable.sql | |
| sql/*--stable.sql | |
| !sql/*--*--stable.sql |
| @@ -1,5 +1,5 @@ | |||
| comment = 'A framework for managing test data' | |||
| default_version = '0.1.0' | |||
| default_version = 'stable' | |||
There was a problem hiding this comment.
Bug: default_version moves to 'stable' here, mirroring test_factory.control, but unlike test_factory.control (which gets sql/test_factory--0.5.0--stable.sql in this same PR), there's no corresponding sql/test_factory_pgtap--0.1.0--stable.sql anywhere in this diff.
PostgreSQL's ALTER EXTENSION ... UPDATE requires a literal sql/<extension>--<from>--<to>.sql script to move between two specific versions — there's no fuzzy/partial matching. Any existing test_factory_pgtap 0.1.0 install (the version that has shipped since this extension's only release) would fail ALTER EXTENSION test_factory_pgtap UPDATE with "no update path from version "0.1.0" to version "stable"".
This isn't caught by the test suite: test/install/load.sql's update-mode branch installs test_factory_pgtap fresh (at stable directly) rather than updating it from 0.1.0, so the missing path is never exercised.
Fix: add a sql/test_factory_pgtap--0.1.0--stable.sql script (can be a no-op, since no pgtap-side objects changed) mirroring what this PR already did for test_factory.
e80485e Release 2.4.0 (#135) cca6885 Use the _PGXNTOOL_/_ prefix for internal test-gate variables and targets (#130) 88b3c11 Error when PGXNTOOL_ENABLE_TEST_INSTALL=yes but test/install/ is empty (#131) 065dd27 Validate PGXNTOOL_VERIFY_RESULTS_MODE (#132) 9cb2a53 Reject PGXNTOOL_PGTLE_VERSION values that aren't an exact pg_tle range name (#134) 51062d3 Fix `make test` failing when test/sql/ does not exist (#133) 5e5f002 check-test-install-error-stop.sh: accept \include and anchor patterns (#128) c25cdf4 Fix stale and inaccurate user docs (#129) f6fda71 Require HISTORY.asc issue numbers in ascending order (#125) 9b65063 Warn when two DOCS entries install to the same filename (issue #115) (#124) e8ed42d Guarantee test/install/*.sql schedule ordering (#120) 51c75ac Add post-tag-version-bump to freeze default_version after a release (#95) dffddf3 Only let an explicit ON_ERROR_STOP excuse a later turn-off in test/install (#122) 52b22fd Let `make results` seed a new test's first expected output (#121) af25072 CLAUDE.md: fix monitor-ci.sh doc mismatch, no --commit flag exists (#116) a3b85fe Rename build-results target to results-build (#123) 7a5f724 Import Postgres-Extensions/ai's shared CLAUDE.md into dev-facing docs (#117) 0a6db44 Gate the main test suite on test-build; add build-results; require ON_ERROR_STOP in test/install (#109) 59bb298 Add PGXNTOOL_ENABLE_FS_INSTALL and PGXNTOOL_ENABLE_PGXN_INSTALL (#91) bedf9b6 Add `make print-pgtle` target for combined pg_tle install files (#94) 5aafc8f ci: pin claude-code-action to a SHA in claude-code-review.yml (#112) 0d6bef9 Rename internal-only variables to the _PGXNTOOL_ shape (#93) 9fa8ae0 ci: bump GitHub Actions to latest versions (#98) 5d1d337 Fix claude-code-review.yml trust gate: check PR author, not head repo owner (#102) 2f36a12 Document `superuser`/`trusted`; split general PostgreSQL guidance into its own docs (#113) c50d8e6 claude-code-review.yml: allow the inline-comment MCP tool so review comments post individually (#105) a6d3287 Release 2.3.0 (#89) 1a7ee20 CLAUDE.md: fix pre-existing documentation-accuracy errors (#88) 35fd187 Fix DATA wildcard skipping historical full-install version scripts (#48) (#80) f9ce2a2 Fix installcheck running before install; make test now fails on regressions (#83) 3ceb930 Rename PGTLE_VERSION to PGXNTOOL_PGTLE_VERSION (#85) 2de8429 claude-code-review.yml: add missing --comment flag (#84) 957bdf6 Restrict @claude mention trigger to a trusted account (#82) b67064b Release 2.2.0 (#77) d949d6d Fix stale README/CLAUDE.md docs; rename internal-only test shim (#76) 6d7822c ci: grant actions:write so bun cache save succeeds (#75) 2738f59 README.asc: fix stale docs, document undocumented API surface (#74) d1d3bee Add make pgxntool-version to print the embedded pgxntool version (#73) 493a0f8 Fix parallel-build SQL corruption, remote hardcoding, and add safety checks (#61) 3b0e3de Fix make pgtle PGTLE_VERSION=X being silently ignored (#66) 21b35ef ci: skip paired-test-PR requirement for doc-only PRs (#71) 55efd03 Rename EXTENSION_VERSION_FILES to EXTENSION__CURRENT_VERSION__FILES (#69) 9d0a856 Fix pgtle.sh rejecting non-numeric version aliases like 'stable' (#57) (#63) 9c2f75f Docs: versioned SQL file tracking tradeoffs and update-testing pattern (#60) c38cf2a ci: never check out fork PR head in claude-code-review pull_request_target job (#70) aab8f2b pgtle_versions.md: fix wrong uninstall_extension() version claim (#59) e2c9174 README.asc: make tag creates a git tag, not a branch (#58) eb84bc6 Stamp 2.1.0 9fbe6f4 Fix results ordering, control file whitespace, ENABLE_* override, debug levels (#31) 88bb4f2 Add Claude Code GitHub Actions workflows (#41) af5bbbb ci: pass repo owners to run-tests.yml for fork-account matching (#40) c7928af Fix repo-root guard to work inside a git worktree (#39) b062fca ci: point reusable test workflow at @master b6cdbfd Add CI workflows and multi-session PR guard (#33) 1ba0987 Stamp 2.0.3 1931cbe Fix pgxntool-sync remote and make it runnable without make (#37) 8176304 Stamp 2.0.2 3e142ab Fix parse_control_file: remove comments before stripping quotes (#27) cacc301 Stamp 2.0.1 bf1db6b Fix bash 3.2 / Linux compatibility issues (#26) 62d0fcb Fix broken ifeq for --load-language=plpgsql on PG < 13 (#24) 121f0b3 Stamp 2.0.0 ad3ca7e Remove .source support; add test/install, test/build, and verify-results (#18) c010cf8 Fix bash 3.2 compatibility (#23) abeb9d3 Remove .source file support from pg_regress integration (#22) 08c1879 Stamp 1.1.2 6e0dad2 Fix double --dbname bug that defeated unique test database names 639756c Stamp 1.1.1 6ba3176 Fix pg_tle exception handler and empty upgrade files (#15) 3b8cb2a Stamp 1.1.0 550a901 Remove commit.md (maintained in pgxntool-test) d73ca93 Add unique test database names to prevent conflicts (#13) 9b344be Add update-setup-files.sh for 3-way merging after pgxntool-sync (#12) ab7f6e2 Stamp 1.0.0 3a571ba Add pg_tle support and modernize test infrastructure (#11) b96ea6d Add support for Claude code; build and doc improvements (#9) e9c24de Fix pg_regress on versions > 12 (#5) REVERT: bed3604 Fix pg_regress on versions > 12 (#5) (#6) git-subtree-dir: pgxntool git-subtree-split: e80485ea77ec6dbdfa1dc9217d1c8b7ed2a94f43
Summary
test_factory0.5.0 has been the released, real-world-installed version since 2017 -- issue CREATE EXTENSION fails on PG16+ without a superuser (RDS/Aurora): must be able to SET ROLE "test_factory__owner" #14 itself describes a live production failure against it.sql/test_factory.sqlonfix/issue-14-cleangot silently baked intosql/test_factory--0.5.0.sqltoo, via pgxntool's own auto-regeneration -- retroactively rewriting what "version 0.5.0" contains without ever bumping the version number.sql/test_factory--0.5.0.sqlto matchupstream/masterbyte-for-byte (verified). The issue CREATE EXTENSION fails on PG16+ without a superuser (RDS/Aurora): must be able to SET ROLE "test_factory__owner" #14 fix itself stays intact in the basesql/test_factory.sqlfile, ready for whichever version eventually ships it -- that decision isn't made here.release_statusinMETA.in.json/META.jsonis already"stable"in both -- no change needed.Stacked on #18 (
issue-14-clean, pushed to this repo for that purpose) rather than a fork-to-fork PR.Test plan
diffconfirms the restored file is byte-for-byte identical toupstream/master's version.make lintpasses.