Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vwQFW-005rdm-0N for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Feb 2026 19:45:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwQFV-00BPgO-08 for pgsql-bugs@arkaria.postgresql.org; Sat, 28 Feb 2026 19:45:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vvzAx-0047hm-1B for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 14:50:43 +0000 Received: from mail-dl1-x1236.google.com ([2607:f8b0:4864:20::1236]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvzAu-00000001aK9-0VpX for pgsql-bugs@lists.postgresql.org; Fri, 27 Feb 2026 14:50:43 +0000 Received: by mail-dl1-x1236.google.com with SMTP id a92af1059eb24-12758ce1e8dso1452198c88.0 for ; Fri, 27 Feb 2026 06:50:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772203839; cv=none; d=google.com; s=arc-20240605; b=U+Ba1M1cUPgfMtwi7hfyR5nVKFOeU5FhfTgjN1Pb6nd6c6qhVGI5qgOYv82gAlhHPp TEwkQeWLl7lLQqbtKqj9Phwi1J3GiqVhacL6gNRWNF0IeLhlgVsl6SDnb/A8mp/p4miT RKB8VvBoz9sbVRjz9hSlwWTvRqq+y6BfQpcBWq7N5V2ERcezjTOI/vURie36vLB1maUD CqzZa0aHPq25u7UcrIW3nGlxhJ6WmBmqRrxHBBsyyO8bsl5X6oWmBU8ActfOHwOeFHgO 4ULRPocpKuFhIpIuy8THLEi9jYfrAG58IjNjMEKcQs+d+DfWqA3G08jVToXFSNC95j9Z zjTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=r1IM4IydcRfqZSA5FtdbAdD5JJLex+B9V8jMBniGmqY=; fh=vR25N3+d8dNHUTLhu+5NPbhqmVDzmSWekj9cOnxEonw=; b=e9q+IB7U86aSF4RnzSBz1XSVSmzQwBtg3XfUb7x7cil0uwCMW3uEgzLik6jKyOVy0b qGOAwPdjCkNEpgp+TUgrsTe90/CQRuFzv/Ixm3z/6lAcxgqTPdk2WfwzDa5lZlxOfLcu 9AOKyyIKE2oTibNJ4gAUjrqlsvUPrG4u2xJdHzPLhWsz3XFAPi6IZd6T2jQhu9ntROto xp9ZrFUdyJy6/BFoTJCxjIOtGnJnADmTC7wyub+g2cMYrGKER7MOvb7FgufsNvx6t5oc g+i5HpjJ/gdYk/qg/ibQ5IozqAhiEsqiMvmvvaoW6wiHJ3NDQoiJ22hgGkvvs1C0SyRF +BcQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772203839; x=1772808639; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=r1IM4IydcRfqZSA5FtdbAdD5JJLex+B9V8jMBniGmqY=; b=jFfdntA0+rvyr9Uo+bl0ylUXehgXdx2eCzklQ/QwBU8jRKbk9LxjbYFf1JXA+ibMS/ vntljNBOjhhANM0AQTzPcyHjBoomcIT09NlLepNb6jmuGX89JUIAe7eLbiwI5pTKGrm1 VMlawhnearzDCI1fmtv5pYERBwtS0yXlcvNW5ZHvV4yoz0Y08aIxZ4uuPqMPbGkyJdMv 6suIk9gfNU64St6UmClkwm9tiJBwPzfl196fwkT0KQTqmPiauBcJVvdXxlLOQnlJh3xw hdFWsuxvNVfTm3StH8Iek3C3/bIjnSpgL/n3mfooBGS9+PXc1ApByA/W25nXncnZZujV 3cZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772203839; x=1772808639; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=r1IM4IydcRfqZSA5FtdbAdD5JJLex+B9V8jMBniGmqY=; b=VRWg0E5Zwk2Y8hpefdnQo3g+vxGBs9DzFkI5KWQDgDxYz/wxoTrpyP7yjsG9g5proO yW3O0U7EPEn/Vo6ay6EeK7yS6FFOxwHNbWcEB3S1gDIIV7rhUDPYyyvYLb5QzlX+RPmN g/7lS7qJyk2zS05yGne3Rb9rymRhpU50nTXs90yZoZbtnTg3l+ZbVfLzhr68uGs1zwZy HoR2K+DkLm1zrE0FBd8ArEOkmWfUhWxRu7Edq1UFXWb6PWbzLT6PzVM6TwkBsPoZcvi/ TR9cXPmEsg54FVbssbhoqjMw+KHpsd1udh6jN034gFCHGAn48QJvMiiDFITO7tG3rkmo 8McQ== X-Gm-Message-State: AOJu0Yw2Gu/isMWQeJ+KGZPCKiY2kOnshcAkiwKzb+i66qZU4Uz7LxdQ VW/oFwGV+GbuHhARW1v7j3Qa9MNdHjyKIEQWp5XsADEG8rhRwGd+uYa35OxkejKjDI0CbeIGf42 3Z5KF4bFsGozRdkQfxFSQc3hvdplPqWLmChux X-Gm-Gg: ATEYQzxbkZ4G4MbOP/Mq+lSIXxFsYDEim2jVEwaI0TosYXkppa7JP5vI6751Ma5P4CX PcjE1wAC49tAYIkfSd+xordMfANDF93FJL62jtf/zAD8grLZVe8hfAd1Sux5ikapSn1KGgHZxXs KCNnSPRF1/dKY/iCAmUAy4PlPR+o3XUTiBpyuj2IzaoqwfHXedH0nurY0AJx7/FNSLyTrCerxuf vAYrKaKkC1e+MqRZ90epoYON+70/etrHa2N1GDCWRvN5jFcMLZPDeWes82qPPIHPKWt9vLulFs9 LwhjZSs= X-Received: by 2002:a05:7022:90f:b0:11b:9386:a3c8 with SMTP id a92af1059eb24-1278fd7b7d5mr1262481c88.41.1772203838615; Fri, 27 Feb 2026 06:50:38 -0800 (PST) MIME-Version: 1.0 References: <19420-ec7f929dce3a7e14@postgresql.org> <1b32a18349afe49d4cc605a91b8f900e4f9e1ad1.camel@cybertec.at> In-Reply-To: <1b32a18349afe49d4cc605a91b8f900e4f9e1ad1.camel@cybertec.at> From: Agnieszka Chodkowska-Gyurics Date: Fri, 27 Feb 2026 15:50:27 +0100 X-Gm-Features: AaiRm53eecDRwnQ9y5jMY2ggzXqzCvPnsd6XVJRIsQxm3qjlo69Lkn3rP9Am4Ss Message-ID: Subject: Re: BUG #19420: Zombie FK exists after partition is detached. To: Laurenz Albe Cc: pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000045357d064bcf5ca7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000045357d064bcf5ca7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'm thinking about that too, but I wanted to make sure there wasn't a better solution first. pt., 27 lut 2026 o 15:45 Laurenz Albe napisa=C5= =82(a): > On Fri, 2026-02-27 at 09:09 +0000, PG Bug reporting form wrote: > > Logged by: Agnieszka Chodkowska > > PostgreSQL version: 16.6 > > Operating system: Linux, Debian 12.2.0 64 bit > > > > I have child table with FK defined as folllows > > > > ALTER TABLE IF EXISTS tst.child_test_1 > > ADD CONSTRAINT child_test_1_parent_id_parent_part_by_fkey FOREIGN K= EY > > (parent_id, parent_part_by) > > REFERENCES tst.maintenance_test_1_p20260218 (id, part_by) MATCH > SIMPLE > > ON UPDATE NO ACTION > > ON DELETE CASCADE; > > This is a table partition with a foreign key to another table partition, > correct? > > > I updated configuration according to documentation as follows: > > retention_keep_table=3Dfalse , > > retention_keep_index =3D false > > These are not PostgreSQL configuration parameters... > > > Somehow postgresql retains the foreign keys of the detached/dropped > > partitions, to the parent table partitions. > > That is as expected. partitions are tables in their own right and can > entertain foreign key constraints to other tables, independent of their > role as partitions of a partitioned table. > > > I try the following methods: > > partman.run_maintenance('tst.child_test_1') > > partman.run_maintenance() > > ALTER TABLE tst.child_test_1 DETACH PARTITION > > > > The error persisted regardless of the method used. > > I'd say that you have to drop the foreign key constraint explicitly. > > Yours, > Laurenz Albe > --=20 Zapraszam na moj=C4=85 stron=C4=99 www. --00000000000045357d064bcf5ca7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

= I'm thinking about that too, but I wanted to make sure there wasn't a better solutio= n first.


pt., 27 lut 2026 o 15:45=C2=A0Laur= enz Albe <laurenz.albe@cyber= tec.at> napisa=C5=82(a):
On Fri, 2026-02-27 at 09:09 +0000, PG Bug reporting form wr= ote:
> Logged by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Agnieszka Chodkowska
> PostgreSQL version: 16.6
> Operating system:=C2=A0 =C2=A0Linux, Debian 12.2.0 64 bit
>
> I have child table=C2=A0 with FK defined as folllows
>
> ALTER TABLE IF EXISTS tst.child_test_1
>=C2=A0 =C2=A0 =C2=A0ADD CONSTRAINT child_test_1_parent_id_parent_part_b= y_fkey FOREIGN KEY
> (parent_id, parent_part_by)
>=C2=A0 =C2=A0 =C2=A0REFERENCES tst.maintenance_test_1_p20260218 (id, pa= rt_by) MATCH SIMPLE
>=C2=A0 =C2=A0 =C2=A0ON UPDATE NO ACTION
>=C2=A0 =C2=A0 =C2=A0ON DELETE CASCADE;

This is a table partition with a foreign key to another table partition, correct?

> I updated configuration according to documentation as follows:
> retention_keep_table=3Dfalse ,
> retention_keep_index =3D false

These are not PostgreSQL configuration parameters...

> Somehow postgresql retains the foreign keys of the detached/dropped > partitions, to the parent table partitions.

That is as expected.=C2=A0 partitions are tables in their own right and can=
entertain foreign key constraints to other tables, independent of their
role as partitions of a partitioned table.

> I try the following methods:
> partman.run_maintenance('tst.child_test_1')
> partman.run_maintenance()
> ALTER TABLE tst.child_test_1 DETACH PARTITION <child_test_p_2026021= 8>
>
> The error persisted regardless of the method used.

I'd say that you have to drop the foreign key constraint explicitly.
Yours,
Laurenz Albe


--
--00000000000045357d064bcf5ca7--