Re: Shouldn't CREATE TABLE LIKE copy the relhasoids property?

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Shouldn't CREATE TABLE LIKE copy the relhasoids property?
Date: 2015-04-28 00:35:49
Message-ID: 20150428003549.GB21038@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 25, 2015 at 11:11:52PM -0400, Tom Lane wrote:
> Hm, good point; INHERITS will silently override such a specification:
>
> regression=# create table base1 (f1 int) with oids;
> CREATE TABLE
> regression=# create table c2 () inherits (base1) without oids;
> CREATE TABLE
> regression=# \d+ c2
> Table "public.c2"
> Column | Type | Modifiers | Storage | Stats target | Description
> --------+---------+-----------+---------+--------------+-------------
> f1 | integer | | plain | |
> Inherits: base1
> Has OIDs: yes
>
> > Though I guess unlike inherits there is no
> > reason to mandate the final result be identical to the base table - though
> > here is something to be said for pointing out the inconsistency and
> > requiring the user to alter table if indeed they want to have the oid-ness
> > changed.
>
> Yeah, LIKE doesn't necessarily have to behave the same as INHERITS;
> but probably we should follow that precedent unless we have a specific
> argument not to. Which I don't.

Agreed. Here is an attached patch for 9.6 which works for multiple
LIKE'ed tables with multiple inheritance and index creation. I figured
out why Tom's OID primary key test was failing so I now process the
columns and LIKE first, then the constraints. There is also no longer a
dependency on default_with_oids.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

Attachment Content-Type Size
like.diff text/x-diff 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2015-04-28 00:55:38 Re: pgsql: Add transforms feature
Previous Message Andrew Dunstan 2015-04-27 23:54:28 Re: pgsql: Add transforms feature