Thread: unique/references not honored when inheriting tables

unique/references not honored when inheriting tables

From
pgsql-bugs@postgresql.org
Date:
Helge Bahmann (bahmann@math.tu-freiberg.de) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
unique/references not honored when inheriting tables

Long Description
If a table inherits fields carrying the "references" or "unique" constraint, they are not honoured but silently
dropped.It is necessary to manually create the triggers/indices. 

It would be nice if it were possible to create an index across a table and all sub-tables.


Sample Code
CREATE TABLE foo(id int unique)
CREATE TABLE bar() INHERITS (foo)
INSERT INTO bar VALUES(1)
INSERT INTO bar VALUES(1)


No file was uploaded with this report

Re: unique/references not honored when inheriting tables

From
Bruce Momjian
Date:
Is this still true in 7.1?


> Helge Bahmann (bahmann@math.tu-freiberg.de) reports a bug with a severity of 4
> The lower the number the more severe it is.
> 
> Short Description
> unique/references not honored when inheriting tables
> 
> Long Description
> If a table inherits fields carrying the "references" or "unique" constraint, they are not honoured but silently
dropped.It is necessary to manually create the triggers/indices.
 
> 
> It would be nice if it were possible to create an index across a table and all sub-tables.
> 
> 
> Sample Code
> CREATE TABLE foo(id int unique)
> CREATE TABLE bar() INHERITS (foo)
> INSERT INTO bar VALUES(1)
> INSERT INTO bar VALUES(1)
> 
> 
> No file was uploaded with this report
> 
> 


--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: unique/references not honored when inheriting tables

From
Stephan Szabo
Date:
AFAIK, yes.  Inheriting unique constraints would be a 
special case of inheriting indexes theoretically, since I'd
assume that inheriting a unique column should mean unique
through entire inheritance tree.  References is similar, 
we'd need to do something to inherit the triggers, and
referencing to an inheritance tree needs the unique 
constraint on that entire tree.

I'm not sure what it would take to do a trigger over an
inheritance tree. I guess the other option is to create
appropriate triggers when you inherit and having alter
table add/drop constraint do the same thing).

On Mon, 16 Oct 2000, Bruce Momjian wrote:

> Is this still true in 7.1?
> 
> 
> > Helge Bahmann (bahmann@math.tu-freiberg.de) reports a bug with a severity of 4
> > The lower the number the more severe it is.
> > 
> > Short Description
> > unique/references not honored when inheriting tables
> > 
> > Long Description
> > If a table inherits fields carrying the "references" or "unique" constraint, they are not honoured but silently
dropped.It is necessary to manually create the triggers/indices.
 
> > 
> > It would be nice if it were possible to create an index across a table and all sub-tables.
> > 
> > 
> > Sample Code
> > CREATE TABLE foo(id int unique)
> > CREATE TABLE bar() INHERITS (foo)
> > INSERT INTO bar VALUES(1)
> > INSERT INTO bar VALUES(1)
> > 
> > 
> > No file was uploaded with this report
> > 
> > 
> 
> 
> -- 
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
>