Re: pg_dump does not dump domain not-null constraint's comments

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_dump does not dump domain not-null constraint's comments
Date: 2025-07-15 07:44:10
Message-ID: CACJufxHg-KABN2FyKgY4bBM=pa0ijpwarKyCA0F+0Dqb_TjjCA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 15, 2025 at 2:10 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> accidently found another existing bug.
>
> create schema test;
> CREATE DOMAIN test.d1 AS integer NOT NULL default 11;
> alter domain test.d1 add constraint a2 check(value > 1) not valid;
> comment on CONSTRAINT a2 ON DOMAIN test.d1 is 'test';
> dump output is:
>
> CREATE SCHEMA test;
> CREATE DOMAIN test.d1 AS integer NOT NULL DEFAULT 11;
> COMMENT ON CONSTRAINT a2 ON DOMAIN test.d1 IS 'test';
> ALTER DOMAIN test.d1
> ADD CONSTRAINT a2 CHECK ((VALUE > 1)) NOT VALID;
>
> Obviously the COMMENT command will error out.
> currently working on a fix, just sharing the bug details in advance.

we should let:
dumpConstraint handles dumping separate "NOT VALID" domain constraints along
with their comments.
dumpDomain: handles dumping "inlined" valid (not separate) domain constraints
together with their comments.

tested locally, i didn't write the test on src/bin/pg_dump/t/002_pg_dump.pl....

v5-0001-fix-pg_dump-domain-not-valid-constraint-comments.no-cfbot
was based on
v4-0001-Improve-pg_dump-handling-of-domain-not-null-constraints.patch
and 0001-fix-tweak.patch.txt.

Attachment Content-Type Size
v5-0001-fix-pg_dump-domain-not-valid-constraint-comments.no-cfbot application/octet-stream 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Anthonin Bonnefoy 2025-07-15 07:54:07 Document AccessExclusive lock behaviour on standbys
Previous Message Hayato Kuroda (Fujitsu) 2025-07-15 07:33:10 RE: stats.sql might fail due to shared buffers also used by parallel tests