Re: COMMENTS are not being copied in CREATE TABLE LIKE - Mailing list pgsql-hackers

From Jim Jones
Subject Re: COMMENTS are not being copied in CREATE TABLE LIKE
Date
Msg-id cc2e7c77-2ff6-4ab0-9bab-f9e6ba5cf6b4@uni-muenster.de
Whole thread Raw
In response to Re: COMMENTS are not being copied in CREATE TABLE LIKE  (Hüseyin Demir <huseyin.d3r@gmail.com>)
Responses Re: COMMENTS are not being copied in CREATE TABLE LIKE
List pgsql-hackers
Hi Hüseyin

On 22/02/2026 09:05, Hüseyin Demir wrote:
> 1. Table comments tend to describe the purpose or context of a specific table (e.g. "staging table for pipeline X"),
unlikecolumn or constraint comments which describe the schema structure. Copying them by default may be wrong more
oftenthan it's right, since the new table almost certainly serves a different purpose than the source.
 

Good point. Comments may well lose their semantic value when placed in a
different context, but I'm not sure how it differs from column comments.
A column comment can also refer to a context (original table) that is no
longer applicable after cloning, specially when the CREATE TABLE LIKE
includes multiple tables.


> 2. This changes the behavior of INCLUDING ALL, which many users rely on without thinking too carefully about what it
pullsin. Silently copying a source table's comment (which might say something like "template — do not use directly")
intoevery derived table could cause confusion in practice.
 


It's also a valid concern - although I see it slightly differently. I we
take this line of reasoning too seriously, we might never be able to
expand CREATE TABLE LIKE, since the ALL keyword would be directly
affected (expanded) in the process. There are also other patches that
aim to expand CREATE TABLE LIKE, e.g. INCLUDING TRIGGERS[1]


> Before reviewing the patch for code quality and repo standards, I think we need to decide whether this behavior
changeis the right approach at all. My preference would be to keep table comments managed separately, given the
situationsabove.
 


Are you suggesting we should simply keep ignoring the table comments? Or
should we manage them differently?

Thanks for the comments. Much appreciated!

Best, Jim

1 - https://commitfest.postgresql.org/patch/6087/



pgsql-hackers by date:

Previous
From: Jim Jones
Date:
Subject: Re: WIP - xmlvalidate implementation from TODO list
Next
From: Yugo Nagata
Date:
Subject: Re: Incremental View Maintenance, take 2