From: James Gregory <james@anchor.net.au>
To: Reece Hart <rkh@gene.COM>
Cc: pgsql-general@postgresql.org
Subject: Re: table inheritance and foreign keys
Date: 15 May 2003 16:43:04 +1000
Message-ID: <1052980983.5672.7.camel@pirate.bridge.anchor.net.au> (raw)
In-Reply-To: <1052957276.5829.53.camel@tallac>
References: <1052957276.5829.53.camel@tallac>
On Thu, 2003-05-15 at 10:07, Reece Hart wrote:
> I'd appreciate some advice regarding the use of foreign keys in
> inherited tables. Specifically, here's the schema I'd like:
Ok, you can't do it with native postgres RI stuff. I'm told that
the subject has been debated extensively, but right now it can't
be done.
I had to do the same thing as you and the way I've gone about it
is to write triggers in plpython that raise an exception if RI
is not maintained. I have a table that lists all the "x
references y" pairs, and it just reads that and does the query
to see if it can find a row in the "y" table with the right ID.
It was working quite well (within my limited testing) until I hit
a but in plpython last night. Said bug is on my todo list to take
a look at, but that won't be happening imediately.
You'll find you can't write this stuff easily in plpgsql, and I
don't recommend plpython right now because I don't trust it at
this point.
You might have some luck writing similar triggers in C. I'm
happy to send you my python triggers if you'd like something to
start from, but be warned: they're a bit of a mess.
HTH
James.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: james@anchor.net.au, rkh@gene.COM
Subject: Re: table inheritance and foreign keys
In-Reply-To: <1052980983.5672.7.camel@pirate.bridge.anchor.net.au>
References: <1052957276.5829.53.camel@tallac> <1052980983.5672.7.camel@pirate.bridge.anchor.net.au>
* 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