Add extension testing conventions: schema/search_path isolation - #5
Merged
jnasbyupgrade merged 9 commits intoAug 9, 2026
Merged
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 |
…n_tools/cat_tools Found extension_tools's CLAUDE.md pointing at container-local docs (~/advanced-extension-testing.md, ~/test-fixes.md) that nothing outside that one session could resolve. The substance -- check schema= not relocatable= before building a custom-schema test dimension, and how to actually prove search_path-independence when one applies -- is general methodology, not extension_tools-specific: test-fixes.md's own account of it describes a costly mistake made in cat_tools from getting this wrong. Companion PR trims extension_tools's CLAUDE.md to its own specific facts and points here for the methodology.
…opt-in doc for random-schema testing Moves the schema-flexibility content out of CLAUDE.md entirely and reframes the core lesson: the critical, universal thing to get right is that an extension's own schema(s) must be absent from search_path during testing -- for EVERY extension, including fixed-schema ones, not just flexible ones. A pinned schema only means the install location can't change; it says nothing about whether the extension's own code correctly qualifies its own references. Adds the end-of-suite re-check as an explicit, separate ask, since a start-of-suite-only check misses mid-suite search_path leaks. test/CLAUDE.md carries only that universal principle, linked from CLAUDE.md's Related docs. RANDOM_SCHEMA_TESTING.md is new and deliberately unlinked from either: randomly-named-schema installs to catch hardcoded schema references (for non-fixed-schema extensions), and the cheaper two-random-schema move verification for relocatable extensions (none exist in this org yet, but worth documenting). Repos that don't use a fixed schema should reference it explicitly from their own test/CLAUDE.md.
…ble=true Checked rather than assumed -- found it while surveying repos for the random-schema-testing PRs. Note it doesn't obviously need the pattern applied, since it doesn't create any schema-dependent objects of its own.
…ce burden Docs in this repo describe general policy for the whole org -- naming a specific sibling repo as "the example" or "the current instance of X" just creates a dangling reference the moment that repo's code changes, gets renamed, or the property being cited no longer holds. Rephrased the relocatable-extension caveat generically instead of naming trunklet-format specifically, and dropped a specific pgxntool issue-link URL in favor of stating the gap without a link that can go stale if the issue closes without a doc update.
… run, not "at least part" of it "At least part of the test run" allows windows where the schema is back on search_path, during which an unqualified reference can resolve by accident and go undetected -- exactly what this doc exists to prevent. Also reframes the start/end double-check section so it reads as verifying the entire-run requirement, not as a softer alternative to it.
If you explicitly SET search_path yourself before assertions, checking it right after tells you nothing you didn't already know. The end-of-run check is what actually matters -- it's the one that can catch a test putting the schema back on search_path partway through.
…mplement Continuous checking throughout the run would be ideal but isn't practical for file-based test suites. A static grep for search_path across the suite's own files -- expecting exactly two matches, the setup and the end-check -- catches a leak at review time instead of only at the mercy of whether the end-check's specific assertion happens to notice it.
…gxntool cross-ref, move RANDOM_SCHEMA_TESTING.md under test/ - Drop "The one thing to get right" heading -- this doc is about one aspect of testing (schema/search_path isolation), not testing overall. - The search_path-mention-count check should be an automated, checked-in test, not a suggestion to have an agent manually re-grep. - pgxntool's own test/install feature (files that run once, committed, before the suite) is the natural place to put the explicit `SET search_path` step -- cross-referenced from "How to exclude." - Moved RANDOM_SCHEMA_TESTING.md under test/ alongside CLAUDE.md, since it's testing-specific rather than a general top-level doc. Still not linked from CLAUDE.md or test/CLAUDE.md on purpose.
jnasbyupgrade
force-pushed
the
schema-flexibility-testing
branch
from
August 9, 2026 22:28
1dd0715 to
652bb24
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test/CLAUDE.md (new, linked from CLAUDE.md's Related docs): the universal principle — an extension's own schema(s) must be absent from search_path for the entire test run, for every extension, including fixed-schema ones. A pinned schema only means the install location can't change; it says nothing about whether the extension's own code correctly qualifies its own references, so the same unqualified-reference bug can hide in a fixed-schema extension just as easily. Cross-references pgxntool's own test/install feature and CLAUDE.md, and asks for a re-check at the end of the suite (framed as a practical compromise for file-based suites, plus a suggestion to add an automated check that search_path is mentioned in exactly the two legitimate places).
test/RANDOM_SCHEMA_TESTING.md (new, deliberately not linked from anywhere): randomly-named-schema installs to catch hardcoded schema references in non-fixed-schema extensions, plus the cheaper two-random-schema move verification for relocatable extensions. Repos that don't use a fixed schema should reference this explicitly from their own test/CLAUDE.md — companion PRs do that where it applies.
Neither doc names a specific sibling repo as an example or citation — that kind of reference is a maintenance burden that goes stale the moment the cited repo's code changes.