Re: Need information about Foreign Key created Triggers

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jean-Francois Leveque <leveque(at)webmails(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Need information about Foreign Key created Triggers
Date: 2001-06-08 15:09:40
Message-ID: Pine.BSF.4.21.0106080803450.25514-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 8 Jun 2001, Jean-Francois Leveque wrote:

>
> I created a Foreign Key (REFERENCES) constraint on
> a table like this (some columns ommited) :
> CREATE TABLE tablename (
> id_tablename INTEGER DEFAULT nextval('id_tablename_seq'),
> tablename_parent INTEGER CONSTRAINT tablename_parent_fk
> REFERENCES tablename (id_tablename),
> CONSTRAINT tablename_pk PRIMARY KEY (id_tablename)
> );
>
> When I pg_dump, I can see three triggers :
> The first calls RI_FKey_check_ins AFTER INSERT OR UPDATE,
> the second one calls RI_FKey_noaction_del AFTER DELETE,
> the third one calls RI_FKey_noaction_upd AFTER UPDATE.
>
> All the triggers and procedure calls have the same parameters.
>
>
> I browsed the docs, looked at :
> http://techdocs.postgresql.org/techdocs/hackingreferentialintegrity.php
>
> and asked pgsql-docs but I couldn't find what they
> really do. Can someone give me information about
> those Triggers created for FKey RI ?

It's in the archives somewhere, but...

The functions take the same args, but the name of the functions says
what it's going to do and the table that the trigger and the action
(AFTER ?) tells you when it does it.

RI_FKey_check_ins checks a newly inserted or updated row in the FK
table against the PK table rows.
RI_FKey_<something>_del does the referential action <something>,
in your case no action, when a row is deleted from the PK table.
RI_FKey_<something>_upd does the referential action <something>,
in your case no action, when a row is updated in the PK table.

IIRC, The arguments are
name of constraint, fk table, pk table, match type,
fk col 1, pk col1, ... fk col n, pk col n

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2001-06-08 15:10:18 Re: AW: Re: [SQL] behavior of ' = NULL' vs. MySQL vs. Stand ards
Previous Message Tom Lane 2001-06-08 15:04:26 Re: [HACKERS] Re: behavior of ' = NULL' vs. MySQL vs. Standards