Thread: pg_dump does not dump domain not-null constraint's comments
hi. ---------------------------------------------------- begin; create schema test; set search_path to test; create domain d1 as int; alter domain d1 add constraint nn not null; alter domain d1 add constraint cc check (value is not null); comment on constraint nn on domain d1 is 'not null constraint on domain d1'; comment on constraint cc on domain d1 is 'check constraint on domain d1'; commit; ------the above is the test script------------------ in PG17 and master, pg_dump (--schema=test --no-owner) will only produce COMMENT ON CONSTRAINT cc ON DOMAIN test.d1 IS 'check constraint on domain d1'; but didn't produce COMMENT ON CONSTRAINT nn ON DOMAIN test.d1 IS 'not null constraint on domain d1'; we should make pg_dump to produce it too? The attached patch tries to make it produce comments on not-null constraints on domains. I aslo renamed struct TypeInfo fields, nDomChecks will be renamed to nDomConstrs; domChecks will be renamed to domConstrs. TypeInfo->domConstrs will also include not-null constraint information, changing from domChecks to domConstrs makes sense, IMHO.
Attachment
On 2025-May-07, jian he wrote: > in PG17 and master, pg_dump (--schema=test --no-owner) > [...] > didn't produce > COMMENT ON CONSTRAINT nn ON DOMAIN test.d1 IS 'not null constraint on > domain d1'; > we should make pg_dump to produce it too? Yes, this is clearly a pg17 bug whose fix should be backpatched. > The attached patch tries to make it produce comments on not-null > constraints on domains. Thanks, I'll have a look. > I aslo renamed struct TypeInfo fields, nDomChecks will be renamed to > nDomConstrs; domChecks will be renamed to domConstrs. > TypeInfo->domConstrs will also include not-null constraint > information, changing from domChecks to domConstrs makes sense, IMHO. Hmm, for a backpatch I would leave the field names alone since they are publicly visible; we can rename separately in pg19 once it opens. Can you resubmit splitting the renaming out to a 0002 patch? -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "In fact, the basic problem with Perl 5's subroutines is that they're not crufty enough, so the cruft leaks out into user-defined code instead, by the Conservation of Cruft Principle." (Larry Wall, Apocalypse 6)
Ooh, you know what? I ran your the CREATE DOMAIN statement in your new test and pg_dump'ed that, and as far as I can tell the _name_ of the not-null constraint is not dumped either. So it's not just the comment that we're losing. That's a separate bug, and probably needs to be fixed first, although I'm not sure if that one is going to be back-patchable. Which means, I withdraw my earlier assessment that the comment fix is back-patchable as a whole. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/