public inbox for [email protected]  
help / color / mirror / Atom feed
From: Carlos Alves <[email protected]>
To: Jim Jones <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Chao Li <[email protected]>
Cc: Fujii Masao <[email protected]>
Cc: Matheus Alcantara <[email protected]>
Cc: [email protected] <[email protected]>
Cc: David G. Johnston <[email protected]>
Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
Date: Tue, 24 Mar 2026 15:32:21 -0300
Message-ID: <CAL-Pge4eWCAu7VcjXhXxFKPwT0jYqG2xG7vRAyZJXcr75voJCA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<CAHGQGwF-uuKkon8Ah9dbMiGKoYmFJyHZnDa_HcWWCXKnh7LJ2Q@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

Em seg., 23 de mar. de 2026 às 16:40, Jim Jones <[email protected]>
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


Hi 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.


Attachments:

  [application/octet-stream] tests.sql (8.2K, 3-tests.sql)
  download

view thread (18+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: COMMENTS are not being copied in CREATE TABLE LIKE
  In-Reply-To: <CAL-Pge4eWCAu7VcjXhXxFKPwT0jYqG2xG7vRAyZJXcr75voJCA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox