Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heLFA-00052C-Ml for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2019 15:14:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1heLF9-0006fH-Ac for pgsql-bugs@arkaria.postgresql.org; Fri, 21 Jun 2019 15:14:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heL16-000653-La for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2019 14:59:52 +0000 Received: from mail1.bemta24.messagelabs.com ([67.219.250.5]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1heL0x-0002AF-A0 for pgsql-bugs@lists.postgresql.org; Fri, 21 Jun 2019 14:59:51 +0000 Received: from [67.219.250.97] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-5.bemta.az-a.us-west-2.aws.symcld.net id 84/A1-11494-AD0FC0D5; Fri, 21 Jun 2019 14:59:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHJsWRWlGSWpSXmKPExsUiMuXIWt1bH3h iDXZOU7DY8CzdgdHjaFNhAGMUa2ZeUn5FAmvG+uO/GQtaBSu67k9gbmDs4Oti5ORgEzCSePBp KnsXIxeHkMB9RonZ234xQjhdTBIL7s9ggXCuM0rcerKeBaRFREBX4tnnyYwgNrOAu8SibxfYQ GxhgUKJef9+MUHUFElc79oEZbtJ/Pt0lR3EZhFQlbjy6wLYHF6BSImPJ+5ALWhklJi/YC1Ygl PAWOLT9rtgCxgFxCS+n1rDBLFMHOiI+WC2hICAxJI955khbFGJl4//sULUR0o8nzeHFSKuILH h5mE2CFtW4tL8bkYI21fidt9LJpDFEgK3GCUeHOuBGqQlsWTxN6giKYkTF49CDcqQeH15OZSt LtHycR6ULSPxb9dUZohBM9gkPrydC7SNA+ideIm2JXUQNXISq3ofskDUXGCW2HB8NTPEN3oSN 6ZOYZvAqDULyXOzkKQgbG2JZQtfM88Ch5igxMmZT1gWMLKsYrRIKspMzyjJTczM0TU0MNA1ND TSNTQG0RZ6iVW6iXqlxbrlqcUlukZ6ieXFesWVuck5KXp5qSWbGIHJJaWgqWwH45sjr/UOMUp yMCmJ8vqd54kV4kvKT6nMSCzOiC8qzUktPsQow8GhJMHLB0xXQoJFqempFWmZOcBEB5OW4OBR EuEtfA+U5i0uSMwtzkyHSJ1itOSY8HLuImaOnUfnAcmb75csYhZiycvPS5US5/0O0iAA0pBRm gc3DpaMLzHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5l0GMoUnM68EbusroIOYgA5aMJsL5K CSRISUVANTo+axVeG7V3rVXdsQ8udueMrZ2ZUTrRhfJqsekrxfm/uxUYb3gJdW4a2+2JpbXQn 2+17xPpkdKsvVsHBt3u136xszSxb1eRUv3hzMwXZks9inv9nrLiYkaF1eMLXhavYJ12mWHLeC D1crl3so9HCWX3DmrU97sU/o67LyTvFn5/8mfzwUpaA9cX9Sg5Ho+9JP6qcetk58uGWdbkXMR me3wm9scWuOfNWNu5JyNPqdgE/p5P0i6evK7YL3/zK5EHB6l+vL3R/ShffGH90jXrHhg8epuC UbbGdxHHzkwZD9W1+67Pu2G+lLkl1uClz8/q7+QsHECV9UIu0+VD2U2ad6tcrte6twU3qfwPH JXy8tUWIpzkg01GIuKk4EAFp8XD5BBAAA X-Env-Sender: robert.rozboril@dxc.com X-Msg-Ref: server-22.tower-321.messagelabs.com!1561129177!492396!1 X-Originating-IP: [20.148.196.173] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.43.9; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15302 invoked from network); 21 Jun 2019 14:59:38 -0000 Received: from amer-mta206e.csc.com (HELO Amer-MTA206e.csc.com) (20.148.196.173) by server-22.tower-321.messagelabs.com with RC4-SHA encrypted SMTP; 21 Jun 2019 14:59:38 -0000 From: "Rozboril, Robert" Received: from mail-dm3nam03lp2052.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.52]) by Amer-MTA206i.csc.com with ESMTP/TLS/AES256-GCM-SHA384; 21 Jun 2019 10:59:37 -0400 Received: from SN6PR01MB4559.prod.exchangelabs.com (20.177.249.148) by SN6PR01MB4351.prod.exchangelabs.com (20.177.248.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.15; Fri, 21 Jun 2019 14:59:36 +0000 Received: from SN6PR01MB4559.prod.exchangelabs.com ([fe80::240a:cec2:72e2:ee58]) by SN6PR01MB4559.prod.exchangelabs.com ([fe80::240a:cec2:72e2:ee58%7]) with mapi id 15.20.1987.014; Fri, 21 Jun 2019 14:59:36 +0000 To: Alvaro Herrera 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 Thread-Topic: PostgreSQL v11.3 - Records are deleted from child table if partition key of parent table is changed Thread-Index: AdUnM28VSGd5HxAFSmOhlRKWekgvDgAXqyQAABk1fRAAD5BUgAAC0r+A Date: Fri, 21 Jun 2019 14:59:35 +0000 Message-ID: References: <20190621132823.GA8023@alvherre.pgsql> In-Reply-To: <20190621132823.GA8023@alvherre.pgsql> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.46.52.15] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 47a36246-f1e5-4aee-e29a-08d6f65913af x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:SN6PR01MB4351; x-ms-traffictypediagnostic: SN6PR01MB4351: x-ms-exchange-purlcount: 1 x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0075CB064E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(136003)(396003)(366004)(39860400002)(346002)(199004)(189003)(13464003)(966005)(486006)(55016002)(53936002)(11346002)(6306002)(9686003)(25786009)(305945005)(446003)(6436002)(86362001)(14454004)(33656002)(4326008)(68736007)(316002)(229853002)(7736002)(71190400001)(256004)(5024004)(74316002)(81156014)(26005)(81166006)(476003)(186003)(8936002)(71200400001)(66066001)(6116002)(3846002)(478600001)(52536014)(6916009)(76176011)(8676002)(64756008)(66946007)(66446008)(73956011)(7696005)(99286004)(66476007)(2906002)(66556008)(6506007)(53546011)(76116006)(5660300002)(66574012)(6246003)(102836004)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR01MB4351;H:SN6PR01MB4559.prod.exchangelabs.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: dxc.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 18rRmmLQ2JMLDpc91pASiIR6Laqrp2GHP+VUXBmdS+fT7QXAkxteGeiR0l3nH9ETaTcR3CMjd2y53ZU2cbdRdJ+SyxXwzfOG4f/kk/9CR7lZLnXxWBhjrtn6qiVYxRYHSaH1WSr1ySVWyv+tAs4SSHFoRJgujHHSm+59e7nLfMa0bvHkrDVxrd7rEY2YES6MB9CGrqraYw5AFWshm5S9kjO8r9pC6z4Imv/M1hXXDSWmwnx/SwPo8ESBi/Plrlp7Eps0IjqaLl5kmM265TeLWW8kbwJtfyQARTJl18RkTLC2Ju4qv2IgDdl4x8gHOh1GbBom+L40SI8k+Ojz9Qf79HqPGmy5jzdExXBg6MGllgaEoMT0nE/MRFIoG3ytZeLKln5l1LY60S1kb4iPLf66vZFZoyV4FHUOhQjttpSd9Fg= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: dxc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47a36246-f1e5-4aee-e29a-08d6f65913af X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jun 2019 14:59:36.0581 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 93f33571-550f-43cf-b09f-cd331338d086 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: robert.rozboril@dxc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4351 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi =C1lvaro, Thank you for your answer. Good luck! Meanwhile I did workaround using before update trigger to handle data in ch= ild tables and setting constraints as deferred to don't lose data. I am tes= ting it right now. Regards, Robert -----Original Message----- From: Alvaro Herrera [mailto:alvherre@2ndquadrant.com] Sent: Friday, June 21, 2019 15:28 To: Rozboril, Robert Cc: pgsql-bugs@lists.postgresql.org Subject: Re: PostgreSQL v11.3 - Records are deleted from child table if par= tition 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 l= evel that's what it is) and thus cascades to delete the tuple on polf. The= re is nothing that automagically instantiates a new tuple in polt. To fix this problem, we would need a mechanism to insert an equivalent refe= rencing tuple in the other partition. I'm not sure how would we achieve su= ch a thing. -- =C1lvaro 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 behal= f of DXC Technology Company or one of its affiliates. It is intended exclu= sively for the addressee. The substance of this message, along with any at= tachments, may contain proprietary, confidential or privileged information = or information that is otherwise legally exempt from disclosure. Any unauth= orized review, use, disclosure or distribution is prohibited. If you are no= t the intended recipient of this message, you are not authorized to read, p= rint, retain, copy or disseminate any part of this message. If you have rec= eived this message in error, please destroy and delete all copies and notif= y 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 ord= er or other contract unless pursuant to explicit written agreement or gover= nment initiative expressly permitting the use of e-mail for such purpose. -= -.