Skip site navigation (1) Skip section navigation (2)

Re: Re(2): REFERENCES fails on derived classes

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Michael Caine <mcaine(at)artlogic(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Re(2): REFERENCES fails on derived classes
Date: 2001-06-11 14:54:06
Message-ID: Pine.BSF.4.21.0106110749570.47763-100000@megazone23.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, 11 Jun 2001, Michael Caine wrote:

> a month i was told that my possible bug submission was "sort of" a bug. 
> the report and reply are below.
> 
> now i write a follow up because i don't know how to establish a workroom. 
> specifically, i know know that a unique constraint must be added to an
> inherited "id" field, even if it's a primary key in the base table.  i can
> do this by 'CREATE INDEX', but this creates a completely new constraint. 
> i want to share the unique 'serial' behavior between the base table and
> derived table, so that en entry in either table is unique between the
> tables.  that way, when i do a 'SELECT baseTable*' kind of command, i can
> differentiate between two records.  is there a way to do this, or could
> this be considered a valid bug of some sort?

Unfortunately there's no way within the current constraints to do that
kind of unique constraint, although you should get actually unique numbers
out of the serial -- and those will span the two tables since it uses the 
same sequence, you can't guarantee that explicitly placed values will be
unique. This is probably a bug, but inheritance needs alot of work in
general.

You might be able fake it with a insert/update trigger in plpgsql
that makes sure that there are no matching rows.  It wouldn't exactly
be the same thing as a unique constraint, but it'd probably be close
enough for most use.



In response to

Responses

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2001-06-11 14:58:51
Subject: Re: Information regarding foriegn key constraint.
Previous:From: Peter EisentrautDate: 2001-06-11 14:52:09
Subject: Re: where clause bug

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group