From: | Fabrízio de Royes Mello <fabrizio(at)timbira(dot)com(dot)br> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, PegoraroF10 <marcos(at)f10(dot)com(dot)br>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Problem with trigger makes Detail record be invalid |
Date: | 2018-04-19 19:03:11 |
Message-ID: | CAPfkCSCSU28WEjLEH99hdVr+TwScTxN7NAMFVycmjsy49jXAmg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2018-04-19 15:57 GMT-03:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>
> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> > On 04/19/2018 10:55 AM, PegoraroF10 wrote:
> >> Is this a bug or it´s mine responsability to check that trigger result
?
>
> > Without seeing exactly what the trigger function on Detail is doing that
> > is not answerable.
>
> I think the OP is complaining because his misimplemented trigger can break
> the consistency of the foreign key constraint. That is not a bug, it's
> an intentional design decision: triggers are lower-level than foreign key
> enforcement queries, and fire during such queries. It's easy to construct
> examples where people would be very unhappy if this were not so, because
> then FK-driven updates would not be seen by the table's triggers. It does
> mean that you have to be careful when writing a trigger.
>
Yeap... it's already mentioned in stackoverflow in ptbr sometime ago [1]
with a reproducible test case.
> (I'm not sure that this issue is adequately documented, though.
> I'd have expected to find something about it in triggers.sgml and/or
> create_trigger.sgml, but in a quick look neither of them mentions foreign
> keys.)
>
We don't have it properly documented... at the time I answered this
question on pt-br stackoverflow I noticed the lack o documentation and
unfortunately I completely forgot to propose a small patch for it.
Regards,
[1]
https://pt.stackoverflow.com/questions/256115/postgresql-foreign-keys-falhando/256398#256398
--
Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2018-04-19 19:11:54 | Re: Problem with trigger makes Detail record be invalid |
Previous Message | Adrian Klaver | 2018-04-19 18:58:24 | Re: Problem with trigger makes Detail record be invalid |