Table inheritance surprise

Lists: pgsql-hackers
From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Table inheritance surprise
Date: 2008-05-07 21:52:08
Message-ID: 20080507215208.GF15867@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Folks,

When I do CREATE TABLE foo(LIKE bar INCLUDING CONSTRAINTS), it doesn't
include foreign key constraints (8.3.1). I believe this is surprising
behavior, but maybe not a bug, so I'd like to propose another bit of
syntactic sugar, namely

LIKE [INCLUDING FOREIGN KEYS]

which would do what it looks like it does.

What say?

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


From: Decibel! <decibel(at)decibel(dot)org>
To: David Fetter <david(at)fetter(dot)org>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Table inheritance surprise
Date: 2008-05-09 13:55:34
Message-ID: 8CE09ABF-3462-4EA5-A7E2-ABD06BB24FC9@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 7, 2008, at 4:52 PM, David Fetter wrote:
> When I do CREATE TABLE foo(LIKE bar INCLUDING CONSTRAINTS), it doesn't
> include foreign key constraints (8.3.1). I believe this is surprising
> behavior, but maybe not a bug, so I'd like to propose another bit of
> syntactic sugar, namely
>
> LIKE [INCLUDING FOREIGN KEYS]
>
> which would do what it looks like it does.

It's surprising to me that INCLUDING CONSTRAINTS doesn't include FK
constraints... is there a reason not to? Perhaps we should just
change INCLUDING CONSTRAINTS to do that...
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: David Fetter <david(at)fetter(dot)org>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Table inheritance surprise
Date: 2008-06-26 22:53:05
Message-ID: 200806262253.m5QMr5O18993@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

David Fetter wrote:
> Folks,
>
> When I do CREATE TABLE foo(LIKE bar INCLUDING CONSTRAINTS), it doesn't
> include foreign key constraints (8.3.1). I believe this is surprising
> behavior, but maybe not a bug, so I'd like to propose another bit of
> syntactic sugar, namely
>
> LIKE [INCLUDING FOREIGN KEYS]
>
> which would do what it looks like it does.
>
> What say?

TODO has:

o Allow inherited tables to inherit indexes, UNIQUE constraints,
and primary/foreign keys

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

+ If your life is a hard drive, Christ can be your backup. +


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: David Fetter <david(at)fetter(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Table inheritance surprise
Date: 2008-06-27 12:11:56
Message-ID: 1214568716.3845.360.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Thu, 2008-06-26 at 18:53 -0400, Bruce Momjian wrote:
> David Fetter wrote:
> > Folks,
> >
> > When I do CREATE TABLE foo(LIKE bar INCLUDING CONSTRAINTS), it doesn't
> > include foreign key constraints (8.3.1). I believe this is surprising
> > behavior, but maybe not a bug, so I'd like to propose another bit of
> > syntactic sugar, namely
> >
> > LIKE [INCLUDING FOREIGN KEYS]
> >
> > which would do what it looks like it does.
> >
> > What say?
>
> TODO has:
>
> o Allow inherited tables to inherit indexes, UNIQUE constraints,
> and primary/foreign keys

INCLUDING CONSTRAINTS is non-standard so maybe we can just make
INCLUDING CONSTRAINTS also include foreign keys.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, David Fetter <david(at)fetter(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Table inheritance surprise
Date: 2008-06-27 22:08:06
Message-ID: 12289.1214604486@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> On Thu, 2008-06-26 at 18:53 -0400, Bruce Momjian wrote:
>> TODO has:
>>
>> o Allow inherited tables to inherit indexes, UNIQUE constraints,
>> and primary/foreign keys

But that TODO item is about inheritance, which has approximately
zip to do with CREATE TABLE LIKE.

> INCLUDING CONSTRAINTS is non-standard so maybe we can just make
> INCLUDING CONSTRAINTS also include foreign keys.

In a green field that would probably make sense, but it'd create
a significant backward compatibility problem to do it now.
Undoubtedly there are apps depending on the current behavior of
LIKE INCLUDING CONSTRAINTS. (If there are not, then the feature is
useless and we should take it out instead of extending it.)

regards, tom lane