Repository navigation
Pull operator classes an extension contests, leave out settings the server doesn't know, fail diff on schema errors - #363
Merged
Conversation
…erver doesn't know, fail diff on schema errors. Which operator class is a type's default can change between server versions: btree_gist's gist_inet_ops is the GiST default for inet on PostgreSQL 18, core's inet_ops on 19. Pull left default classes out of indexes and exclusion constraints, so YAML pulled on 18 built inet_ops indexes on 19, a database upgraded to 19 planned to recreate them under --unsafe, and YAML pulled on 19 built gist_inet_ops on 18, where an exclusion constraint WITH && then failed. Introspection now marks a class as contested when it belongs to an extension or an extension has a class for the same type and access method, and pull writes contested classes in index opclasses and exclusion constraint expressions even when they are the default. A named class already compares equal to the live one. A setting the server doesn't recognise (escape_string_warning, removed in PostgreSQL 19) passed validate and diff and failed the migration with unrecognized configuration parameter. diff now looks up the names without a dot under database set and roles, role set, and function and procedure set with pg_settings_get_flags, and leaves unknown ones out of the plan with a warning. Names with a dot are placeholders PostgreSQL accepts, and are not looked up. diff printed validate's errors as warnings and went on to write a plan, such as add constraint "c1" check () for a constraint written with check: instead of expression, and exited 2. It now prints them and exits 1 without writing the buffer, --no-warnings included.
# Conflicts: # internal/cli/diff.go
This was referenced Nov 21, 2026
Closed
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 #337
Fixes #338
Fixes #350
Part of #325.
gist_inet_opsis the GiST default for inet on 18, core'sinet_opson 19.pgy pullnow writes contested classes in indexopclassesand in exclusion constraint expressions (ExcludeWithContestedOpclasses) even when they are the default, so YAML pulled on 18 builds the same indexes on 19 and the other way round. A named class already compared equal to the live one. Side effect: pulled YAML also names btree_gist/citext default classes such asgist_int4_ops.pgy difflooks up the setting names without a dot (databasesetandroles, roleset, function and procedureset) withpg_settings_get_flags, and leaves unknown ones (e.g.escape_string_warning, removed in 19) out of the plan with a warning instead of planning a statement that fails at migrate. Dotted names are placeholders and are not looked up.pgy diff: it prints them, writes nothing and exits 1,--no-warningsincluded. This reverses the errors-as-warnings choice of a3dba0c; validate's warning-severity findings and policy findings stay warnings. Help text, README and docs updated.Tests: unit tests for each part,
internal/cli/diff_invalid_test.go, integrationopclass_settings_test.goand pull fixturecontested_opclasses.sql.make test,go vet, and the cli + integration suites (withPGY_TEST_REQUIRE_PL=1and thepg_dumpcomparison) pass on PostgreSQL 15, 18 and 19.