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 3ecadefa-f63a-48a6-b732-b3e79814933b@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>)
List pgsql-hackers

On 26/02/2026 08:46, Hüseyin Demir wrote:
> Yes, because changing the behavior will lead to misinterpretations while
> creating tables and tables derived from template ones will be presented
> differently with respect to comments they have.

But isn't that the case to any feature that we add to CREATE TABLE LIKE?
For instance, if we add INCLUDING TRIGGERS, it will inevitably change
the behaviour of INCLUDING ALL.

> Such changes can cause unexpected different objects inside a database.
> For example, any existing script using INCLUDING COMMENTS or INCLUDING
> ALL will now copy the table comment where it didn't before. 

That's true, the newly created table would then get a comment it didn't
have before. I just fail to see how this would create an unexpected
different object.

Of course, if this script relies on the table not having a comment to
work, it could case some problems.

> If we need this behavioral change my idea is to introduce a new sub-
> option or keep table comments excluded unless explicitly opted in.
> Because after changing the current behavior there is no way to implement
> old behavior. 

The user can always use EXCLUDING COMMENTS for that

CREATE TABLE t2 (
  LIKE t1
    INCLUDING ALL
    EXCLUDING COMMENTS
);


Thanks, Hüseyin!

Best, Jim



pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: Skipping schema changes in publication
Next
From: Jim Jones
Date:
Subject: Re: Show comments in \dRp+, \dRs+, and \dX+ psql meta-commands