Re: Add CREATE SCHEMA ... LIKE support

From: "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add CREATE SCHEMA ... LIKE support
Date: 2026-02-12 21:08:57
Message-ID: DGDAHDLH1N0G.184T5QPQXWN8S@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu Feb 12, 2026 at 5:38 PM -03, Álvaro Herrera wrote:
>> I was reading the TODO wiki page and found the "Add CREATE SCHEMA ...
>> LIKE that copies a schema" item and I thought that it could be a good
>> idea to have this at core.
>
> Egad. A TODO thing from way back which probably doesn't make much sense
> nowadays, or at least so I think.
>
> This whole thing seems like a giant can of worms, and I'm not sure it's
> a good idea to add DDL syntax for it. I didn't read the thread in
> detail, but the discussions downthread about adding weird clauses to
> CREATE SCHEMA look quite worrisome.
>
> Why not try to devise a way to reuse the DDL functions being proposed in
> various nearby pgsql-hackers threads? There are a bunch of such patches
> in the commitfest already; it's probably easy to have a way to generate
> a list of objects in a schema, then call the DDL function corresponding
> to each object type for each object, and then you're done.

IIUC you'are suggesting to have something like pg_get_schema_ddl() which
would return the CREATE SCHEMA command and the DDL command used to
create the objects within the schema?

If that's the point it's sounds a better way to implement this. At some
point when I was writing the last version I thought that if we have
these patches already merged this LIKE clause could be implemented
easier but I was thinking to reuse with the LIKE clause, but creating a
function to get a schema definition seems more reasonable and follow the
same pattern for these other patches.

Thanks for the comments.

--
Matheus Alcantara
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-02-12 21:21:54 Re: [PATCH] Support reading large objects with pg_read_all_data
Previous Message KAZAR Ayoub 2026-02-12 21:07:52 Speed up COPY TO text/CSV parsing using SIMD