Table inheritance surprise

Поиск
Список
Период
Сортировка
Искать

Table inheritance surprise

От:
David Fetter <david@fetter.org>
Дата:
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  http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

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

Re: Table inheritance surprise

От:
Decibel! <decibel@decibel.org>
Дата:
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@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828


Re: Table inheritance surprise

От:
Bruce Momjian <bruce@momjian.us>
Дата:
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          http://momjian.us EnterpriseDB                             http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +

Re: Table inheritance surprise

От:
Simon Riggs <simon@2ndquadrant.com>
Дата:

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.comPostgreSQL Training, Services and Support


Re: Table inheritance surprise

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Simon Riggs  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

FAQ