Re: triggers and inheritance tree

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: triggers and inheritance tree
Date: 2012-03-28 13:29:22
Message-ID: CA+Tgmoa3GxMJbstGNw0wzc61q+LiV8G1KT-x_APcyqpuP7UxGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 28, 2012 at 9:16 AM, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> On Wed, Mar 28, 2012 at 1:21 AM, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
>> Hi,
>>
>> i was trying to create triggers that redirect INSERT/UPDATE/DELETE
>> actions from parent to childs, but found that UPDATE/DELETE doesn't
>> get redirected. Actually, the triggers BEFORE UPDATE and BEFORE DELETE
>> aren't even fired.
>>
>
> and of course, it has nothing to do with the inheritance tree. that
> was just a coincidence.
>
> the problem occurs the same with normal tables, but i can't find where
> is the problem.
> i suspect, though, that is in the comparison in TRIGGER_TYPE_MATCHES

I think the problem is that the UPDATE or DELETE can only fire once a
matching row has been identified, so that OLD can be filled in
appropriately. But in this case, the matching row gets found not in
the parent table, but in one of its child tables. So any triggers on
the child table would fire, but triggers on the parent table will not.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-03-28 13:45:29 Re: 9.2 commitfest closure (was Command Triggers, v16)
Previous Message Jaime Casanova 2012-03-28 13:16:46 Re: triggers and inheritance tree