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

From Fujii Masao
Subject Re: pg_dump misses comments on NOT NULL constraints
Date
Msg-id 6260d8fa-6339-4c62-abd0-57a5e400cc65@oss.nttdata.com
Whole thread Raw
In response to pg_dump misses comments on NOT NULL constraints  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: pg_dump misses comments on NOT NULL constraints
List pgsql-hackers

On 2025/06/25 20:46, Álvaro Herrera wrote:
> On 2025-Jun-25, Fujii Masao wrote:
>
>>  From 516e647e7d1fdafc64dba092389963f32cd688e5 Mon Sep 17 00:00:00 2001
>> From: Fujii Masao <fujii@postgresql.org>
>> Date: Wed, 25 Jun 2025 10:02:56 +0900
>> Subject: [PATCH v2] Make CREATE TABLE LIKE copy comments on NOT NULL
>>   constraints when requested.
>>
>> Commit 14e87ffa5c5 introduced support for adding comments to NOT NULL
>> constraints. However, CREATE TABLE LIKE INCLUDING COMMENTS did not copy
>> these comments to the new table. This was an oversight in that commit.
>>
>> This commit corrects the behavior by ensuring CREATE TABLE LIKE to also copy
>> the comments on NOT NULL constraints when INCLUDING COMMENTS is specified.
>
> LGTM.  I'd add a line in the test showing that these comments are copied
> even if INCLUDING CONSTRAINTS is not given,

+1 to adding that test.

  CREATE TABLE ctlt1_inh (LIKE ctlt1 INCLUDING CONSTRAINTS INCLUDING COMMENTS) INHERITS (ctlt1);
  \d+ ctlt1_inh
-SELECT description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid = c.oid
ANDc.conrelid = 'ctlt1_inh'::regclass; 
+SELECT conname, description FROM pg_description, pg_constraint c WHERE classoid = 'pg_constraint'::regclass AND objoid
=c.oid AND c.conrelid = 'ctlt1_inh'::regclass ORDER BY conname COLLATE "C"; 

However, since ctlt1_inh is created with INCLUDING COMMENTS, this test
doesn't seem to demonstrate the case you mentioned — that comments on
not-null constraints are copied even without INCLUDING CONSTRAINTS.
Am I misunderstanding?

Regards,

--
Fujii Masao
NTT DATA Japan Corporation




pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Remove HeapTupleheaderSetXmin{Committed,Invalid} functions
Next
From: Greg Sabino Mullane
Date:
Subject: Re: display hot standby state in psql prompt