Re: pg_dump misses comments on NOT NULL constraints

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pg_dump misses comments on NOT NULL constraints
Date: 2025-06-26 16:31:23
Message-ID: 202506261631.qjodlp32f7yo@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Jun-26, Fujii Masao wrote:

> I noticed a small inconsistency in the output of pg_dump when handling
> comments for COMMENT commands on not-null constraints. [...]

> You can see that only comments for the not-null constraint includes
> the schema-qualified table name (hoge.t) after "ON". The others just
> show "t". It's a very minor issue, but for consistency, it would be
> better if all constraint comments used the same format.

Hmm, you're right. I think we should make the tags use qualified names
instead, but that'd be a much larger patch.

> + if (comment != NULL)
> + {
> + destroyPQExpBuffer(comment);
> + destroyPQExpBuffer(tag);
>
> The "comment != NULL" check isn't needed here, since destroyPQExpBuffer()
> already handles null safely.

Hah, true.

> Since valid not-null constraints are dumped in the pre-data section,
> the following change seems necessary in pg_dump.sgml.
>
> statistics for indexes, and constraints other than validated check
> - constraints.
> + and not-null constraints.
> Pre-data items include all other data definition items.

Ah, right, did that, thank you.

Thanks for reporting this and to Jian for the quick analysis and patch!

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Oh, great altar of passive entertainment, bestow upon me thy discordant images
at such speed as to render linear thought impossible" (Calvin a la TV)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2025-06-26 16:31:48 Re: Documentation fix on pgbench \aset command
Previous Message Andrey Borodin 2025-06-26 16:24:45 Re: IPC/MultixactCreation on the Standby server