Re: pg_dump misses comments on NOT NULL constraints - Mailing list pgsql-hackers

From Álvaro Herrera
Subject Re: pg_dump misses comments on NOT NULL constraints
Date
Msg-id 202506251553.6zizoiu763b5@alvherre.pgsql
Whole thread Raw
In response to Re: pg_dump misses comments on NOT NULL constraints  (Fujii Masao <masao.fujii@oss.nttdata.com>)
List 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/



pgsql-hackers by date:

Previous
From: Jim Jones
Date:
Subject: Re: display hot standby state in psql prompt
Next
From: Tom Lane
Date:
Subject: Re: No error checking when reading from file using zstd in pg_dump