]> granicus.if.org Git - postgresql/commit
Fix FK checks of TRUNCATE involving partitioned tables
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 12 Jul 2018 16:09:08 +0000 (12:09 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Thu, 12 Jul 2018 16:09:08 +0000 (12:09 -0400)
commitcd073d8f7043d047c024f0f213c0e9c31b9c0505
tree9128f8933f12f17274bae74fea6999bcf75a1124
parent11a3aeeb5e174a3681f674e7e5ec9bbbc6430394
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
src/backend/catalog/heap.c
src/backend/commands/tablecmds.c
src/test/regress/expected/truncate.out
src/test/regress/sql/truncate.sql