| 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: | 2025-12-16 02:45:04 |
| Message-ID: | CACJufxG3N8mNXjtP_VDR1V54kfinU3jrEvCjpUO-n056hnOqVA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Dec 16, 2025 at 1:52 AM Euler Taveira <euler(at)eulerto(dot)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(dot)universality(at)gmail(dot)com>
Reviewed-by: Euler Taveira <euler(at)eulerto(dot)com>
Reviewed-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)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
----------------------------------
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Add-INCLUDING-PARAMETERS-to-CREATE-TABLE-LIKE.patch | text/x-patch | 18.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mihail Nikalayeu | 2025-12-16 02:48:00 | Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY |
| Previous Message | cca5507 | 2025-12-16 02:33:15 | Re: [PATCH] Add pg_lfind8_nonzero() |