GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(postgres): types, domains and partitions as real schemas use them by jasdeepkhalsa · Pull Request #285 · DBDiff/DBDiff Conversation
|
| Shape | Before | After |
|---|---|---|
varchar(20)[], numeric(10,2)[], timestamptz(3)[], bit(4)[] |
_varchar, _numeric, … — modifier lost, and the re-diff saw no difference |
character varying(20)[], … spelled by format_type |
Array of a mixed-case or non-public type ("Mood"[], app.status[]) |
_Mood, _status — type does not exist |
"Mood"[], app.status[] |
vector(1536) (any extension type with a modifier) |
vector — an HNSW index on it then fails |
vector(1536) |
Domain "Name" in public |
Name, which folds to the built-in name type |
"Name" |
Domain gains a CHECK … NOT VALID |
DROP DOMAIN + CREATE DOMAIN … NOT VALID — a syntax error, and the drop fails while columns use it |
ALTER DOMAIN … ADD CONSTRAINT … NOT VALID |
| Column added to a partitioned table | ADD COLUMN on the parent and every partition — refused |
on the parent only |
| Partition in another schema than its parent | parent named in the partition's schema — does not exist | parent named in its own schema |
| Partitioned table whose id comes from a sequence it owns (each partition carrying the default) | sequence created and the column written bigserial, so a second …_seq1 sequence fed every partition |
one sequence, as on the source |
| PostgreSQL 18 virtual generated column | written STORED, and stored vs virtual compared as identical |
VIRTUAL; a change between them drops and re-adds the column |
The array and domain spellings matter for the built-in renderer, which runs whenever no pg_dump at least as new as the server is installed. Domain changes and partitioned tables were wrong under both renderers.
A domain is still replaced when its base type or collation changes, since ALTER DOMAIN can't do that.
tests/RealWorldShapesPostgresTest.php covers each shape as a live round trip (UP, re-diff empty, DOWN restores). It runs under both renderers. Because the re-diff was itself blind to the lost modifiers, each case also compares the catalog directly: format_type per column, domain constraints with convalidated, and partition parents.tests/Unit/PostgresColumnTypeTest.php covers type spelling.ObjectKindsSQLTest, the domain cases now pin ALTER DOMAIN, and a separate case keeps the base-type change as a replacement.master, 9 of the 11 new round-trip cases and 7 of the 11 new unit cases fail. The two round-trip cases that pass on master are the pg_dump-renderer variants of the domain and array tests, which pg_dump already rendered correctly.MySQL, SQLite and Dolt are unaffected. Every change is in PostgreSQL-only code. The shared TableSchema path only skips columns PostgreSQL reports as inherited, which the other engines never report. The MySQL matrix in CI confirms it.
🤖 Generated with Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Run against widely used public schemas (AdventureWorks, Pagila, GitLab's
structure.sql, pgvector), PostgreSQL migrations were wrong in six ways the
synthetic corpus had no case for.
- An array column was written as the catalog's internal name, `_varchar`:
varchar(20)[] became varchar[], numeric(10,2)[] numeric[], bit(4)[]
bit(1)[], and an array of a mixed-case or non-public type (`_Mood`,
`_status`) did not resolve. The re-diff then compared the same internal
names and called the columns identical. Arrays are now spelled by the
server, format_type(atttypid, atttypmod).
- A type modifier on an extension type was dropped: vector(1536) became
vector, on which an HNSW index fails ("column does not have dimensions").
- A domain in `public` was written bare. `"Name"` folded to PostgreSQL's own
`name` type, so its columns were created with a different type, and
`"Flag"` failed as unknown. It is quoted wherever it needs to be.
- A changed domain was dropped and recreated, which fails while any column
uses it. A default, NOT NULL or CHECK change is now made with ALTER DOMAIN;
only a new base type or collation still replaces it.
- A NOT VALID check was written into CREATE DOMAIN, which does not accept
it. It is added after the domain exists, still unvalidated.
- A column added to a partitioned table was also added to every partition,
which PostgreSQL refuses ("cannot add column to a partition"); a column a
table only inherits is no longer added or dropped on it. And a partition in
another schema than its parent named the parent in its own schema.
MySQL, SQLite and Dolt are unaffected: every change is in PostgreSQL-only
code, and the shared TableSchema path only skips columns PostgreSQL reports
as inherited, which other engines never do.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PostgreSQL 18 adds virtual generated columns, and makes them the default. Every generated column was written STORED, so a virtual one was created stored, and the comparison could not tell them apart: the kind was not in the pre-scan hash, the column definition parser skipped the keyword, and a change between the two was not a regeneration. The kind is now read from attgenerated, written as VIRTUAL or STORED, hashed, and compared; a change between them drops and re-adds the column, as PostgreSQL cannot switch it in place. A generated column recreated around a dependency's retype keeps its kind. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GitLab's `uploads` takes its id from a sequence it owns, and every partition carries a copy of the default. Counted as further uses, those copies made the sequence look shared, so it was modelled standalone and created — while the column was still written bigserial, which made a second sequence (`uploads_id_seq1`) that every partition's default then pointed at. A default on a column the table inherits is no longer counted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keeps PostgresSchemaHelper within the 20-method limit; no behaviour change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.