COMMENTS are not being copied in CREATE TABLE LIKE
COMMENTS are not being copied in CREATE TABLE LIKE
Hi,
While reviewing another patch[1] I saw that COMMENTS on tables are being
ignored in CREATE TABLE LIKE:
psql (18.1 (Debian 18.1-1.pgdg13+2))
Type "help" for help.
postgres=# \pset null '(null)'
Null display is "(null)".
postgres=# CREATE TABLE t1 (id int, name text);
COMMENT ON TABLE t1 IS 'table comment';
CREATE TABLE t2 (LIKE t1 INCLUDING ALL);
CREATE TABLE t3 (LIKE t1 INCLUDING COMMENTS);
SELECT
obj_description('t1'::regclass, 'pg_class') AS t1_comment,
obj_description('t2'::regclass, 'pg_class') AS t2_comment,
obj_description('t3'::regclass, 'pg_class') AS t3_comment;
CREATE TABLE
COMMENT
CREATE TABLE
CREATE TABLE
t1_comment | t2_comment | t3_comment
---------------+------------+------------
table comment | (null) | (null)
(1 row)
v1 attached attempts to fix it by expanding expandTableLikeClause() to
retrieve and copy the table-level comment when the INCLUDING COMMENTS
[ALL] option is specified:
psql (19devel)
Type "help" for help.
postgres=# CREATE TABLE t1 (id int, name text);
COMMENT ON TABLE t1 IS 'table comment';
CREATE TABLE t2 (LIKE t1 INCLUDING ALL);
CREATE TABLE t3 (LIKE t1 INCLUDING COMMENTS);
SELECT
obj_description('t1'::regclass, 'pg_class') AS t1_comment,
obj_description('t2'::regclass, 'pg_class') AS t2_comment,
obj_description('t3'::regclass, 'pg_class') AS t3_comment;
CREATE TABLE
COMMENT
CREATE TABLE
CREATE TABLE
t1_comment | t2_comment | t3_comment
---------------+---------------+---------------
table comment | table comment | table comment
(1 row)
Thoughts?
Best, Jim
1 -
https://www.postgresql.org/message-id/flat/DG7Y34A6VBEG.76L7K1OML5DI%40gmail.comRe: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"Matheus Alcantara" <matheusssilv97@gmail.com>
Дата:
Hi, thanks for checking this.
On Thu Feb 12, 2026 at 7:11 AM -03, Jim Jones wrote:
> Hi,
>
> While reviewing another patch[1] I saw that COMMENTS on tables are being
> ignored in CREATE TABLE LIKE:
>
> psql (18.1 (Debian 18.1-1.pgdg13+2))
> Type "help" for help.
>
> postgres=# \pset null '(null)'
> Null display is "(null)".
> postgres=# CREATE TABLE t1 (id int, name text);
> COMMENT ON TABLE t1 IS 'table comment';
> CREATE TABLE t2 (LIKE t1 INCLUDING ALL);
> CREATE TABLE t3 (LIKE t1 INCLUDING COMMENTS);
>
> SELECT
> obj_description('t1'::regclass, 'pg_class') AS t1_comment,
> obj_description('t2'::regclass, 'pg_class') AS t2_comment,
> obj_description('t3'::regclass, 'pg_class') AS t3_comment;
> CREATE TABLE
> COMMENT
> CREATE TABLE
> CREATE TABLE
> t1_comment | t2_comment | t3_comment
> ---------------+------------+------------
> table comment | (null) | (null)
> (1 row)
>
>
> v1 attached attempts to fix it by expanding expandTableLikeClause() to
> retrieve and copy the table-level comment when the INCLUDING COMMENTS
> [ALL] option is specified:
>
The patch fix the issue and it seems correct to me.
This bug seems to also happen on 14.20:
postgres=# select version();
version
------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.20 (Homebrew) on aarch64-apple-darwin24.6.0, compiled by Apple clang version 17.0.0 (clang-1700.4.4.1), 64-bit
(1 row)
postgres=# CREATE TABLE t(a int, b text);
CREATE TABLE
postgres=# COMMENT ON TABLE t IS 'foo';
COMMENT
postgres=# CREATE TABLE t2(LIKE t INCLUDING ALL);
CREATE TABLE
postgres=# SELECT obj_description('t'::regclass, 'pg_class') as t_comment, obj_description('t2'::regclass, 'pg_class') AS t2_comment;
t_comment | t2_comment
-----------+------------
foo |
(1 row)
So I think that we need to backport.
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Thu, Feb 12, 2026 at 11:36 PM Matheus Alcantara
wrote:
>
> Hi, thanks for checking this.
>
> On Thu Feb 12, 2026 at 7:11 AM -03, Jim Jones wrote:
> > Hi,
> >
> > While reviewing another patch[1] I saw that COMMENTS on tables are being
> > ignored in CREATE TABLE LIKE:
> >
> > psql (18.1 (Debian 18.1-1.pgdg13+2))
> > Type "help" for help.
> >
> > postgres=# \pset null '(null)'
> > Null display is "(null)".
> > postgres=# CREATE TABLE t1 (id int, name text);
> > COMMENT ON TABLE t1 IS 'table comment';
> > CREATE TABLE t2 (LIKE t1 INCLUDING ALL);
> > CREATE TABLE t3 (LIKE t1 INCLUDING COMMENTS);
> >
> > SELECT
> > obj_description('t1'::regclass, 'pg_class') AS t1_comment,
> > obj_description('t2'::regclass, 'pg_class') AS t2_comment,
> > obj_description('t3'::regclass, 'pg_class') AS t3_comment;
> > CREATE TABLE
> > COMMENT
> > CREATE TABLE
> > CREATE TABLE
> > t1_comment | t2_comment | t3_comment
> > ---------------+------------+------------
> > table comment | (null) | (null)
> > (1 row)
> >
> >
> > v1 attached attempts to fix it by expanding expandTableLikeClause() to
> > retrieve and copy the table-level comment when the INCLUDING COMMENTS
> > [ALL] option is specified:
> >
>
> The patch fix the issue and it seems correct to me.
>
> This bug seems to also happen on 14.20:
> postgres=# select version();
> version
> ------------------------------------------------------------------------------------------------------------------------------
> PostgreSQL 14.20 (Homebrew) on aarch64-apple-darwin24.6.0, compiled by Apple clang version 17.0.0 (clang-1700.4.4.1), 64-bit
> (1 row)
>
> postgres=# CREATE TABLE t(a int, b text);
> CREATE TABLE
> postgres=# COMMENT ON TABLE t IS 'foo';
> COMMENT
> postgres=# CREATE TABLE t2(LIKE t INCLUDING ALL);
> CREATE TABLE
> postgres=# SELECT obj_description('t'::regclass, 'pg_class') as t_comment, obj_description('t2'::regclass, 'pg_class') AS t2_comment;
> t_comment | t2_comment
> -----------+------------
> foo |
> (1 row)
>
> So I think that we need to backport.
The documentation [1] states that INCLUDING COMMENTS copies comments for
the copied columns, constraints, and indexes. It does not mention copying
comments on the table itself. Therefore, not copying table comments with
INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch
seems more like an improvement than a bug fix.
Regards,
[1]
https://www.postgresql.org/docs/devel/sql-createtable.html#SQL-CREATETABLE-PARMS-LIKE-OPT-COMMENTS
--
Fujii Masao
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
On 12/02/2026 16:08, Fujii Masao wrote: > On Thu, Feb 12, 2026 at 11:36 PM Matheus Alcantara > wrote: >> The patch fix the issue and it seems correct to me. Thanks for the review! > The documentation [1] states that INCLUDING COMMENTS copies comments for > the copied columns, constraints, and indexes. It does not mention copying > comments on the table itself. Therefore, not copying table comments with > INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch > seems more like an improvement than a bug fix. Hmm, it seemed so obvious to me that I didn’t look more closely at the documentation :) Although I struggle to see the rationale for not copying a table’s comment in a CREATE TABLE LIKE ... INCLUDING COMMENTS statement, I have to agree that the documentation is quite clear about this limitation, and therefore it cannot really be considered a bug. That said, it may well be worth considering for a future release. What are your thoughts? Thanks! Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"Matheus Alcantara" <matheusssilv97@gmail.com>
Дата:
On Thu Feb 12, 2026 at 12:33 PM -03, Jim Jones wrote: > > > On 12/02/2026 16:08, Fujii Masao wrote: >> On Thu, Feb 12, 2026 at 11:36 PM Matheus Alcantara >> wrote: >>> The patch fix the issue and it seems correct to me. > > Thanks for the review! > >> The documentation [1] states that INCLUDING COMMENTS copies comments for >> the copied columns, constraints, and indexes. It does not mention copying >> comments on the table itself. Therefore, not copying table comments with >> INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch >> seems more like an improvement than a bug fix. > > Hmm, it seemed so obvious to me that I didn’t look more closely at the > documentation :) > Yeah, me too. I even checked if column comments was being created, but I still assume that table comments should also be copied. > Although I struggle to see the rationale for not > copying a table’s comment in a CREATE TABLE LIKE ... INCLUDING COMMENTS > statement, I have to agree that the documentation is quite clear about > this limitation, and therefore it cannot really be considered a bug. > That said, it may well be worth considering for a future release. > > What are your thoughts? > +1 for having this as a feature on a future release. -- Matheus Alcantara EDB: https://www.enterprisedb.com
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Chao Li <li.evan.chao@gmail.com>
Дата:
> On Feb 12, 2026, at 23:33, Jim Jones wrote: > > > > On 12/02/2026 16:08, Fujii Masao wrote: >> On Thu, Feb 12, 2026 at 11:36 PM Matheus Alcantara >> wrote: >>> The patch fix the issue and it seems correct to me. > > Thanks for the review! > >> The documentation [1] states that INCLUDING COMMENTS copies comments for >> the copied columns, constraints, and indexes. It does not mention copying >> comments on the table itself. Therefore, not copying table comments with >> INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch >> seems more like an improvement than a bug fix. > > Hmm, it seemed so obvious to me that I didn’t look more closely at the > documentation :) Although I struggle to see the rationale for not > copying a table’s comment in a CREATE TABLE LIKE ... INCLUDING COMMENTS > statement, I have to agree that the documentation is quite clear about > this limitation, and therefore it cannot really be considered a bug. > That said, it may well be worth considering for a future release. > > What are your thoughts? > > Thanks! > > Best, Jim > > I feel the current behavior is proper. When you create a table using LIKE, you are cloning the structure, not the identity. Just as you have to pick a new name for the table, you should provide a new comment that fits its specific purpose. If a comment is needed, the COMMENT ON command is already the straightforward way to handle that. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Fujii Masao <masao.fujii@gmail.com>
Дата:
On Fri, Feb 13, 2026 at 12:34 AM Jim Jones wrote: > > > > On 12/02/2026 16:08, Fujii Masao wrote: > > On Thu, Feb 12, 2026 at 11:36 PM Matheus Alcantara > > wrote: > >> The patch fix the issue and it seems correct to me. > > Thanks for the review! > > > The documentation [1] states that INCLUDING COMMENTS copies comments for > > the copied columns, constraints, and indexes. It does not mention copying > > comments on the table itself. Therefore, not copying table comments with > > INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch > > seems more like an improvement than a bug fix. > > Hmm, it seemed so obvious to me that I didn’t look more closely at the > documentation :) Although I struggle to see the rationale for not > copying a table’s comment in a CREATE TABLE LIKE ... INCLUDING COMMENTS > statement, I have to agree that the documentation is quite clear about > this limitation, and therefore it cannot really be considered a bug. > That said, it may well be worth considering for a future release. > > What are your thoughts? At first, I felt it would be more intuitive to copy the table comment as well. However, on second thought, since LIKE can reference multiple tables, copying table-level properties such as comments may not be well-defined. For example, if two source tables each have a table comment and both are specified in LIKE, which comment should be applied to the new table? Regards, -- Fujii Masao
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Thursday, February 12, 2026, Fujii Masao <masao.fujii@gmail.com> wrote:
For example, if two source tables each have a table comment and both are
specified in LIKE, which comment should be applied to the new table?
Both, with a new line between them.
David J.
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Chao Li writes: > On Feb 12, 2026, at 23:33, Jim Jones wrote: >> On 12/02/2026 16:08, Fujii Masao wrote: >>> The documentation [1] states that INCLUDING COMMENTS copies comments for >>> the copied columns, constraints, and indexes. It does not mention copying >>> comments on the table itself. Therefore, not copying table comments with >>> INCLUDING COMMENTS does not appear to be a bug. That is, the proposed patch >>> seems more like an improvement than a bug fix. >> Hmm, it seemed so obvious to me that I didn’t look more closely at the >> documentation :) Although I struggle to see the rationale for not >> copying a table’s comment in a CREATE TABLE LIKE ... INCLUDING COMMENTS >> statement, I have to agree that the documentation is quite clear about >> this limitation, and therefore it cannot really be considered a bug. >> That said, it may well be worth considering for a future release. > I feel the current behavior is proper. When you create a table using > LIKE, you are cloning the structure, not the identity. Yeah, I was about to make a similar comment. We do not for example clone the ownership or permissions of the source table. Maybe there is an argument for cloning the table-level comment but it's by no means open-and-shut. So I think the current behavior is intentional not an oversight. Might be good to go find the thread in which the INCLUDING COMMENTS functionality was developed and see if there was discussion. (Speaking of which, I'm feeling very dubious about the nearby proposal to invent LIKE INCLUDING POLICIES. It's hard to credit that it makes sense to clone RLS policies while not cloning table ownership and permissions. But I suppose I should raise that point in that thread.) regards, tom lane
Re: COMMENTS are not being copied in CREATE TABLE LIKE
Thanks everyone for the comments!
On 13/02/2026 05:30, Tom Lane wrote:
> Chao Li writes:
>> I feel the current behavior is proper. When you create a table using
>> LIKE, you are cloning the structure, not the identity.
The concern regarding identity is certainly a valid one, but in this
case I do not see how it applies. Copying the comment would not, IMHO,
transfer the identity of the source table (in a semantic sense), but
would instead merely indicate its provenance.
> Yeah, I was about to make a similar comment. We do not for example
> clone the ownership or permissions of the source table. Maybe there
> is an argument for cloning the table-level comment but it's by no
> means open-and-shut. So I think the current behavior is intentional
> not an oversight. Might be good to go find the thread in which the
> INCLUDING COMMENTS functionality was developed and see if there was
> discussion.
I did a bit of digging in the mailing list and found this old thread[1]
where INCLUDING COMMENTS was introduced. I couldn't see anything related
to table-level comments there. Perhaps it was discussed elsewhere?
On 13/02/2026 05:13, Fujii Masao wrote:
> For example, if two source tables each have a table comment and both are
> specified in LIKE, which comment should be applied to the new table?
On 13/02/2026 05:22, David G. Johnston wrote:
> Both, with a new line between them.
I supposed we could, as David mentioned, simply concatenate them. How it
should be done can be discussed, but a \n (or two) would IMO work just fine.
Example:
CREATE TABLE t1 (a int);
COMMENT ON TABLE t1 IS 'comment from table 1';
CREATE TABLE t2 (b int);
COMMENT ON TABLE t2 IS 'comment from table 2';
CREATE TABLE t3 (c int);
COMMENT ON TABLE t3 IS 'comment from table 3';
CREATE TABLE tm (
LIKE t1 INCLUDING COMMENTS,
LIKE t3 INCLUDING COMMENTS,
LIKE t2 INCLUDING COMMENTS
);
SELECT obj_description('tm'::regclass, 'pg_class') AS table_comment;
table_comment
----------------------
comment from table 1+
comment from table 3+
comment from table 2
(1 row)
Any thoughts on that?
Best, Jim
1 -
https://www.postgresql.org/message-id/flat/20090907114058.C855.52131E4D%40oss.ntt.co.jpRe: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Hüseyin Demir <huseyin.d3r@gmail.com>
Дата:
Hi Jim, I have a couple of concerns about the patch and I wanted to highlight the following cases. 1. Table comments tend to describe the purpose or context of a specific table (e.g. "staging table for pipeline X"), unlike column or constraint comments which describe the schema structure. Copying them by default may be wrong more often than it's right, since the new table almost certainly serves a different purpose than the source. 2. This changes the behavior of INCLUDING ALL, which many users rely on without thinking too carefully about what it pulls in. Silently copying a source table's comment (which might say something like "template — do not use directly") into every derived table could cause confusion in practice. Neither of these is necessarily a blocker, but I think they're worth discussing before we commit to this as the default behavior under INCLUDING COMMENTS. Before reviewing the patch for code quality and repo standards, I think we need to decide whether this behavior change is the right approach at all. My preference would be to keep table comments managed separately, given the situations above.
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi Hüseyin On 22/02/2026 09:05, Hüseyin Demir wrote: > 1. Table comments tend to describe the purpose or context of a specific table (e.g. "staging table for pipeline X"), unlike column or constraint comments which describe the schema structure. Copying them by default may be wrong more often than it's right, since the new table almost certainly serves a different purpose than the source. Good point. Comments may well lose their semantic value when placed in a different context, but I'm not sure how it differs from column comments. A column comment can also refer to a context (original table) that is no longer applicable after cloning, specially when the CREATE TABLE LIKE includes multiple tables. > 2. This changes the behavior of INCLUDING ALL, which many users rely on without thinking too carefully about what it pulls in. Silently copying a source table's comment (which might say something like "template — do not use directly") into every derived table could cause confusion in practice. It's also a valid concern - although I see it slightly differently. I we take this line of reasoning too seriously, we might never be able to expand CREATE TABLE LIKE, since the ALL keyword would be directly affected (expanded) in the process. There are also other patches that aim to expand CREATE TABLE LIKE, e.g. INCLUDING TRIGGERS[1] > Before reviewing the patch for code quality and repo standards, I think we need to decide whether this behavior change is the right approach at all. My preference would be to keep table comments managed separately, given the situations above. Are you suggesting we should simply keep ignoring the table comments? Or should we manage them differently? Thanks for the comments. Much appreciated! Best, Jim 1 - https://commitfest.postgresql.org/patch/6087/
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Hüseyin Demir <huseyin.d3r@gmail.com>
Дата:
Hi Jim,
> Are you suggesting we should simply keep ignoring the table comments? Or
> should we manage them differently?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.
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.
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.
Regards.
Jim Jones <jim.jones@uni-muenster.de>, 22 Şub 2026 Paz, 13:34 tarihinde şunu yazdı:
Hi Hüseyin
On 22/02/2026 09:05, Hüseyin Demir wrote:
> 1. Table comments tend to describe the purpose or context of a specific table (e.g. "staging table for pipeline X"), unlike column or constraint comments which describe the schema structure. Copying them by default may be wrong more often than it's right, since the new table almost certainly serves a different purpose than the source.
Good point. Comments may well lose their semantic value when placed in a
different context, but I'm not sure how it differs from column comments.
A column comment can also refer to a context (original table) that is no
longer applicable after cloning, specially when the CREATE TABLE LIKE
includes multiple tables.
> 2. This changes the behavior of INCLUDING ALL, which many users rely on without thinking too carefully about what it pulls in. Silently copying a source table's comment (which might say something like "template — do not use directly") into every derived table could cause confusion in practice.
It's also a valid concern - although I see it slightly differently. I we
take this line of reasoning too seriously, we might never be able to
expand CREATE TABLE LIKE, since the ALL keyword would be directly
affected (expanded) in the process. There are also other patches that
aim to expand CREATE TABLE LIKE, e.g. INCLUDING TRIGGERS[1]
> Before reviewing the patch for code quality and repo standards, I think we need to decide whether this behavior change is the right approach at all. My preference would be to keep table comments managed separately, given the situations above.
Are you suggesting we should simply keep ignoring the table comments? Or
should we manage them differently?
Thanks for the comments. Much appreciated!
Best, Jim
1 - https://commitfest.postgresql.org/patch/6087/
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
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
Re: COMMENTS are not being copied in CREATE TABLE LIKE
On 13/02/2026 10:19, Jim Jones wrote:
> ...
> Example:
>
> CREATE TABLE t1 (a int);
> COMMENT ON TABLE t1 IS 'comment from table 1';
> CREATE TABLE t2 (b int);
> COMMENT ON TABLE t2 IS 'comment from table 2';
> CREATE TABLE t3 (c int);
> COMMENT ON TABLE t3 IS 'comment from table 3';
>
> CREATE TABLE tm (
> LIKE t1 INCLUDING COMMENTS,
> LIKE t3 INCLUDING COMMENTS,
> LIKE t2 INCLUDING COMMENTS
> );
>
> SELECT obj_description('tm'::regclass, 'pg_class') AS table_comment;
> table_comment
> ----------------------
> comment from table 1+
> comment from table 3+
> comment from table 2
> (1 row)
>
>
> Any thoughts on that?
Rebase
Best, JimRe: COMMENTS are not being copied in CREATE TABLE LIKE
Em seg., 23 de mar. de 2026 às 16:40, Jim Jones <jim.jones@uni-muenster.de> escreveu:
On 13/02/2026 10:19, Jim Jones wrote:
> ...
> Example:
>
> CREATE TABLE t1 (a int);
> COMMENT ON TABLE t1 IS 'comment from table 1';
> CREATE TABLE t2 (b int);
> COMMENT ON TABLE t2 IS 'comment from table 2';
> CREATE TABLE t3 (c int);
> COMMENT ON TABLE t3 IS 'comment from table 3';
>
> CREATE TABLE tm (
> LIKE t1 INCLUDING COMMENTS,
> LIKE t3 INCLUDING COMMENTS,
> LIKE t2 INCLUDING COMMENTS
> );
>
> SELECT obj_description('tm'::regclass, 'pg_class') AS table_comment;
> table_comment
> ----------------------
> comment from table 1+
> comment from table 3+
> comment from table 2
> (1 row)
>
>
> Any thoughts on that?
Rebase
Best, Jim
I ran some tests after applying your patch and initially didn't find any problems. I tried to cover the main scenarios in a focused way, observing the generated results.
Regarding the possibility of including comments in the table itself using the LIKE clause, it seems sensible since other elements like columns, indexes, and constraints have copied comments, as already discussed in the thread.
Just one point I'd like to address is the documentation. Following the idea of the other "includings" options wouldn't it be interesting to present a more concise text? As a suggestion, it could be something like:
"Comments on columns, not null and check constraints, indexes, extended statistics and the table itself from a source table will be copied. If the command references multiple source tables with including clauses, any existing table-level comments will be merged into a single entry, separated by newlines in the order they were specified."
I've attached some preliminary tests I performed.
Thank you in advance for your attention.
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi Carlos On 24/03/2026 19:32, Carlos Alves wrote: > Just one point I'd like to address is the documentation. Following the > idea of the other "includings" options wouldn't it be interesting to > present a more concise text? As a suggestion, it could be something like: > > "Comments on columns, not null and check constraints, indexes, extended > statistics and the table itself from a source table will be copied. If > the command references multiple source tables with including clauses, > any existing table-level comments will be merged into a single entry, > separated by newlines in the order they were specified." In the second paragraph of the INCLUDING COMMENTS docs I wrote: If multiple LIKE clauses specify INCLUDING COMMENTS and the source tables have table-level comments, these comments will be concatenated in the new table, separated by newlines, in the order that the LIKE clauses appear. Which pretty much states the same? Please let me know if I am missing your point here. > I've attached some preliminary tests I performed. Thanks for the thorough tests. Much appreciated! Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Carlos Alves <carlos@alves.inf.br>
Дата:
Em qua., 25 de mar. de 2026 às 06:23, Jim Jones <jim.jones@uni-muenster.de> escreveu:
Hi Carlos
On 24/03/2026 19:32, Carlos Alves wrote:
> Just one point I'd like to address is the documentation. Following the
> idea of the other "includings" options wouldn't it be interesting to
> present a more concise text? As a suggestion, it could be something like:
>
> "Comments on columns, not null and check constraints, indexes, extended
> statistics and the table itself from a source table will be copied. If
> the command references multiple source tables with including clauses,
> any existing table-level comments will be merged into a single entry,
> separated by newlines in the order they were specified."
In the second paragraph of the INCLUDING COMMENTS docs I wrote:
<para>
If multiple <literal>LIKE</literal> clauses specify
<literal>INCLUDING COMMENTS</literal> and the source tables have
table-level comments, these comments will be concatenated in the new
table, separated by newlines, in the order that the
<literal>LIKE</literal> clauses appear.
</para>
Which pretty much states the same? Please let me know if I am missing
your point here.
> I've attached some preliminary tests I performed.
Thanks for the thorough tests. Much appreciated!
Best, Jim
I saw the second paragraph that you wrote and the explanations are perfect!
My suggestion was instead of describing it in two paragraphs, try describing the parameter in just one (and the text I sent was just a suggestion).
But your document is perfect for me! It was just to simplify, as in the description of the other parameters.
Sincerely, Carlos
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Carlos Alves <carlos@alves.inf.br>
Дата:
The following review has been posted through the commitfest application: make installcheck-world: tested, passed Implements feature: tested, passed Spec compliant: not tested Documentation: tested, passed Hi Jim! The tests performed were as follows: 1. Basic: creating a table from another table containing comments and without comments; 2. Multiple tables: containing comments, without comments, changing the order of the tables; 3. Overriding inclusion and exclusion directives; 4. Comments with line breaks and special characters; 5. Creation of a table involving hundreds of original tables (stress test); 6. Comments in other structures: fields, indexes, constraints; 7. Output generated by pg_dump; 8. Documentation No errors or failures were detected during the tests. The only suggestion is to keep the parameter description a single paragraph, following the same style as the description of the other inclusion parameters. But the current description is coherent and okay. After the tests, the patch is working as expected: - Table-level comments are copied when the `including comments` parameter is used. - When there is more than one source table, comments, if any, are kept in the order in which they appear in the command, separated by a new line. - The performance of command execution was not affected. I think only the code review is missing, but I don't have much experience to perform this step. Best regards, Carlos
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi Carlos On 26/03/2026 18:59, Carlos Alves wrote: > No errors or failures were detected during the tests. > > The only suggestion is to keep the parameter description a single paragraph, following the same style as the description of the other inclusion parameters. But the current description is coherent and okay. > > After the tests, the patch is working as expected: > - Table-level comments are copied when the `including comments` parameter is used. > - When there is more than one source table, comments, if any, are kept in the order in which they appear in the command, separated by a new line. > - The performance of command execution was not affected. > > I think only the code review is missing, but I don't have much experience to perform this step. Thanks for this thorough review. This helps a lot! Let's see what the other reviewers have to say about the code and your docs suggestion. Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"ZizhuanLiu X-MAN" <44973863@qq.com>
Дата:
>Hi,
>
>While reviewing another patch[1] I saw that COMMENTS on tables are being
>ignored in CREATE TABLE LIKE:
>.....
>Thoughts?
>
>Best, Jim
>
>1 -
>https://www.postgresql.org/message-id/flat/DG7Y34A6VBEG.76L7K1OML5DI%40gmail.com
Hi everyone,
I would like to share my understanding of common use cases for `CREATE TABLE LIKE`
alongside some related thoughts on copying table comments.
1. When cloning a table together with its associated objects and comments for an
entirely separate business purpose:
1.1 If the user has no special requirements for the comment on the newly created table,
whether the table-level comment is copied or not will make no practical difference to them.
1.2 If the user does need a customized comment for the new table, they will manually run a
`COMMENT ON TABLE` statement to rewrite the description even under the current behavior
that does not copy table comments. Therefore the final outcome remains unaffected regardless
of whether table comments are inherited via `CREATE TABLE LIKE`.
2. If the cloned table is intended to replace the original source table, enabling automatic copy of
the table comment will bring obvious convenience and benefits.
3. In cases where multiple source tables are referenced in one `LIKE` clause, I suggest skipping table
comment copying entirely. Concatenating multiple disparate table comments would result in bloated
and confusing text that fails to accurately describe the intended purpose of the combined new table.
4. As for table ownership and access privileges, these attributes should follow the default rules applied
during standard table creation rather than being copied one-to-one from the source table. We can
draw an analogy to the `cp` command in operating systems: file and directory ownership, group
assignments and access permissions are determined by the system umask environment variable instead
of an exact duplicate of the source file’s permission settings.
5. This aligns with an earlier suggestion from the mailing list thread linked below:
https://www.postgresql.org/message-id/flat/20090907114058.C855.52131E4D@oss.ntt.co.jp
> I realize that might involve a bit
> more code, but I think I'd feel happier if we cloned all the comments we
> reasonably could from the outset.”
From my perspective, adding support to copy table-level comments carries no obvious negative side effects.
Thanks for your time and discussion.
regards,
--
ZizhuanLiu (X-MAN)
44973863@qq.com
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi ZizhuanLiu Thanks for the detailed review! On 18.07.26 16:03, ZizhuanLiu X-MAN wrote: > 3. In cases where multiple source tables are referenced in one `LIKE` clause, I suggest skipping table > comment copying entirely. Concatenating multiple disparate table comments would result in bloated > and confusing text that fails to accurately describe the intended purpose of the combined new table. I slightly disagree. I don't have a strong opinion about it, but I find this a rather unnecessary limitation. I do understand the concern of a bloated comment, but doing so we sort of imply that *all* table comments are not fit for this feature, which is arguably not accurate. IMHO, if the user explicitly wants the comments to be copied, we should not judge if the they make sense or not -- of course, given that the documentation describes the concatenation. What do you think? Thanks for the comments. Much appreciated! Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"ZizhuanLiu X-MAN" <44973863@qq.com>
Дата:
>Hi ZizhuanLiu > >Thanks for the detailed review! > >On 18.07.26 16:03, ZizhuanLiu X-MAN wrote: >> 3. In cases where multiple source tables are referenced in one `LIKE` clause, I suggest skipping table >> comment copying entirely. Concatenating multiple disparate table comments would result in bloated >> and confusing text that fails to accurately describe the intended purpose of the combined new table. > >I slightly disagree. I don't have a strong opinion about it, but I find >this a rather unnecessary limitation. I do understand the concern of a >bloated comment, but doing so we sort of imply that *all* table comments >are not fit for this feature, which is arguably not accurate. IMHO, if >the user explicitly wants the comments to be copied, we should not judge >if the they make sense or not -- of course, given that the documentation >describes the concatenation. > >What do you think? > >Thanks for the comments. Much appreciated! > >Best, Jim Hi Jim,everyone Thanks a lot for your feedback. I’ve been thinking about the scenario where multiple source tables are used, and here are my concerns: 1. Even putting aside the problem of bloated combined text, we need to consider whether concatenating all source table comments delivers what developers, DBAs and business users actually expect. Can the merged description accurately reflect the intended purpose of the newly created table? 2. If we do implement comment concatenation, what merging rules should we adopt? Should we cap the number of source tables whose comments get merged, or impose a maximum character limit on the final combined text? Whichever restriction we pick will likely require truncating parts of the original comments. After truncation, can the resulting text still match what users intend to document? 3. In both cases outlined above, I believe the merged result will fail to satisfy users in most real-world scenarios. Even if we build this merging logic, users will still end up having to manually rewrite the table comment afterwards to fix it(Unless he does not care about it). Given that extra manual cleanup work would be unavoidable, it may be better to skip copying table-level comments entirely for multi-table cases. 4. It is indeed tricky to strike a balance between consistent feature behavior and intuitive, reasonable usability, which is exactly why we’re having this discussion. Our ultimate goal is to deliver a smooth experience for end users, so I think it makes sense to shape the design around the needs of the vast majority of users in their common use cases. Looking forward to hearing more thoughts from everyone. regards, -- ZizhuanLiu (X-MAN) 44973863@qq.com
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
"ZizhuanLiu X-MAN" <44973863@qq.com>
Дата:
>Original
>From: Jim Jones
>Date: 2026-07-23 19:51
>To: ZizhuanLiu X-MAN <44973863@qq.com>, matheusssilv97 , Chao Li , masao.fujii , david.g.johnston , tgl , huseyin.d3r
>Cc: pgsql-hackers
>Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
>These are good points, but I'd argue that excluding multiple tables from
>this feature would be hard to justify. Some of these points can be made
>to column comments as well -- we cannot guarantee their semantics in the
>new table, and yet we allow them to be copied.
>
>postgres=# CREATE TABLE t1 (a int);
>COMMENT ON COLUMN t1.a IS 'foo';
>CREATE TABLE t2 (b int);
>COMMENT ON COLUMN t2.b IS 'bar';
>
>CREATE TABLE tm (
> LIKE t1 INCLUDING COMMENTS,
> LIKE t2 INCLUDING COMMENTS
>);
>CREATE TABLE
>COMMENT
>CREATE TABLE
>COMMENT
>CREATE TABLE
>postgres=# SELECT
> col_description('tm'::regclass::oid, 1),
> col_description('tm'::regclass::oid, 2);
> col_description | col_description
>-----------------+-----------------
> foo | bar
>(1 row)
>
>In this case is up to user to either make sure the column comments are
>"transferable" or to correct them in the target table -- which is also
>my case on including the table comments.
>
>I'm not totally against dropping comments for multiple tables, but I
>want to make sure our arguments against having them make sense. If we
>conclude that it's impractical to concatenate table comments we should
>also consider the option of withdrawing the patch -- it's not like I'm
>terribly in love with it :)
>
>Thanks for the input!
>
>Best, Jim
Hi, Jim, everyone
Thanks for all your feedback, discussion and reminders.
After further consideration, I would like to clarify that I am only sharing my
personal perspective here, with no intention of pushing for any specific
implementation or insisting on my preference.
I have reviewed the relevant syntax and parsing rules:
```SQL
{ INCLUDING | EXCLUDING }
{ COMMENTS | COMPRESSION | CONSTRAINTS | DEFAULTS | GENERATED | IDENTITY | INDEXES | STATISTICS | STORAGE | ALL }
```SQL
With the existing implementation, any object enabled via these clauses is
copied strictly one-to-one alongside the source objects. The command never
performs additional logic such as merging content or pruning items automatically.
This leaves three general user workflows for any single attribute type XXX:
1. All instances of XXX fit the use case perfectly: use `INCLUDING XXX` with no post-copy modifications required.
2. Most items of XXX are suitable: copy via `INCLUDING XXX`, then apply minor manual adjustments afterward.
3. Only a small subset of XXX items are needed: skip copying entirely with `EXCLUDING XXX`, with optional follow-up tweaks.
Extending this logic to the full set of attributes covered by `ALL`:
1. Every attribute works as expected: use `INCLUDING ALL` with zero follow-up changes.
2. Most attributes are applicable: either copy everything with `INCLUDING ALL` and tweak afterward,
or use `INCLUDING ALL` paired with `EXCLUDING XXX/YYY/ZZZ...` to exclude unwanted categories.
3. Only a minority of attributes are required: opt for `EXCLUDING ALL`, then explicitly list needed items
via `INCLUDING XXX/YYY/ZZZ...`.
The current syntax design covering `INCLUDING`, `EXCLUDING`, and `ALL` already offers adequate
flexibility for users to make top-level copy decisions.
One-to-one copying works reliably when exactly one source table is used.
Multi-table scenarios constitute the only exceptional case where the command’s behavior diverges
from single-table usage. If we can resolve the merging logic properly, I believe merging comments
would be a reasonable approach. I do not think introducing brand-new dedicated syntax options is
necessary for this scenario. At this stage, I have not come up with a more elegant alternative solution.
regards,
--
ZizhuanLiu (X-MAN)
44973863@qq.comRe: COMMENTS are not being copied in CREATE TABLE LIKE
>Original
>From: Jim Jones
>Date: 2026-07-23 19:51
>To: ZizhuanLiu X-MAN <44973863@qq.com>, matheusssilv97 , Chao Li , masao.fujii , david.g.johnston , tgl , huseyin.d3r
>Cc: pgsql-hackers
>Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
>These are good points, but I'd argue that excluding multiple tables from
>this feature would be hard to justify. Some of these points can be made
>to column comments as well -- we cannot guarantee their semantics in the
>new table, and yet we allow them to be copied.
>
>postgres=# CREATE TABLE t1 (a int);
>COMMENT ON COLUMN t1.a IS 'foo';
>CREATE TABLE t2 (b int);
>COMMENT ON COLUMN t2.b IS 'bar';
>
>CREATE TABLE tm (
> LIKE t1 INCLUDING COMMENTS,
> LIKE t2 INCLUDING COMMENTS
>);
>CREATE TABLE
>COMMENT
>CREATE TABLE
>COMMENT
>CREATE TABLE
>postgres=# SELECT
> col_description('tm'::regclass::oid, 1),
> col_description('tm'::regclass::oid, 2);
> col_description | col_description
>-----------------+-----------------
> foo | bar
>(1 row)
>
>In this case is up to user to either make sure the column comments are
>"transferable" or to correct them in the target table -- which is also
>my case on including the table comments.
>
>I'm not totally against dropping comments for multiple tables, but I
>want to make sure our arguments against having them make sense. If we
>conclude that it's impractical to concatenate table comments we should
>also consider the option of withdrawing the patch -- it's not like I'm
>terribly in love with it :)
>
>Thanks for the input!
>
>Best, Jim
Hi, Jim, everyone
I have checked Db2’s syntax design. Db2’s LIKE syntax is intended to copy columns
only from a single source object, which may be a table, view or nickname. This matches
our discussion perfectly: single-table usage works smoothly, but it is difficult to implement
elegant comment copying when multiple source tables are involved.
```Db2
>>-CREATE TABLE--table-name------------------------------------->
>--+-| element-list |----------------------------+--●----------->
+-OF--type-name1--+-------------------------+-+
| '-| typed-table-options |-' |
+-LIKE--+-table-name1-+--+------------------+-+
| +-view-name---+ '-| copy-options |-' |
| '-nickname-----' |
+-| as-result-table |--+------------------+---+
| '-| copy-options |-' |
+-| materialized-query-definition |-----------+
'-| staging-table-definition |----------------'
......
......
copy-options
|--●--+---------------------------------------------+--●---------------->
| .-COLUMN-. |
'-+-INCLUDING-+--+-----------+--DEFAULTS-'
'-EXCLUDING-'
.-COLUMN ATTRIBUTES-.
.-EXCLUDING IDENTITY--+-------------------------+-.
>--+-------------------------------------------------------+--●-------------|
| .-COLUMN ATTRIBUTES-. |
'-INCLUDING IDENTITY--+-------------------------+--'
```Db2
I suspect PostgreSQL’s CREATE TABLE LIKE was also originally intended to copy metadata
from just one source table, though I found no archived mailing list records to verify this
original design purpose. Even so, PostgreSQL’s syntax and implementation allow users to
specify multiple source tables.
I think multi-table support was added mainly to aggregate columns from different tables,
since most options under `INCLUDING`/`EXCLUDING` govern column-level attributes.
This leads me to wonder why table comment copying was never implemented.
It is probable that developers chose to omit multi-table table comment copying to
enable merging columns from several source tables. Even so, copying table comments
when there is only one source table would be a valuable improvement.
Overall, PostgreSQL supports many more copyable objects and attributes than Db2.
regards,
--
ZizhuanLiu (X-MAN)
44973863@qq.com
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Alex Liapychev <coder.sam@gmail.com>
Дата:
Hello Jim,
Hello everyone,
Thank you Jim and all the reviewers for working on this patch.
We reviewed the patch version v3 on September 20, 2026.
The patch aims to fill the gap in CREATE TABLE LIKE functionality, where INCLUDING COMMENTS or INCLUDING ALL does not copy a comment of a Table itself.
While there is still a discussion going on, if the table's own comment is worth copying at all, we concentrated on reviewing implementation itself.
Patch set structure is good: description of what was done and why, documentation and tests included.
We compiled the patch from branch cf/6482 (commit: 451748bf) against master (commit: 9e17d25e79d) on MacOS (version 26.6.2) on Intel hardware.
Run standard tests(meson tests) and executed manual tests in psql. Tests in both master and cf/6482 completed successfully.
Below are our findings:
1. Corner case: concatenation of big comments, whose total size exceeds MaxAllocSize, fails with an error.
Here is the test case to prove that:
```
CREATE TABLE comment_1gb_test (id BIGINT);
-- set comment 1 GiB in size
UPDATE pg_catalog.pg_description
SET description = pg_catalog.repeat('x', 1000000000)
WHERE classoid = 'pg_catalog.pg_class'::regclass
AND objoid = 'public.comment_1gb_test'::regclass
AND objsubid = 0;
SELECT octet_length(description) as comment_size_bytes FROM pg_catalog.pg_description WHERE classoid = 'pg_catalog.pg_class'::regclass AND objoid = 'public.comment_1gb_test'::regclass AND objsubid = 0;
comment_size_bytes
--------------------
1000000000
(1 row)
CREATE TABLE xxl1 (LIKE comment_1gb_test INCLUDING ALL);
CREATE TABLE xxl2 (LIKE comment_1gb_test INCLUDING ALL);
ALTER TABLE xxl2 RENAME COLUMN id TO id2;
CREATE TABLE merge_xxl (LIKE xxl1 INCLUDING ALL, LIKE xxl2 INCLUDING ALL);
ERROR: string buffer exceeds maximum allowed length (1073741823 bytes)
DETAIL: Cannot enlarge string buffer containing 1000000001 bytes by 1000000000 more bytes.
```
Some form of truncation should be applied, cap the total size is easiest: first table's comment takes an advantage, others - as fit.
2. Code review notes:
2.1. nitpick: parse_utilcmd.c:46: order of includes would be better if added include ("lib/stringinfo.h") was placed either before "miscadmin.h" (alphabetical order) or before "utils/..." (functional order).
2.2. nitpick: parse_utilcmd.c:1652: it would match style of surrounding code better if local variable `CommentStmt *stmt` would be named `comment_stmt`; see code above in the same function: `stats_stmt` (line 1618), `index_stmt` (line 1577), etc.
2.3. nitpick: create_table_like.out:486 & create_table_like.sql:198: Since behaviour of INCLUDING ALL has also been changed by this patch. It would be better to update the tests to cover it.
Thank you very much for your attention.
Kind regards,
Eddie Cho and Alex Liapychev
P.S.
This is our first review, it was done together within a Postgres Patch Review Workshop: Sept 2026.
Thank you, Paul A. Jungwirth, for your efforts to welcome newcomers and involve them in meaningful work on PostgreSQL.
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Tomas Vondra <tomas@vondra.me>
Дата:
On 9/20/26 22:28, Alex Liapychev wrote:
> Hello Jim,
> Hello everyone,
>
> Thank you Jim and all the reviewers for working on this patch.
>
> We reviewed the patch version v3 on September 20, 2026.
>
> The patch aims to fill the gap in CREATE TABLE LIKE functionality, where INCLUDING COMMENTS or INCLUDING ALL does not copy a comment of a Table itself.
> While there is still a discussion going on, if the table's own comment is worth copying at all, we concentrated on reviewing implementation itself.
>
> Patch set structure is good: description of what was done and why, documentation and tests included.
> We compiled the patch from branch cf/6482 (commit: 451748bf) against master (commit: 9e17d25e79d) on MacOS (version 26.6.2) on Intel hardware.
> Run standard tests(meson tests) and executed manual tests in psql. Tests in both master and cf/6482 completed successfully.
>
> Below are our findings:
>
> 1. Corner case: concatenation of big comments, whose total size exceeds MaxAllocSize, fails with an error.
> Here is the test case to prove that:
> ```
> CREATE TABLE comment_1gb_test (id BIGINT);
> -- set comment 1 GiB in size
> UPDATE pg_catalog.pg_description
> SET description = pg_catalog.repeat('x', 1000000000)
> WHERE classoid = 'pg_catalog.pg_class'::regclass
> AND objoid = 'public.comment_1gb_test'::regclass
> AND objsubid = 0;
> SELECT octet_length(description) as comment_size_bytes FROM pg_catalog.pg_description WHERE classoid = 'pg_catalog.pg_class'::regclass AND objoid = 'public.comment_1gb_test'::regclass AND objsubid = 0;
> comment_size_bytes
> --------------------
> 1000000000
> (1 row)
> CREATE TABLE xxl1 (LIKE comment_1gb_test INCLUDING ALL);
> CREATE TABLE xxl2 (LIKE comment_1gb_test INCLUDING ALL);
> ALTER TABLE xxl2 RENAME COLUMN id TO id2;
>
> CREATE TABLE merge_xxl (LIKE xxl1 INCLUDING ALL, LIKE xxl2 INCLUDING ALL);
> ERROR: string buffer exceeds maximum allowed length (1073741823 bytes)
> DETAIL: Cannot enlarge string buffer containing 1000000001 bytes by 1000000000 more bytes.
> ```
> Some form of truncation should be applied, cap the total size is easiest: first table's comment takes an advantage, others - as fit.
>
I'd just reject such cases, with an ERROR that says the comment would be
too long. It's cleaner than just silently start discarding user
information. The number of people hitting this is about 0 anyway. Who
would even have comments of this size?
That being said, I'm not convinced we actually want to concatenate
comments like this. It feels a bit weird, and it can probably lead to
weird stuff like "duplicate" comments, etc. Do we have any precedent for
this behavior? Are we concatenating comments (or other stuff) anywhere?
I couldn't find such place, but maybe I missed something.
FWIW if we really are worried about very long comments, then maybe
expandTableLikeClause should be more careful about freeing comments
during the concatenation? Right now it keeps all the comments and then
also the intermediate strings during concatenation. (I think.)
> 2. Code review notes:
> 2.1. nitpick: parse_utilcmd.c:46: order of includes would be better if added include ("lib/stringinfo.h") was placed either before "miscadmin.h" (alphabetical order) or before "utils/..." (functional order).
Before miscadmin.h, please. We keep includes in alphabetical order.
> 2.2. nitpick: parse_utilcmd.c:1652: it would match style of surrounding code better if local variable `CommentStmt *stmt` would be named `comment_stmt`; see code above in the same function: `stats_stmt` (line 1618), `index_stmt` (line 1577), etc.
Seems very cosmetic, and there's also a lot of places using 'stmt'.
> 2.3. nitpick: create_table_like.out:486 & create_table_like.sql:198: Since behaviour of INCLUDING ALL has also been changed by this patch. It would be better to update the tests to cover it.
>
Yes, that's a fair point. It'd be good to test INCLUDING ALL copies
comments too. The existing INCLUDING ALL test does not check that.
Aside from that, I don't understand why this patch needs to add
CREATE_TABLE_LIKE_COMMENTS to the last block in transformTableLikeClause
intended to deal with options that need column numbers. I mean, this
deals with a comment on the table itself, no? Or does it need to wait
for some other reason, and the comment is misleading?
regards
--
Tomas Vondra
Re: COMMENTS are not being copied in CREATE TABLE LIKE
Hi Alex, Eddie, and Tomas,
Thanks for the thorough review!
On 21/09/2026 15:58, Tomas Vondra wrote:
>
> On 9/20/26 22:28, Alex Liapychev wrote:
>> 1. Corner case: concatenation of big comments, whose total size exceeds MaxAllocSize, fails with an error.
>> Here is the test case to prove that:
>> ```
>> CREATE TABLE comment_1gb_test (id BIGINT);
>> -- set comment 1 GiB in size
>> UPDATE pg_catalog.pg_description
>> SET description = pg_catalog.repeat('x', 1000000000)
>> WHERE classoid = 'pg_catalog.pg_class'::regclass
>> AND objoid = 'public.comment_1gb_test'::regclass
>> AND objsubid = 0;
>> SELECT octet_length(description) as comment_size_bytes FROM pg_catalog.pg_description WHERE classoid = 'pg_catalog.pg_class'::regclass AND objoid = 'public.comment_1gb_test'::regclass AND objsubid = 0;
>> comment_size_bytes
>> --------------------
>> 1000000000
>> (1 row)
>> CREATE TABLE xxl1 (LIKE comment_1gb_test INCLUDING ALL);
>> CREATE TABLE xxl2 (LIKE comment_1gb_test INCLUDING ALL);
>> ALTER TABLE xxl2 RENAME COLUMN id TO id2;
>>
>> CREATE TABLE merge_xxl (LIKE xxl1 INCLUDING ALL, LIKE xxl2 INCLUDING ALL);
>> ERROR: string buffer exceeds maximum allowed length (1073741823 bytes)
>> DETAIL: Cannot enlarge string buffer containing 1000000001 bytes by 1000000000 more bytes.
>> ```
>> Some form of truncation should be applied, cap the total size is easiest: first table's comment takes an advantage, others - as fit.
>>
>
> I'd just reject such cases, with an ERROR that says the comment would be
> too long. It's cleaner than just silently start discarding user
> information. The number of people hitting this is about 0 anyway. Who
> would even have comments of this size?
I also doubt that anyone has a use case that justifies such a large
comment. The needed size for the merged comment is now checked and an
error is raised if it exceeds MaxAllocSize.
psql (20devel)
Type "help" for help.
postgres=# CREATE TABLE xxl1 (a int);
CREATE TABLE xxl2 (b int);
SET allow_system_table_mods = on;
INSERT INTO pg_description VALUES ('xxl1'::regclass,
'pg_class'::regclass, 0, repeat('x',600000000));
INSERT INTO pg_description VALUES ('xxl2'::regclass,
'pg_class'::regclass, 0, repeat('y',600000000));
CREATE TABLE
CREATE TABLE
SET
INSERT 0 1
INSERT 0 1
postgres=# CREATE TABLE merge_xxl (LIKE xxl1 INCLUDING COMMENTS, LIKE
xxl2 INCLUDING COMMENTS);
ERROR: comment for relation "merge_xxl" is too long
DETAIL: The comment is the concatenation of comments copied from
multiple relations named in LIKE clauses, and the result exceeds the
maximum size allowed for a comment.
> That being said, I'm not convinced we actually want to concatenate
> comments like this. It feels a bit weird, and it can probably lead to
> weird stuff like "duplicate" comments, etc. Do we have any precedent for
> this behavior? Are we concatenating comments (or other stuff) anywhere?
> I couldn't find such place, but maybe I missed something.
Neither am I. I'm just not sure that ignoring the comments when using
multiple tables is a better alternative. I can live with it, but so far
I didn't find enough arguments to remove it. The alternatives I see are:
1) concatenate with a (\n) separator (current behaviour)
2) concatenate without a separator
3) first one wins
4) last one wins
5) ignore it altogether when multiple comments are detected (my least
favourite)
6) your idea? :)
WDYT?
>> 2. Code review notes:
>> 2.1. nitpick: parse_utilcmd.c:46: order of includes would be better if added include ("lib/stringinfo.h") was placed either before "miscadmin.h" (alphabetical order) or before "utils/..." (functional order).
>
> Before miscadmin.h, please. We keep includes in alphabetical order.
Fixed.
>> 2.2. nitpick: parse_utilcmd.c:1652: it would match style of surrounding code better if local variable `CommentStmt *stmt` would be named `comment_stmt`; see code above in the same function: `stats_stmt` (line 1618), `index_stmt` (line 1577), etc.
>
> Seems very cosmetic, and there's also a lot of places using 'stmt'.
>
>> 2.3. nitpick: create_table_like.out:486 & create_table_like.sql:198: Since behaviour of INCLUDING ALL has also been changed by this patch. It would be better to update the tests to cover it.
>>
>
> Yes, that's a fair point. It'd be good to test INCLUDING ALL copies
> comments too. The existing INCLUDING ALL test does not check that.
Fixed. I also included a few tests with views, custom types, foreign
tables, and temporary tables.
>
> Aside from that, I don't understand why this patch needs to add
> CREATE_TABLE_LIKE_COMMENTS to the last block in transformTableLikeClause
> intended to deal with options that need column numbers. I mean, this
> deals with a comment on the table itself, no? Or does it need to wait
> for some other reason, and the comment is misleading?
While revisiting the code I found a much larger problem: v3 hard codes
OBJECT_TABLE in obj_type, which breaks the feature when the target is a
foreign table:
psql (20devel)
Type "help" for help.
postgres=# CREATE TABLE t1 (a int);
COMMENT ON TABLE t1 IS 't1 comment';
CREATE SERVER s FOREIGN DATA WRAPPER dummy;
CREATE FOREIGN TABLE ft (LIKE t1 INCLUDING ALL) SERVER s;
CREATE TABLE
COMMENT
CREATE SERVER
ERROR: "ft" is not a table
-- PG18
psql (18.4 (Debian 18.4-1.pgdg13+1))
Type "help" for help.
postgres=# CREATE TABLE t1 (a int);
COMMENT ON TABLE t1 IS 't1 comment';
CREATE SERVER s FOREIGN DATA WRAPPER dummy;
CREATE FOREIGN TABLE ft (LIKE t1 INCLUDING ALL) SERVER s;
CREATE TABLE
COMMENT
CREATE SERVER
CREATE FOREIGN TABLE
postgres=# \d ft
Foreign table "public.ft"
Column | Type | Collation | Nullable | Default | FDW options
--------+---------+-----------+----------+---------+-------------
a | integer | | | |
Server: s
I moved the logic to transformCreateStmt, where I can use cxt.isforeign
to feed cstmt->objtype with OBJECT_FOREIGN_TABLE or OBJECT_TABLE.
Another open question: should we also copy the comments from custom
types when they're used in the LIKE clause?
Example (copied from the regression tests):
CREATE TYPE ctlty_comment6 AS (f int);
COMMENT ON TYPE ctlty_comment6 IS 'comment6';
CREATE TABLE ctlt_type_comment (LIKE ctlty_comment6 INCLUDING COMMENTS);
SELECT obj_description('ctlt_type_comment'::regclass, 'pg_class') AS
table_comment;
table_comment
---------------
comment6
(1 row)
I'd be inclined to leave it out, since types and tables aren't
semantically very close, but I'd like to hear your thoughts first --
removing it would be quick.
PFA v4.
WDYT?
Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Alex Liapychev <coder.sam@gmail.com>
Дата:
Hi Jim and Tomas, everyone, Thank you Tomas for stepping in and putting things into perspective. Thank you Jim for making the changes so quickly. We did a recheck of the new version v4 of the patch on September 26, 2026. Branch cf/6482 (commit: 47ed4119) rebased over master (commit: f25c50fd). Tests on both master alone and with cf/6482 on top completed successfully. V4 is a complete rewrite. Author fixed all issues pointed by Tomas and by us (see 3 previous messages). I will list notable changes briefly: 1. Docs: create_table.sgml:695 - replaced “table” for “source relation”, because it could be other types of relations. 2. Tests: added INCLUDING ALL test case; test cases for concatenation corner cases; foreign and temporary table as copy target cases; type as a source case. 3. Code review of a file parse_utilcmd.c: 3.1. Includes are now sorted in alphabetical order. 3.2. Case when concatenated comment exceeds MaxAllocSize: >>> 1. Corner case: concatenation of big comments, whose total size exceeds MaxAllocSize, fails with an error. >> I'd just reject such cases, with an ERROR that says the comment would be >> too long. It's cleaner than just silently start discarding user >> information. The number of people hitting this is about 0 anyway. Who >> would even have comments of this size? Implemented on L:1369-1374, error ERRCODE_PROGRAM_LIMIT_EXCEEDED is returned with clear message. 3.3. Memory allocation and freeing: >> FWIW if we really are worried about very long comments, then maybe >> expandTableLikeClause should be more careful about freeing comments >> during the concatenation? Right now it keeps all the comments and then >> also the intermediate strings during concatenation. (I think.) I tried to trace memory allocations, there are 2 scopes where allocations happen: 3.3.a. The local scope, where comment of each LIKE relation is read: - allocated: in GetComment (L:1348 or 1352); - freed: pfree(tblcomment) at L:1379; Seems good. 3.3.b. Scope of transformCreateStmt function: - defined: Variable cxt (CreateStmtContext) is created on stack (at L:176), inside is new field tablecomment (StringInfo). - - It is NULLed before first use at L:257. - allocated: Field cxt->tablecomment is initialised at L:1361 via makeStringInfo(), which does 2 palloc’s internally. - read: cxt.tablecomment->data is stored into cstmt->comment at L:321. - freed: NEVER. destroyStringInfo is not called from parse_utilcmd.c. Which seems correct, because we pass data to outside of a function. But probably we should call pfree for cxt.tablecomment (StringInfo struct itself) to balance 1st palloc from makeStringInfo. 3.3.c. (bonus) Scope where de-allocation also might happen: Comment produced in transformCreateStmt function then reaches code from file comment.c, where it is stored to target relation. I could not find any pfree for stmt->comment inside the file comment.c, where it is consumed. Which should exist to balance 2nd palloc from makeStringInfo. I don’t know if this palloc'd memory is freed somehow automagically at some later point. But to my understanding it may be a memory leak, which spans past this specific patch scope. 4. The question if we should concat comments at all: >> That being said, I'm not convinced we actually want to concatenate >> comments like this. It feels a bit weird, and it can probably lead to >> weird stuff like "duplicate" comments, etc. Do we have any precedent for >> this behavior? Are we concatenating comments (or other stuff) anywhere? >> I couldn't find such place, but maybe I missed something. > > Neither am I. I'm just not sure that ignoring the comments when using > multiple tables is a better alternative. I can live with it, but so far > I didn't find enough arguments to remove it. The alternatives I see are: > > 1) concatenate with a (\n) separator (current behaviour) > 2) concatenate without a separator > 3) first one wins > 4) last one wins > 5) ignore it altogether when multiple comments are detected (my least > favourite) > 6) your idea? :) > > WDYT? I think from perspective of semantics of INCLUDING COMMENTS/ALL it seems right to copy comments of a table. But for such complicated scenario, where there are few source relations - not sure. Maybe "last one wins" would be the easiest to implement and least counter-intuitive for users? This concatenation code works, but what consequences it may have to support it over years? Kind regards, Alex Liapychev
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Alex Liapychev <coder.sam@gmail.com>
Дата:
Hi Jim and Tomas, everyone,
I dig the mailing list to find if there was anything related to copying the table comments in the past.
I have found thread starting on 2009-09-07, where “COMMENTS” was added to “INCLUDING …” clause for the first time:
Part of the discussion in this thread regarding COMMENTS goes around columns, indexes and constraints.
I could not find any mention of table’s own comment.
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.
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.
- 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.
Kind regards,
Alex Liapychev
On 27 Sep 2026, at 02:23, Alex Liapychev <coder.sam@gmail.com> wrote:Hi Jim and Tomas, everyone,
Thank you Tomas for stepping in and putting things into perspective.
Thank you Jim for making the changes so quickly.
We did a recheck of the new version v4 of the patch on September 26, 2026.
Branch cf/6482 (commit: 47ed4119) rebased over master (commit: f25c50fd).
Tests on both master alone and with cf/6482 on top completed successfully.
V4 is a complete rewrite.
Author fixed all issues pointed by Tomas and by us (see 3 previous messages).
I will list notable changes briefly:
1. Docs: create_table.sgml:695 - replaced “table” for “source relation”, because it could be other types of relations.
2. Tests: added INCLUDING ALL test case; test cases for concatenation corner cases; foreign and temporary table as copy target cases; type as a source case.
3. Code review of a file parse_utilcmd.c:
3.1. Includes are now sorted in alphabetical order.
3.2. Case when concatenated comment exceeds MaxAllocSize:1. Corner case: concatenation of big comments, whose total size exceeds MaxAllocSize, fails with an error.I'd just reject such cases, with an ERROR that says the comment would be
too long. It's cleaner than just silently start discarding user
information. The number of people hitting this is about 0 anyway. Who
would even have comments of this size?
Implemented on L:1369-1374, error ERRCODE_PROGRAM_LIMIT_EXCEEDED is returned with clear message.
3.3. Memory allocation and freeing:FWIW if we really are worried about very long comments, then maybe
expandTableLikeClause should be more careful about freeing comments
during the concatenation? Right now it keeps all the comments and then
also the intermediate strings during concatenation. (I think.)
I tried to trace memory allocations, there are 2 scopes where allocations happen:
3.3.a. The local scope, where comment of each LIKE relation is read:
- allocated: in GetComment (L:1348 or 1352);
- freed: pfree(tblcomment) at L:1379;
Seems good.
3.3.b. Scope of transformCreateStmt function:
- defined: Variable cxt (CreateStmtContext) is created on stack (at L:176), inside is new field tablecomment (StringInfo).
- - It is NULLed before first use at L:257.
- allocated: Field cxt->tablecomment is initialised at L:1361 via makeStringInfo(), which does 2 palloc’s internally.
- read: cxt.tablecomment->data is stored into cstmt->comment at L:321.
- freed: NEVER.
destroyStringInfo is not called from parse_utilcmd.c.
Which seems correct, because we pass data to outside of a function.
But probably we should call pfree for cxt.tablecomment (StringInfo struct itself) to balance 1st palloc from makeStringInfo.
3.3.c. (bonus) Scope where de-allocation also might happen:
Comment produced in transformCreateStmt function then reaches code from file comment.c, where it is stored to target relation.
I could not find any pfree for stmt->comment inside the file comment.c, where it is consumed.
Which should exist to balance 2nd palloc from makeStringInfo.
I don’t know if this palloc'd memory is freed somehow automagically at some later point.
But to my understanding it may be a memory leak, which spans past this specific patch scope.
4. The question if we should concat comments at all:That being said, I'm not convinced we actually want to concatenate
comments like this. It feels a bit weird, and it can probably lead to
weird stuff like "duplicate" comments, etc. Do we have any precedent for
this behavior? Are we concatenating comments (or other stuff) anywhere?
I couldn't find such place, but maybe I missed something.
Neither am I. I'm just not sure that ignoring the comments when using
multiple tables is a better alternative. I can live with it, but so far
I didn't find enough arguments to remove it. The alternatives I see are:
1) concatenate with a (\n) separator (current behaviour)
2) concatenate without a separator
3) first one wins
4) last one wins
5) ignore it altogether when multiple comments are detected (my least
favourite)
6) your idea? :)
WDYT?
I think from perspective of semantics of INCLUDING COMMENTS/ALL it seems right to copy comments of a table.
But for such complicated scenario, where there are few source relations - not sure.
Maybe "last one wins" would be the easiest to implement and least counter-intuitive for users?
This concatenation code works, but what consequences it may have to support it over years?
Kind regards,
Alex Liapychev
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
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? > 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! > * 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. Thanks! Best, Jim
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Tomas Vondra <tomas@vondra.me>
Дата:
On 10/1/26 18:49, Jim Jones 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? > 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. 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. I was wondering if maybe this was discussed when the INCLUDING COMMENTS was added, so I did a bit of digging in the archives, and I found this thread from 2009: https://www.postgresql.org/message-id/flat/20090907114058.C855.52131E4D%40oss.ntt.co.jp Unfortunately, there's no discussion about (not) copying table comments. >> 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! > >> * 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. > Right. To add comments on an object you have to be an owner, at which point you can do all kinds of dangerous stuff. I was more worried about "accidental breakage" where suddenly copying comments breaks something else. But I failed to construct a practical example, so maybe it's fine. regards -- Tomas Vondra
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Tomas Vondra writes: > 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 argument is what's bugging me. We are struggling to figure out what the patch should do with multiple comments because we don't have a clear use-case in mind. Any behavior we choose might be the wrong one for whatever usage is out there. So I'd just as soon pass on implementing this functionality until we have some field requests and we can quiz those people about their needs. regards, tom lane
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Alex Liapychev <coder.sam@gmail.com>
Дата:
Hi Jim, Hi Tomas and Tom, First, let me address the specific questions. > On 1 Oct 2026, at 18:49, Jim Jones 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
Re: COMMENTS are not being copied in CREATE TABLE LIKE
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
Re: COMMENTS are not being copied in CREATE TABLE LIKE
От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi Alex On 01/10/2026 23:13, Alex Liapychev wrote: > 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. Looking from this perspective I agree with you. I was so busy trying to find out "how to concatenate the comments" that I forgot to ask myself "why should we concatenate them". Thanks for the thorough review. Best, Jim