Re: create table like including storage parameter - Mailing list pgsql-hackers

From jian he
Subject Re: create table like including storage parameter
Date
Msg-id CACJufxHBWd4vRjS7cE8SRQfNeb5mZq9KTDMPKQ9O5DJjh-+umQ@mail.gmail.com
Whole thread
In response to Re: create table like including storage parameter  ("Euler Taveira" <euler@eulerto.com>)
Responses Re: create table like including storage parameter
List 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.


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

Attachment

pgsql-hackers by date:

Previous
From: surya poondla
Date:
Subject: Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication
Next
From: lakshmi
Date:
Subject: Re: Avoid multiple calls to memcpy (src/backend/access/index/genam.c)