Always install count_nulls into a fresh, randomly named schema for tests - #55
Conversation
Replace the two-value TEST_SCHEMA axis (fixed "" and "Quoted" legs, run via make test-schema-all's in-Makefile loop) with a single install per run into a freshly, randomly generated schema whose constant prefix (a literal trailing space) always requires SQL identifier quoting. This exercises %I- qualification on every run instead of only on a dedicated quoting leg, and removes the Makefile/GUC-propagation infrastructure that existed solely to support the two-value axis. Cleanup-before-create matches on the constant prefix to find and drop any schema left behind by a run that crashed before its own teardown, so stale schemas don't accumulate. test/helpers/find_test_schema.sql lets separate sessions (bin/test_existing's per-step psql invocations) rediscover the randomly generated name. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
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 |
|
Claude finished @jnasbyupgrade's task in 2m 7s —— View job Claude finished reviewing this PR
SummaryThis is a solid, well-documented simplification: replacing the two-value FindingStale
These now point at a Makefile variable that no longer exists, which will confuse future readers following the "see TEST_SCHEMA" pointers. Worth a follow-up comment update (e.g. "see 'Schema targeting' in test/README.md" or similar) to match the terminology the rest of the PR standardized on. I did not find any other dangling references to |
These two comments referenced "TEST_SCHEMA in the Makefile" / "TEST_SCHEMA" directly, a concept this PR removed elsewhere - point them at the "Schema targeting" section of test/README.md instead. teardown__search_path_unchanged's own comment (which also mentions an early design phase with no TEST_SCHEMA concept) is left as-is: it's accurate historical scoping about that function's own reasoning, not a claim about the current codebase. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude finished @jnasbyupgrade's task in 3m 18s —— View job Reviewing PR #55
SummaryThis is a clean simplification: a single, always-randomized, always-quoting-required install schema replaces the two-value
No new issues found. The prior review's finding (stale |
The wording made it sound like installing into a random schema is how count_nulls behaves as a product, rather than a testing-time decision. Reword and shorten it to lead with "during testing", with a pointer to test/install/load.sql and test/README.md for the mechanics instead of restating them here.
…schema.sql test/install/load.sql and bin/test_existing.sql/create_extension.sql duplicated the same cleanup-before-create + random-name + CREATE SCHEMA + CREATE EXTENSION logic, differing only in whether a VERSION was pinned. Move it into a single test/helpers/create_test_schema.sql, parameterized by a :version psql variable (empty = no VERSION clause), and have both callers \i/-f it instead of keeping their own copies. test/install/load.sql now does `\set version ...` then `\i`s the shared file for both its fresh and update modes; bin/test_existing's create_extension_in_schema() now points -f directly at the shared file. bin/test_existing.sql/create_extension.sql is removed, fully superseded.
Replace the hand-rolled count-then-RAISE EXCEPTION validation with SELECT ... INTO STRICT, which raises Postgres's own no_data_found/too_many_rows when the query doesn't resolve to exactly one row, instead of re-implementing that check. The actual :test_schema capture stays a separate plain SELECT + \gset, since a DO block can't populate a psql variable itself (a \gset following one just silently re-executes it and sets nothing).
|
Claude finished @jnasbyupgrade's task in 2m 41s —— View job Reviewing PR #55
SummaryRe-reviewed the full diff against Specific things I traced end-to-end and confirmed correct:
Minor nit (not blocking)
No other issues found. Nice use of |
…t empty Empty :version was being treated as a deliberate "install current" signal. That's ambiguous: a caller whose :version was supposed to carry a real version but ended up empty due to an upstream bug would silently install current instead of failing loudly - the same class of footgun this codebase already guards against elsewhere (see test/install/load.sql's "Read without missing_ok" GUC handling). Require the same 'current' sentinel bin/test_existing's assert_version()/current_version() already use instead, and make an empty :version a hard RAISE EXCEPTION. Update test/install/load.sql's fresh-mode branch to pass 'current' accordingly; its update-mode branch already passes a real version (0.9.6) and is unchanged. No other caller of create_test_schema.sql passes an empty version. The guard bridges :version into its DO block via SET + current_setting() (matching test/install/load.sql's own count_nulls.test_load_mode pattern) rather than referencing :'version' directly inside the DO $$ ... $$ body: psql does not interpolate variables inside dollar-quoted strings, only in plain top-level SQL text such as the version_clause SELECT below it - confirmed directly, a first attempt using :'version' inside the DO block reached the server un-substituted and errored with a syntax error at ":". Also, two smaller follow-ups on this same branch: - test/helpers/find_test_schema.sql: revert the SELECT ... INTO STRICT refactor back to the original hand-counted RAISE EXCEPTION. The motivating idea - that a DO block could both validate and populate :test_schema in one step - doesn't hold: a DO block can't populate a psql variable at all (a \gset following one silently re-executes it and captures nothing), so the separate plain SELECT + \gset is needed either way, and INTO STRICT doesn't actually remove a statement. - test/sql/extension_tests.sql: note in the header comment that test/expected/extension_tests.out staying identical regardless of the random schema name isn't a coincidence - none of the pgTAP assertion descriptions embed the schema name (see test/README.md for the full rationale). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude finished @jnasbyupgrade's task in 4m 18s —— View job Reviewing PR #55
SummaryFocused this pass on the four commits pushed since the last review ( Things I traced and confirmed correct:
Finding: stale
|
…st__shutdown__drop_all test/helpers/create_test_schema.sql already unconditionally drops any leftover 'count_nulls test schema %' schema before creating a fresh one, on every single invocation - so the explicit DROP SCHEMA %I this function also did was always redundant duplicate cleanup, never the thing that actually mattered for catching a stale schema. It was also moot in practice: this file's functions run inside a transaction pgxntool's test harness rolls back, never commits, so the DROP SCHEMA here never persisted past the run anyway. test__shutdown__drop_all now just asserts DROP EXTENSION succeeds, and no longer needs ncs() to know which schema to drop. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude finished @jnasbyupgrade's task in 2m 56s —— View job Reviewing PR #55
SummaryThis pass focuses on the one new commit since the last review,
Finding:
|
…t_schema.sql bin/test_existing's prepare-old usage doc and plant_guard.sql's header both said the random schema is created by test/install/load.sql, but neither subcommand ever goes through load.sql - prepare-old calls test/helpers/create_test_schema.sql directly. Point both at the actual file. test/README.md's Layout section had no entry for helpers/create_test_schema.sql despite it being a substantial, shared, independently documented file; add one. Its Schema targeting section still attributed the random-name generation and cleanup-before-create behavior directly to install/load.sql, which is only true for the load.sql-mediated path now - reattribute it to create_test_schema.sql, noting it's shared by both install/load.sql and bin/test_existing. Also update the test__shutdown__drop_all paragraph, stale after the prior commit on this branch removed its explicit schema drop: it now only asserts DROP EXTENSION succeeds, relying entirely on create_test_schema.sql's own cleanup-before-create. test/core/functions.sql, test/sql/extension_tests.sql, and ci.yml's test/install/load.sql pointers are left untouched - those describe the pgTAP suite's own execution context, which is genuinely only ever reached via load.sql's fresh/update flow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude finished @jnasbyupgrade's task in 1m 14s —— View job Reviewing PR #55
SummaryThis pass focuses on the one new commit since the last review, It is. All three stale pointers flagged in the prior review round are fixed:
I also re-verified this commit didn't touch (and didn't need to touch) the other No new issues found. All findings from earlier review passes on this PR (the |
Replace the two-value TEST_SCHEMA axis (fixed "" and "Quoted" legs, run via
make test-schema-all's in-Makefile loop) with a single install per run into a freshly, randomly generated schema whose constant prefix (a literal trailing space) always requires SQL identifier quoting. This exercises%I-qualification on every run instead of only on a dedicated quoting leg, and removes the Makefile/GUC-propagation infrastructure that existed solely to support the two-value axis.Cleanup-before-create matches on the constant prefix (
count_nulls test schema %) to find and drop any schema left behind by a run that crashed before its own teardown, so stale schemas don't accumulate run over run.test/helpers/find_test_schema.sqllets separate sessions (bin/test_existing's per-steppsql -f ...invocations, each a fresh connection) rediscover the randomly generated name without having created it themselves.bin/test_existing'sprepare-old/plant_guard/run-suiteno longer take a schema argument, since every install always targets its own randomly generated schema now;create_extension_in_schema()moved to a proper-fscript (bin/test_existing.sql/create_extension.sql) since it needs multiple statements including a\gset.This supersedes PR #32's cross-schema approach, which is left open only for reference.