pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rozboril, Robert <robert.rozboril@dxc.com>
To: Alvaro Herrera <alvherre@2ndquadrant.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: Fri, 21 Jun 2019 14:59:35 +0000
Message-ID: <SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com> (raw)
In-Reply-To: <20190621132823.GA8023@alvherre.pgsql>
References: <SN6PR01MB4559C457FF745D12CF79CCEBE5E70@SN6PR01MB4559.prod.exchangelabs.com>
	<20190621132823.GA8023@alvherre.pgsql>

Hi Álvaro,

Thank you for your answer. Good luck!

Meanwhile I did workaround using before update trigger to handle data in child tables and setting constraints as deferred to don't lose data. I am testing it right now.

Regards,
   Robert


-----Original Message-----
From: Alvaro Herrera [mailto:alvherre@2ndquadrant.com]
Sent: Friday, June 21, 2019 15:28
To: Rozboril, Robert <robert.rozboril@dxc.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed

Hi Robert,

AFAIU the problem is that when the pof tuple migrates to pot, the partition-level FK constraint on polf sees the update as a delete (because at that level that's what it is) and thus cascades to delete the tuple on polf.  There is nothing that automagically instantiates a new tuple in polt.

To fix this problem, we would need a mechanism to insert an equivalent referencing tuple in the other partition.  I'm not sure how would we achieve such a thing.

--
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


DXC Technology Company -- This message is transmitted to you by or on behalf of DXC Technology Company or one of its affiliates.  It is intended exclusively for the addressee.  The substance of this message, along with any attachments, may contain proprietary, confidential or privileged information or information that is otherwise legally exempt from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate any part of this message. If you have received this message in error, please destroy and delete all copies and notify the sender by return e-mail. Regardless of content, this e-mail shall not operate to bind DXC Technology Company or any of its affiliates to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. --.





view thread (5+ messages)

Message-ID: <SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com>
Permalink:  ../SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com/
Also on:    postgresql.org/message-id/SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com

 · 

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-bugs@postgresql.org
  Cc: robert.rozboril@dxc.com, alvherre@2ndquadrant.com
  Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed
  In-Reply-To: <SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com>
  References: <SN6PR01MB4559C457FF745D12CF79CCEBE5E70@SN6PR01MB4559.prod.exchangelabs.com> <20190621132823.GA8023@alvherre.pgsql> <SN6PR01MB455963A4E9DA9C2BACE3C52BE5E70@SN6PR01MB4559.prod.exchangelabs.com>

* 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