Re: create table like including storage parameter

Поиск
Список
Период
Сортировка
От jian he
Тема Re: create table like including storage parameter
Дата
Msg-id CACJufxG3N8mNXjtP_VDR1V54kfinU3jrEvCjpUO-n056hnOqVA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: create table like including storage parameter  ("Euler Taveira" <euler@eulerto.com>)
Список pgsql-hackers
On Tue, Dec 16, 2025 at 1:52 AM Euler Taveira <euler@eulerto.com> wrote:
>
> I started reviewing this patch. Why don't you reuse untransformRelOptions()?
> Even if this function is used by various extensions [1][2], that's not an
> excuse to duplicate code.

yech, duplicate code is not good. I encountered the same issue in the CAST
DEFAULT patch.  I guess I was posting it in the "post early post often" spirit
for the rebase.

> This v6 is your v5 plus my suggestions.
>

your suggestions are great.
I have incorporated all the changes you proposed.

in 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)));

except RELKIND_RELATION, RELKIND_MATVIEW can also specify storage parameters, I
added a test for it too.

to test CREATE FOREIGN LIKE will silently ignore INCLUDING PARAMETERS, i also
slightly modified create_table_like.sql.

The last SELECT query output is too wide, to make it more readable, I
have to use \gx.

Below is the commit message I have drafted:
----------------------------------
Add INCLUDING PARAMETERS to CREATE TABLE LIKE

Introduce the PARAMETERS option to copy parameters when using CREATE TABLE LIKE.
Currently, this primarily applies to the storage parameters, but in the future,
it may encompass other kind parameters in the table.

Since storage parameters are not in the standard, INCLUDING PARAMETERS does not
comply with the standard.  Also because foreign tables cannot specify storage
parameters, CREATE FOREIGN TABLE LIKE will silently ignore INCLUDING PARAMETERS.

This makes creating a new table via CREATE TABLE LIKE more convenient, as the
user would otherwise have to manually specify every storage parameter. It is a
further step toward making a new table created with CREATE TABLE LIKE more
identical to the original table.

Author: jian he <jian.universality@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>

(delete this line later) commitfest:
https://commitfest.postgresql.org/patch/6088
discussion: https://postgr.es/m/CACJufxHr=nKEsS66M7rTHgB+mXdQ948=_eJ1jztAc7PT-eJefA@mail.gmail.com
----------------------------------

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

Вложения

В списке pgsql-hackers по дате отправления: