Re: COMMENTS are not being copied in CREATE TABLE LIKE

From: Alex Liapychev <coder(dot)sam(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: tomas(at)vondra(dot)me, tgl(at)sss(dot)pgh(dot)pa(dot)us, 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:13:58
Message-ID: 245F8C2C-11CF-4087-B050-1726558AA4A0@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jim,
Hi Tomas and Tom,

First, let me address the specific questions.
> On 1 Oct 2026, at 18:49, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
>
> On 01/10/2026 01:14, Alex Liapychev wrote:
>>
>> My personal view is that adding this functionality carries more risks
>> than leaving it out. Although the code is relatively small and appears
>> to work correctly, I would not merge it into the codebase.
>
> You mean the multiple tables scenario or the whole patch?

Yes, I meant the scenario involving multiple tables - specifically, the concatenation of their comments.
Sorry I wasn’t clear about that here.

>> An example of how this functionality could be used maliciously:
>>
>> * A workflow creates a new table from several template tables in
>> response to an event.
>
> Can you elaborate more on this scenario? I'm afraid I didn't get your
> point here. Thanks!
>

I meant that CREATE TABLE is executed within some automatic flow, without direct human supervision.
For example, by a cron job or application’s code that executes CREATE TABLE in response to some event.

>> * An adversarial user with sufficient database access adds one comment
>> to each of two template tables. The combined size of these comments
>> exceeds |MaxAllocSize|, causing the automation to fail unexpectedly.
>
> An "adversarial" user with enough privileges can do many things break
> it, like renaming a column causing a conflict. I see this large comment
> scenario as purely theoretical -- at least I fail to see any practical
> use case ever exhausting this limit.

Yes, this is a narrow and theoretical scenario. But introducing a way to break the application still creates a real vulnerability, even if it requires very specific conditions. The delay between the adversary’s action (adding long comments) and the resulting failure (when CREATE TABLE actually runs) makes the cause harder to identify and can help the adversary remain undetected longer.

Second, let me explain my overall assessment.

First of all, the code itself in v4 looks good. (The question of freeing memory that I had, is answered by the Memory Contexts.)

My concern is less about the implementation itself than about whether the benefit justifies the long-term maintenance burden and the potential security risk, however theoretical.

As Tomas and Tom’s comments have highlighted, the underlying issue is the lack of a clear use case.
A concrete, practical use case would help establish whether those costs and risks are justified at all, and which alternative to concatenation to pick.

That said, this is just my assessment as a reviewer.

Thank you for your work on this patch and for taking the time to discuss these concerns.

Kind regards,
Alex Liapychev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Christensen 2026-10-01 21:22:16 [PATCH] GROUP BY ALL: the regroupening
Previous Message Alexandre Felipe 2026-10-01 20:50:05 Re: Throwing away unnecessary spin-locks