Re: pg_dump misses comments on NOT NULL constraints

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
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-25 15:39:08
Message-ID: 0e4726c2-4e30-4931-a72b-01e05b7b093a@oss.nttdata.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025/06/25 22:36, Álvaro Herrera wrote:
> On 2025-Jun-25, Álvaro Herrera wrote:
>
>> Yeah, I think in this case we need to extract the constraint name so
>> that we have it available to print the COMMENT command, rather than
>> making any assumptions about it. In fact I suspect this would fail if
>> the table or column names are very long. For the other pg_dump uses of
>> this logic it doesn't matter AFAIR, but here I think we must be
>> stricter.
>
> As attached.

Thanks for the patch! I agree with the approach, i.e., printing the not-null
constraint name only when there's a comment on it.

However, with the patch applied, I encountered a segmentation fault in pg_dump
as follows:

$ psql <<EOF
create table t (i int);
alter table t add constraint t_i_not_null not null i not valid;
comment on constraint t_i_not_null ON t IS 'iii';
EOF

$ pg_dump
Segmentation fault: 11

> I'm bothered by this not having any tests -- I'll see about adding some
> after lunch.

+1. Thanks!

Regards,

--
Fujii Masao
NTT DATA Japan Corporation

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-06-25 15:39:38 Re: pg_dump misses comments on NOT NULL constraints
Previous Message Greg Sabino Mullane 2025-06-25 15:33:16 Re: Proposal: Native High Availability and Automatic Failover in PostgreSQL