Re: Inheritance and column references problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Scott Goodwin <scott(at)scottg(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Inheritance and column references problem
Date: 2004-02-25 00:38:28
Message-ID: 20040224162831.X8710@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Is this a bug, or a feature? It seems I can't make a column reference
> work directly with the table that gets inherited by the others. Neither
> can I make a column reference work with a table that *inherits* the
> toinherit table. If I can't get this to work, I'll have to revert back
> to not using inheritance at all.

All of primary key, unique and foreign key constraints don't currently
meaningfully inherit. For the foreign key case the reference goes only
to the directly named table so rows in the subtables are not considered
for purposes of validating the constraint. In addition, in a structure
where you have a primary key inherited, the child tables do not get the
constraint for uniqueness although that can be added by explicitly putting
the constraint on, however that won't prevent duplicates between the child
and parent nor between children. There are some marginally complicated
workarounds using a separate table that have been discussed on the lists
before and should be available in the archives.

I think I should build a macro for the above. ;)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-02-25 00:38:31 Re: select statement against pg_stats returns inconsistent
Previous Message Greg Sabino Mullane 2004-02-25 00:23:35 Re: DBD::Pg 1.32 ready for testing