Re: [PATCH] session_replication_role = replica with TRUNCATE

Поиск
Список
Период
Сортировка
Искать
От
Peter Eisentraut
Тема
Re: [PATCH] session_replication_role = replica with TRUNCATE
Дата
Msg-id
f7f87cb1-1a98-ffbf-4296-8b13bbcfd185@2ndquadrant.com
Ответ на
Список
Дерево обсуждения
[PATCH] session_replication_role = replica with TRUNCATE Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Re: [PATCH] session_replication_role = replica with TRUNCATE Petr Jelinek <petr.jelinek@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Re: [PATCH] session_replication_role = replica with TRUNCATE Petr Jelinek <petr.jelinek@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Craig Ringer <craig@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Re: [PATCH] session_replication_role = replica with TRUNCATE Petr Jelinek <petr.jelinek@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Re: [PATCH] session_replication_role = replica with TRUNCATE Petr Jelinek <petr.jelinek@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Re: [PATCH] session_replication_role = replica with TRUNCATE Petr Jelinek <petr.jelinek@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Craig Ringer <craig@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Tom Lane <tgl@sss.pgh.pa.us>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Simon Riggs <simon@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [PATCH] session_replication_role = replica with TRUNCATE Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
On 12/29/17 07:01, Marco Nenciarini wrote:
> The current behavior of session_replication_role = replica with TRUNCATE
> is not the same of with the other commands.
> It does not check FKs for INSERT/UPDATE/DELETE but it does for TRUNCATE,
> so one cannot execute TRUNCATE on a table when it is possible to DELETE
> from table without WHERE clause.
> 
> I'm attaching a simple patch to make TRUNCATE match behavior of DELETE
> for session_replication_role = replica.

I'm wondering whether this shouldn't be fixed the other way around,
namely have foreign keys always enforced on replicas.

I'm not aware of an explanation why it currently works the way it does,
other than that FKs happen to be implemented by triggers and triggers
happen to work that way.  But I think it's pretty bogus that logical
replication subscriptions can insert data that violates constraints.
It's also weird that you can violate deferred unique constraints but not
immediate ones (I think, not tested).

So I'm proposing the attached alternative patch, which creates
constraint triggers to be TRIGGER_FIRES_ALWAYS by default.

Thoughts?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
В списке pgsql-hackers по дате отправления
От: Atri Sharma
Дата:
От: Stephen Frost
Дата:
FAQ