Re: BUG #6226: Broken foreign key stored on database (parent deleted with children still readable, BUG#6225 Update)

From: Daniel Cristian Cruz <danielcristian(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6226: Broken foreign key stored on database (parent deleted with children still readable, BUG#6225 Update)
Date: 2011-10-06 00:33:55
Message-ID: CACffM9GNDyQ8czxTPc5Y7A5cY5EudgUnmz5bfB1vitBtRRkD-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Thanks, Tom. Now I got it.

I didn't tryed to change BEFORE to AFTER, but reminded something I learned
coding triggers a long time ago, and I forgot. This could be a fortune:

"The rough rule of thumb is that BEFORE triggers are good for adjusting
the contents of the row that's about to be stored, while AFTER triggers
are what to use to propagate changes elsewhere."

And the full version (from manual):

"Typically, row-level BEFORE triggers are used for checking or modifying the
data that will be inserted or updated. For example, a BEFORE trigger might
be used to insert the current time into a timestamp column, or to check that
two elements of the row are consistent. Row-level AFTER triggers are most
sensibly used to propagate the updates to other tables, or make consistency
checks against other tables. The reason for this division of labor is that
an AFTER trigger can be certain it is seeing the final value of the row,
while a BEFOREtrigger cannot; there might be other BEFORE triggers firing
after it. If you have no specific reason to make a trigger BEFORE or AFTER,
the BEFORE case is more efficient, since the information about the operation
doesn't have to be saved until end of statement."

I became a rusty DBA poluting pgsql-bugs, sorry. RTFM for myself. :)
--
Daniel Cristian Cruz
クルズ クリスチアン ダニエル

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Stefan Franke 2011-10-06 08:26:51 BUG #6241: JDBC: blob doesnot work with bytea
Previous Message Craig Ringer 2011-10-06 00:05:15 Re: BUG #6233: pg_dump hangs with Access Violation C0000005