On Wed, Jun 18, 2025 at 10:21 AM Fujii Masao
<masao(dot)fujii(at)oss(dot)nttdata(dot)com> wrote:
>
> I ran into another issue related to comments on NOT NULL constraints.
> When using CREATE TABLE ... (LIKE ... INCLUDING ALL), the NOT NULL constraints
> are copied, but their comments are not. For example:
>
> -----------------------------------------------------
> =# CREATE TABLE t (i int);
> =# ALTER TABLE t ADD CONSTRAINT my_not_null_i NOT NULL i;
> =# ALTER TABLE t ADD CONSTRAINT my_check_i CHECK (i > 0);
> =# COMMENT ON CONSTRAINT my_not_null_i ON t IS 'my not null for i';
> =# COMMENT ON CONSTRAINT my_check_i ON t IS 'my check for i';
>
> =# CREATE TABLE t_copied (LIKE t INCLUDING ALL);
>
> As shown, the comment on my_not_null_i is not copied to the new table,
> even though the constraint itself is. Could this be another oversight
> in commit 14e87ffa5c5?
>
hi.
in transformTableLikeClausem, let cxt(CreateStmtContext) to add
CommentStmt should just work.
Please check attached, tests also added.