From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | Marco Nenciarini <marco(dot)nenciarini(at)2ndquadrant(dot)it>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH] session_replication_role = replica with TRUNCATE |
Date: | 2018-01-18 17:14:28 |
Message-ID: | f7f87cb1-1a98-ffbf-4296-8b13bbcfd185@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
0001-Create-constraint-triggers-to-fire-ALWAYS.patch | text/plain | 1.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2018-01-18 17:19:25 | Re: GSoC 2018 Project Ideas & Mentors - Last Call |
Previous Message | Atri Sharma | 2018-01-18 17:12:06 | Re: GSoC 2018 Project Ideas & Mentors - Last Call |