Re: [GENERAL] UPDATE column without FK fires other FK triggers constraint check

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [GENERAL] UPDATE column without FK fires other FK triggers constraint check
Дата
Msg-id 8678.1500489727@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [GENERAL] UPDATE column without FK fires other FK triggers constraint check  (Luca Looz <luca.looz92@gmail.com>)
Ответы Re: [GENERAL] UPDATE column without FK fires other FK triggersconstraint check
Список pgsql-general
Luca Looz <luca.looz92@gmail.com> writes:
> After some tests it seems that this happens when the same row is covered by
> more than 1 update in the same transaction even without any change.
> Is this an expected behavior? Why it happens?

Yes, see comment in RI_FKey_fk_upd_check_required:

             * If the original row was inserted by our own transaction, we
             * must fire the trigger whether or not the keys are equal.  This
             * is because our UPDATE will invalidate the INSERT so that the
             * INSERT RI trigger will not do anything; so we had better do the
             * UPDATE check.  (We could skip this if we knew the INSERT
             * trigger already fired, but there is no easy way to know that.)

Although this is talking about the BEGIN; INSERT; UPDATE; COMMIT case,
the code has no way to tell that apart from BEGIN; UPDATE; UPDATE; COMMIT.

            regards, tom lane


В списке pgsql-general по дате отправления:

Предыдущее
От: Jerry Sievers
Дата:
Сообщение: Re: [GENERAL] Two-phase commit case studies
Следующее
От: vstuart
Дата:
Сообщение: Re: [GENERAL] ~/.psqlrc file is ignored