Re: Copy storage parameters on CREATE TABLE LIKE/INHERITS - Mailing list pgsql-hackers

From ITAGAKI Takahiro
Subject Re: Copy storage parameters on CREATE TABLE LIKE/INHERITS
Date
Msg-id 20080801111303.7764.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: Copy storage parameters on CREATE TABLE LIKE/INHERITS  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> There are a couple of other things that need to be thought about:
> * LIKE is intended to copy a table as a *portion* of another table;

You're absolutely right. I just thought it's a *better default* behavior
because LIKE and INHERITS are often used in single inheritance, but
in definition they declare columns, not whole tables.
In other words, we don't have an ability of copying tables as units...

However, I think we'd better to have an ability to copy reloptions easily.
There were requests about adding a configuration parameter to modify 
default fillfactor. I think reloption-cloning would be a solution about it.

How about adding a new WITH-LIKE syntax?
CREATE TABLE newtbl ( ... ) WITH (LIKE "template-table")

It is expanded to an option array as below:
SELECT 'WITH (' || array_to_string(         array_append(reloptions, 'OIDS=' || relhasoids), ',') || ')'  FROM pg_class
WHEREoid = "template-table";
 


> I think therefore that having LIKE copy anything "global" to a table,
> such as tablespace or reloptions, is fundamentally wrongheaded.  What
> will you do about conflicts?  The same is true for inheritance cases,
> since a table can inherit from multiple parents.

Currently I uses the first setting found in multiple tables
and directly specified options have the highest priority.
For example, setting are used in order of [A] -> [B] -> [C].
Conflicted parameters are ignored silently for now.
 CREATE TABLE newtbl (LIKE [B], LIKE [C]) WITH ([A])

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Fixing the representation of ORDER BY/GROUP BY/DISTINCT
Next
From: Robert Lor
Date:
Subject: Re: Review: DTrace probes (merged version) ver_03