Re: COMMENTS are not being copied in CREATE TABLE LIKE

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Tomas Vondra <tomas(at)vondra(dot)me>, Alex Liapychev <coder(dot)sam(at)gmail(dot)com>
Cc: matheusssilv97 <matheusssilv97(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, "masao(dot)fujii" <masao(dot)fujii(at)gmail(dot)com>, "david(dot)g(dot)johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, tgl <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "huseyin(dot)d3r" <huseyin(dot)d3r(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, chochoforwork(at)gmail(dot)com, 44973863(at)qq(dot)com
Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
Date: 2026-10-01 21:30:21
Message-ID: 5885bc81-73d3-4c78-876f-5883659ce5f9@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v5-0001-Add-table-comments-in-CREATE-TABLE-LIKE-INCLUDING.patch text/x-patch 15.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-10-01 21:36:56 Re: COMMENTS are not being copied in CREATE TABLE LIKE
Previous Message Amit Kapila 2026-10-01 21:29:33 Re: Fix apply worker crash when subscriber table has only a deferrable primary key