Re: WIP fix proposal for bug #6123

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Florian Pflug" <fgp(at)phlo(dot)org>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP fix proposal for bug #6123
Date: 2011-08-09 14:53:37
Message-ID: 4E4103A1020000250003FCC3@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Florian Pflug <fgp(at)phlo(dot)org> wrote:

> Another option would be to re-issue the DELETE from the BEFORE
> DELETE trigger, and then return NULL. It'll cause the BEFORE
> DELETE trigger to be invoked recursively, but presumably the
> second invocation could easily detect that all required pre-delete
> actions have already taken place and exit early (and return OLD).
> In pseudo-code, something like
>
> BEFORE DELETE ON <parent table>:
> DELETE FROM <child table> WHERE parent_id = OLD.id;
> IF FOUND THEN
> -- Removing children might have modified our row,
> -- so returning non-NULL is not an option
> DELETE FROM <table> WHERE id = OLD.id;
> RETURN NULL;
> ELSE
> -- No children removed, so our row should be unmodified
> RETURN OLD;
> END IF;

Yeah, that would cover it all right. That pretty much eliminates my
objections to your "check for error after firing each BEFORE
trigger" approach.

-Kevin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-08-09 15:04:31 Re: Compiler warnings with stringRelOpts (was WIP: Fast GiST index build)
Previous Message Florian Pflug 2011-08-09 14:34:00 Re: WIP fix proposal for bug #6123