Re: COMMENTS are not being copied in CREATE TABLE LIKE

From: Alex Liapychev <coder(dot)sam(at)gmail(dot)com>
To: jim(dot)jones(at)uni-muenster(dot)de
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-09-20 20:28:11
Message-ID: 65963A8C-C1EE-431E-9513-C4AD16AEE789@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2026-09-20 21:16:19 Re: Serverside SNI support in libpq
Previous Message Kiran Kaki 2026-09-20 18:40:18 Re: pg_walinspect: fix LSN validation messages and empty range handling