pg_dump misses comments on NOT NULL constraints

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: pg_dump misses comments on NOT NULL constraints
Date: 2025-06-18 00:13:36
Message-ID: d50ff977-c728-4e9e-8488-fc2688e08754@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In v18, we can now add comments on NOT NULL constraints. However, I noticed
that pg_dump doesn't include those comments in its output. For example:

--------------------------
$ psql <<EOF
CREATE TABLE t (i int);
ALTER TABLE t ADD CONSTRAINT my_not_null NOT NULL i;
ALTER TABLE t ADD CONSTRAINT my_check CHECK (i > 0);
COMMENT ON CONSTRAINT my_not_null ON t IS 'my not null';
COMMENT ON CONSTRAINT my_check ON t IS 'my check';
EOF

$ pg_dump | grep COMMENT
-- Name: CONSTRAINT my_check ON t; Type: COMMENT; Schema: public; Owner: postgres
COMMENT ON CONSTRAINT my_check ON public.t IS 'my check';
--------------------------

As shown above, the comment on my_not_null is missing from the dump output.

Is this an oversight in commit 14e87ffa5c5? If so, I'll add it as
a v18 open item.

I'm aware of a related open item [1] affecting both v17 and v18,
but this seems like a separate issue, since it relates to a new v18 feature...
Or we should treat them the same?

Regards,

[1] https://www.postgresql.org/message-id/CACJufxF-0bqVR%3Dj4jonS6N2Ka6hHUpFyu3_3TWKNhOW_4yFSSg%40mail.gmail.com

--
Fujii Masao
NTT DATA Japan Corporation

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-06-18 00:36:06 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Sungwoo Chang 2025-06-18 00:03:59 Re: Fwd: dsm_registry: Add detach and destroy features