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

Reply via email to