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-25 15:53:44
Message-ID: 202506251553.6zizoiu763b5@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Jun-26, Fujii Masao wrote:

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

Ah, thanks for the test case. Yeah, I removed one 'if' condition too
many from Jian's patch. We just need to test the constraint name for
nullness and then things seem to work:

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 5dd1f42631d..7b5024d4f71 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -17719,7 +17719,8 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)

for (j = 0; j < tbinfo->numatts; j++)
{
- if (tbinfo->notnull_comment[j] != NULL)
+ if (tbinfo->notnull_constrs[j] != NULL &&
+ tbinfo->notnull_comment[j] != NULL)
{
if (comment == NULL)
{

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-06-25 15:58:54 Re: No error checking when reading from file using zstd in pg_dump
Previous Message Jim Jones 2025-06-25 15:50:39 Re: display hot standby state in psql prompt