From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Rozboril, Robert <robert.rozboril@dxc.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed
Date: Thu, 20 Jun 2019 14:00:56 -0400
Message-ID: <20190620180056.GA25386@alvherre.pgsql> (raw)
In-Reply-To: <SN6PR01MB4559916F4541CFD2D42E7E43E5E40@SN6PR01MB4559.prod.exchangelabs.com>
On 2019-Jun-20, Rozboril, Robert wrote:
> ALTER TABLE polf ADD CONSTRAINT polf_po_id_fk FOREIGN KEY (po_id) REFERENCES pof(po_id) ON DELETE CASCADE;
> ALTER TABLE polt ADD CONSTRAINT polt_po_id_fk FOREIGN KEY (po_id) REFERENCES pot(po_id) ON DELETE CASCADE;
Hmm, yeah, I wouldn't expect this to work well -- the UPDATEs done by
the cascade action would not see that there is another partition. If
you were declaring the PK and FK constraints on the parent tablej, it
should work correctly:
ALTER TABLE pol ADD CONSTRAINT pol_pkey PRIMARY KEY (pol_id);
ALTER TABLE pol ADD CONSTRAINT pol_po_id_fk FOREIGN KEY (po_id) REFERENCES po(po_id) ON DELETE CASCADE;
(similarly for the "po" table).
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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-bugs@postgresql.org
Cc: alvherre@2ndquadrant.com, robert.rozboril@dxc.com
Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed
In-Reply-To: <20190620180056.GA25386@alvherre.pgsql>
References: <SN6PR01MB4559916F4541CFD2D42E7E43E5E40@SN6PR01MB4559.prod.exchangelabs.com> <20190620180056.GA25386@alvherre.pgsql>
* 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