Re: Need help : Weird referencial Integrity triggers

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Vilson farias <vilson(dot)farias(at)digitro(dot)com(dot)br>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need help : Weird referencial Integrity triggers
Date: 2000-10-07 11:44:20
Message-ID: 200010071144.GAA14039@jupiter.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vilson farias wrote:
> I've been changing some tables and I saw a strange behavior in pg_trigger.
> Check out the commented code below :
>
> [...]
>
> Now, if I select the corresponding triggers from pg_trigger, I'll find
> three. Why 3? One for update, one for insert and one for delete ?

One for INSERT/UPDATE of the foreign key table, one for
DELETE and one for UPDATE of the primary key table.

You haven't specified a referential action for the UPDATE
case of the primary key (ON UPDATE ...). The default action
is NO ACTION, what means that changing the primary keys value
isn't allowed as long as there are references to it from any
foreign key. Thus, updating a PK can never be ignored and
there must be a trigger.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Collin Peters 2000-10-07 15:51:42 Postmaster startup problems
Previous Message Jan Wieck 2000-10-07 11:35:58 Re: How does TOAST compare to other databases' mechanisms?