Compare constraint definitions in upgrade schema snapshots#262
Merged
pinodeca merged 2 commits intoJun 23, 2026
Merged
Conversation
NOT NULL column constraints are first-class pg_constraint rows on PG18+ but not on PG17 (they live in pg_attribute.attnotnull), which would make the constraint snapshot PG-version-dependent. Per-column nullability is already captured by the 'column' section via is_nullable, so filter out contype = 'n' to keep the snapshot deterministic across PG versions while preserving the CHECK body / convalidated comparison from issue microsoft#241.
pinodeca
approved these changes
Jun 23, 2026
pinodeca
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Reviewed with Opus 4.8
Opus pointed out that the new approach checks NOT NULL constraints on PG 18 and suggested I run the CI for PG 18 (I did and it passed) to check for spurious failures due to auto-naming of NOT NULL constraints.
Nullability is already covered by column constraints, so checking NOT NULL constraints has limited value. Hence Opus suggested excluding those constraints and adding a comment about it in the test-upgrade.sh script.
I did so and pushed a commit on the PR branch in the author's fork.
@snvtac , thanks for setting "Maintainers are allowed to edit this pull request."
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.
Fixes #241.
Summary
pg_constraintpg_get_constraintdef(con.oid)so CHECK bodies and full constraint definitions are comparedcon.convalidatedso validated vsNOT VALIDdrift is caughtTesting
bash -n scripts/test-upgrade.shcargo fmt -p pg_durable -- --checkgit diff --checkNot run:
./scripts/test-upgrade.shbecause this local environment does not have pgrx PostgreSQL 17 installed (Error: pgrx PostgreSQL 17 not installed).