From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Paulo Roberto Siqueira <paulo(dot)siqueira(at)usa(dot)net> |
Cc: | PGSQL Novice <pgsql-novice(at)postgresql(dot)org>, PGSQL Admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: Foreign key |
Date: | 2000-10-03 17:16:04 |
Message-ID: | Pine.BSF.4.10.10010031011330.20147-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-novice |
On Tue, 3 Oct 2000, Paulo Roberto Siqueira wrote:
> This list have helped me a lot. That's why I'm here again asking for more
> information.
> I've read all the documentation, but I need more information on how
> postgres implements foreign key on version 7.0.2. I know it uses triggers.
> More information is needed though. I want to know the mechanism, when it
> will change to real foreign key etc.
The mechanics are that a foreign key constraint definition is turned into
three constraint triggers (more on this in a second), one on the foreign
key table, two on the primary key table. The one on the foreign key table
is an after update/insert trigger that checks that the row matches. The
two on the primary key table are after delete and update (respectively)
and either implement a check to make sure the row isn't referenced (no
action/restrict) or implement the referential action (on delete ...
on cascade ...) The checks and actions are all implemented in C using
SPI by building appropriate queries.
Constraint triggers are a little different from normal triggers because
there is some additional stuff to handle the relationship between the
tables and a deferred trigger queue to handle deferrable constraints.
I'm not sure what you mean by real foreign key above, so I'm not sure
how to answer the last bit.
From | Date | Subject | |
---|---|---|---|
Next Message | Vladimir V. Zolotych | 2000-10-04 07:24:22 | postgres C++ functions |
Previous Message | Jeremy Ashcraft | 2000-10-03 17:04:56 | 6.5 bug? |
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Ackerman | 2000-10-04 05:09:40 | RE: installation options... Please help... |
Previous Message | Paulo Roberto Siqueira | 2000-10-03 14:52:41 | Foreign key |