| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br> |
| Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Add CREATE SCHEMA ... LIKE support |
| Date: | 2026-02-10 11:41:07 |
| Message-ID: | 1a298a0b-7181-4baf-b4e4-83cba1157f65@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 10/02/2026 11:09, Jim Jones wrote:
> In a scenario where a parent table and the partitioned tables live in
> different schemas, creating a schema based on the schema that contains
> only the partitions arguably generates useless tables.
> The same applies for creating schema that contains only the parent table
> Even if parent and children live in the same schema, they become
> detached in the new copy -- I'd argue that this one is a bug.
> Comments are also being ignored, but I guess it was already mentioned
> upthread:
I also just noticed that UNLOGGED tables are cloned as normal tables:
postgres=# CREATE SCHEMA s1;
CREATE UNLOGGED TABLE s1.t(c int);
CREATE SCHEMA s2 LIKE s1 INCLUDING ALL;
CREATE SCHEMA
CREATE TABLE
CREATE SCHEMA
postgres=# \d s1.t
Unlogged table "s1.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
postgres=# \d s2.t
Table "s2.t"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------
c | integer | | |
Adding this to collectSchemaTablesLike in schemacmds.c could do the trick:
newRelation->relpersistence = classForm->relpersistence;
Best, Jim
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Marcos Pegoraro | 2026-02-10 11:52:20 | Re: Add CREATE SCHEMA ... LIKE support |
| Previous Message | Pavel Stehule | 2026-02-10 10:34:31 | Re: jsonb subscripting vs SQL/JSON array accessor semantics (SQL:2023) |