Re: [PATCH] session_replication_role = replica with TRUNCATE - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: [PATCH] session_replication_role = replica with TRUNCATE
Date
Msg-id 2e689636-51cd-aa19-c7a2-435051fbc9cd@2ndquadrant.com
Whole thread Raw
In response to [PATCH] session_replication_role = replica with TRUNCATE  (Marco Nenciarini <marco.nenciarini@2ndquadrant.it>)
Responses 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>)
List pgsql-hackers
Hi,

On 29/12/17 13:01, Marco Nenciarini wrote:
> Hi,
> 
> 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.
> 

Yes please, I never understood why 'DELETE FROM foo;' works fine with
'session_replication_role = replica' and FKs while 'TRUNCATE foo;' would
throw error.

> I'm attaching a simple patch to make TRUNCATE match behavior of DELETE
> for session_replication_role = replica.
> 

May be worth documenting that the session_replication_role also affects
TRUNCATE's interaction with FKs in config.sgml.

-- 
  Petr Jelinek                  http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Basebackups reported as idle
Next
From: Simon Riggs
Date:
Subject: Re: Add hint about replication slots when nearing wraparound