Re: COMMENTS are not being copied in CREATE TABLE LIKE

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
Date: 2026-02-26 10:07:34
Message-ID: 3ecadefa-f63a-48a6-b732-b3e79814933b@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-02-26 10:23:40 Re: Show comments in \dRp+, \dRs+, and \dX+ psql meta-commands
Previous Message shveta malik 2026-02-26 09:52:41 Re: Skipping schema changes in publication