Re: Multiple Inheritance - Mailing list pgsql-general

From Tom Lane
Subject Re: Multiple Inheritance
Date
Msg-id 2681.974218714@sss.pgh.pa.us
Whole thread Raw
In response to Multiple Inheritance  (Wouter Tijhuis <tijhuis@cs.utwente.nl>)
List pgsql-general
Wouter Tijhuis <tijhuis@cs.utwente.nl> writes:
> As you can see from the output this will generate a sequence error in test2.

Well, since you have columns named "id" in *both* parent tables, it's
not possible for the child to inherit both.  The implementation is to
ignore test2's id and inherit only test1's.  Thus, you get an id
sequence that is unique across test1 and test, but has nothing to do
with test2's id sequence.

If you want distinct ids for both test1 and test2, name the columns
differently so that the child table can inherit both.

Or, if you think that you want a globally unique id, make a common
ancestor table that both test1 and test2 inherit id from.

Or build the serial-number behavior from spare parts --- there's nothing
magic about it, it's just "DEFAULT nextval('some-sequence')" --- so you
can have direct control of which sequence generator gets used for each
table.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Implementation of the frontend protocol
Next
From: Tom Lane
Date:
Subject: Re: Encoding