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 5885bc81-73d3-4c78-876f-5883659ce5f9@uni-muenster.de
Whole thread
In response to Re: COMMENTS are not being copied in CREATE TABLE LIKE  (Tomas Vondra <tomas@vondra.me>)
List pgsql-hackers
On 01/10/2026 19:25, Tomas Vondra wrote:
> Multiple tables scenario, I think. I suggested asking for a "real" use
> case on Discord, because (a) I still don't know if anyone actually needs
> this feature, and (b) if there's such use case, it'd probably give us
> insights what to do about duplicate comments.

Oh, I totally missed this discussion on discord.

> Yes, I can construct a made-up example, but I struggle to create an
> example where copying table comments would be meaningful.
> 
> I think this lack of use case is partially due to the origin of the
> patch. If it was written because of genuine need for the feature, we'd
> have the use case by definition. But it was written "because it's
> missing" and so no use case.

Yeah, this is the root cause of this issue. I had to deal with this
multiple tables scenario, which I didn't anticipated when proposing the
patch, and couldn't find any good argument just to ignore it. But the
lack of practical use cases is indeed argument enough to leave it alone
for now.

The support for multiple LIKE clauses is now removed from the patch. I
added a variable in CreateStmtContext to count the numbers of LIKE
clauses in transformTableLikeClause(), so that we can skip the comments
in transformCreateStmt() if it's different than 1. Docs and tests were
updated accordingly.

Thanks!

Best, Jim

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Fix apply worker crash when subscriber table has only a deferrable primary key
Next
From: Jim Jones
Date:
Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE