From: Allan Engelhardt <allane@cybaea.com>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Subject: Re: Creating foreign key constraint to child table?
Date: Sun, 05 Aug 2001 20:55:48 +0100
Message-ID: <3B6DA4C4.CEC3B8F2@cybaea.com> (raw)
References: <Pine.BSF.4.21.0108051218300.25692-100000@megazone23.bigpanda.com>
Stephan Szabo wrote:
> On Sun, 5 Aug 2001, Allan Engelhardt wrote:
[see new example below]
> Not that this is related to what you asked about precisely (I saw the
> response you made), but the query above also doesn't do what you think
> it does right now. It currently makes a reference to only foo, not
> any subchildren of foo.
Oh, man! You are right, but this sux big time: there should not be an asymmetry between a FOREIGN KEY constraint and the SELECT statement. Now that the default is SQL_INHERITANCE ON, it should be the default for the constraint as well, IMHO.
1. Am I the only one who thinks this is a bug?
2. How would I get the behaviour I expect? Write my own trigger? :-P
--- Allan.
test=# create table foo (id integer primary key);
test=# create table bar () inherits (foo);
test=# create table baz (bar integer,
constraint fk_bar foreign key (bar) references foo(id));
test=# insert into foo values (1);
test=# insert into bar values (2);
test=# insert into baz values (2);
ERROR: fk_bar referential integrity violation - key referenced from baz not found in foo
test=# select * from foo where id = 2;
id
----
2
(1 row)
test=#
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: allane@cybaea.com, sszabo@megazone23.bigpanda.com
Subject: Re: Creating foreign key constraint to child table?
In-Reply-To: <3B6DA4C4.CEC3B8F2@cybaea.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox