| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Euler Taveira <euler(at)eulerto(dot)com> |
| Cc: | Nathan Bossart <nathandbossart(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: create table like including storage parameter |
| Date: | 2026-03-23 04:44:40 |
| Message-ID: | CACJufxHBWd4vRjS7cE8SRQfNeb5mZq9KTDMPKQ9O5DJjh-+umQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
transformTableLikeClause, we have:
```
if (relation->rd_rel->relkind != RELKIND_RELATION &&
relation->rd_rel->relkind != RELKIND_VIEW &&
relation->rd_rel->relkind != RELKIND_MATVIEW &&
relation->rd_rel->relkind != RELKIND_COMPOSITE_TYPE &&
relation->rd_rel->relkind != RELKIND_FOREIGN_TABLE &&
relation->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is invalid in LIKE clause",
RelationGetRelationName(relation)),
errdetail_relkind_not_supported(relation->rd_rel->relkind)));
```
RELKIND_COMPOSITE_TYPE, RELKIND_FOREIGN_TABLE,
RELKIND_PARTITIONED_TABLE cann't/don't have storage parameters.
https://www.postgresql.org/docs/current/sql-creatematerializedview.html says
"All parameters supported for CREATE TABLE are also supported for
CREATE MATERIALIZED VIEW"
However for RELKIND_VIEW:
CREATE TABLE t_sp (a text) WITH (toast_tuple_target = 128);
CREATE VIEW v1 with (check_option=local) as select a from t_sp;
CREATE TABLE t_sp1 (LIKE v1 INCLUDING PARAMETERS);
ERROR: unrecognized parameter "check_option"
INCLUDING PARAMETERS: basically copy source pg_class.reloptions and
use it for the target table.
RELKIND_VIEW pg_class.reloptions is different from RELKIND_RELATION,
Therefore INCLUDING PARAMETERS should not be applied when the source
relation is RELKIND_VIEW.
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-Add-INCLUDING-PARAMETERS-to-CREATE-TABLE-LIKE.patch | text/x-patch | 19.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | lakshmi | 2026-03-23 04:45:59 | Re: Avoid multiple calls to memcpy (src/backend/access/index/genam.c) |
| Previous Message | surya poondla | 2026-03-23 04:21:02 | Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication |