Repository navigation
PostgreSQL 19 publications: read EXCEPT entries, manage allSequences and except - #354
Merged
Merged
Conversation
… and except, switch publications to them in place, drop ONLY tables from publications with ONLY, take a table out of EXCEPT lists before attaching it.
# Conflicts: # internal/diff/diff.go
# Conflicts: # internal/diff/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 #327
Fixes #328
Fixes #335
Fixes #336
Part of #325.
What changes
pg_publication_relrows withprexcept = true(PostgreSQL 19) are read intoLivePublication.Exceptinstead ofTables, andpuballsequencesintoAllSequences. Both columns are read throughto_jsonb(...), so the queries still run on 15–18. Excepted inheritance children fold into their parent the way published ones do, soexcept (table x)andexcept (table only x)read back as written.allSequences: trueandexcept: [schema.table, {table: schema.table, only: true}](only withallTables).pgy pullwrites them,Simulatemodels them, andschemas/pgy.schema.jsonaccepts them.pgy validaterejectsallSequencescombined withtables/schemas,exceptwithoutallTables, and a partition inexcept. A database-wideFOR ALL SEQUENCESpublication is treated likeFOR ALL TABLESfor external handling and limited pulls.FOR ALL TABLES EXCEPT (TABLE ..., TABLE ONLY ...), ALL SEQUENCES. A change amongallTables,exceptandallSequencesemitsALTER PUBLICATION ... SET ALL .... On PostgreSQL 19, a publication of tables or schemas switches toallTables/allSequencesin place: its members are dropped, thenSET ALL ...runs in the same transaction, and its options stay. I checked on 19.0 that the other direction isn't possible:SET TABLEon aFOR ALL TABLESorFOR ALL SEQUENCESpublication fails with "publication is defined as FOR ALL TABLES". So switching from all tables/sequences back to tables or schemas still needs--unsafedrop + create, as does anyallTablesswitch on 15–18.versionWarningsnow covers servers before PostgreSQL 19 (the guard isv >= 190000). It reportsallSequencesandexceptas needing PostgreSQL 19, so the migration would fail. pgy writes the statement as declared rather than dropping theEXCEPT, because dropping it would publish tables the YAML leaves out. ThenotNullNamewarning is now limited to servers before PostgreSQL 18, since it used to rely on the old early return.only: trueusing plainDROP TABLE. PostgreSQL then also tries to drop the table's inheritance children from the publication and fails with "relation ... is not part of the publication". The drop now usesDROP TABLE ONLYfor those tables.ATTACH PARTITIONwhile a publication'sEXCEPTclause lists the table. Before attaching, the plan now takes the table out of each liveEXCEPTlist withSET ALL TABLES EXCEPT (...)when the YAML declares that publication withallTablesand without the table inexcept. It warns about any other publication that excepts the table.docs/schema.md(Publications section and the list of names that are quoted like SQL),docs/feature_support.md(the Publications entry) and README (limited pull) are updated.Tests
TestPublicationAllSequencesAndExceptParse); diff create, skip-if-same, each alter, in-place switch on 19 compared with--unsafedrop + create on 18, switching back from all tables/sequences,DROP TABLE ONLY, except before attach, and the PostgreSQL 19 version warnings; pull writes the keys and the result diffs clean; validate errors; JSON Schema fixture.TestIntegrationPublicationAllTablesExceptAndSequencesandTestIntegrationPublicationExceptedTableAttachedrun on servers >= 19 and are skipped below.publication_pg19pull fixture is skipped on servers below 19. It checks pull, diff clean, rebuild and thepg_dumpcomparison.TestIntegrationPublicationEmptiedWithOnlyTableruns on every version.make testandgo vet ./...pass. The cli and integration packages pass against PostgreSQL 19.0, 18 and 15, withPGY_TEST_REQUIRE_PL=1and thepg_dumporacle.