Re: create table like including storage parameter

jian he <jian.universality@gmail.com>

From: jian he <jian.universality@gmail.com>
To: Euler Taveira <euler@eulerto.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, "David G. Johnston" <david.g.johnston@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-23T04:44:40Z
Lists: pgsql-hackers

Attachments

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.


--
jian
https://www.enterprisedb.com/