You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve INCLUDE columns on PRIMARY KEY and UNIQUE constraints #673
pgschema dump omits INCLUDE columns from PRIMARY KEY and UNIQUE constraints. Replay therefore creates different backing indexes. A subsequent plan can be empty because the inspector does not retain the included columns in the constraint representation.
Reproduction
Create this schema in an empty source database:
CREATETABLEevents (
id integer,
a integer,
payload text,
CONSTRAINT root_unique UNIQUE (id, a) INCLUDE (payload)
) PARTITION BY RANGE (id);
CREATETABLEevents_leaf PARTITION OF events FOR VALUESFROM (0) TO (10);
Dump the source and replay the SQL into another empty database. Inspect both databases with:
SELECTt.relname, c.conname, pg_get_constraintdef(c.oid)
FROM pg_constraint c
JOIN pg_class t ONt.oid=c.conrelidJOIN pg_namespace n ONn.oid=t.relnamespaceWHEREn.nspname='public'ANDc.contype='u'ORDER BYt.relname, c.conname;
The source contains UNIQUE (id, a) INCLUDE (payload) on the parent and child. Replay contains UNIQUE (id, a) on both.
Expected behavior
Dump, replay, and plan/apply should preserve included columns on ordinary and partitioned PRIMARY KEY and UNIQUE constraints. The planner should detect a change to included columns. Included columns must remain distinct from the uniqueness key.
Verification and scope
Reproduced with synthetic schemas on PostgreSQL 14–18 against main at 36a38ff3. The same loss occurs before #663, so this is an existing limitation.
Related to #653, #663, and closed PR #645. This report isolates INCLUDE preservation from inherited-name restoration, SQL-loader changes, and constraint comments.
Activity