pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix FK checks of TRUNCATE involving partitioned tables
Date: Thu, 12 Jul 2018 16:26:17 +0000
Message-ID: <E1fdeQ5-0007F1-1r@gemulon.postgresql.org> (raw)

Fix FK checks of TRUNCATE involving partitioned tables

When truncating a table that is referenced by foreign keys in
partitioned tables, the check to ensure the referencing table are also
truncated spuriously failed.  This is because it was relying on
relhastriggers as a proxy for the table having FKs, and that's wrong for
partitioned tables.  Fix it to consider such tables separately.  There
may be a better way ... but this code is pretty inefficient already.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Michael Paquiër <michael@paquier.xyz>
Discussion: https://postgr.es/m/20180711000624.zmeizicibxeehhsg@alvherre.pgsql

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/727196ced2423008bb25d7775c4e3b7fca063c8b

Modified Files
--------------
src/backend/catalog/heap.c             |  7 +++-
src/backend/commands/tablecmds.c       |  2 +-
src/test/regress/expected/truncate.out | 75 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/truncate.sql      | 47 +++++++++++++++++++++
4 files changed, 128 insertions(+), 3 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1fdeQ5-0007F1-1r@gemulon.postgresql.org>
Permalink:  ../E1fdeQ5-0007F1-1r@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fdeQ5-0007F1-1r@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Fix FK checks of TRUNCATE involving partitioned tables
  In-Reply-To: <E1fdeQ5-0007F1-1r@gemulon.postgresql.org>
  References: <E1fdeQ5-0007F1-1r@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox