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 1wIIGD-007xEm-26 for pgsql-general@arkaria.postgresql.org; Thu, 30 Apr 2026 03:40:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIIFC-005c78-1g for pgsql-general@arkaria.postgresql.org; Thu, 30 Apr 2026 03:39:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wIIFB-005c70-2g for pgsql-general@lists.postgresql.org; Thu, 30 Apr 2026 03:39:18 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wIIF9-00000003RXa-2jSj for pgsql-general@lists.postgresql.org; Thu, 30 Apr 2026 03:39:16 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-463a0e14abfso252547b6e.2 for ; Wed, 29 Apr 2026 20:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777520355; cv=none; d=google.com; s=arc-20240605; b=eo0OksVmKgQznVbbHvNFASE402WU2TNmglZ3kJrKofAG5NuD2oErj2Lw5c9uzCqgFK WnMiyb2C53eNhOdK2v76H8YZMS+lwfO1iD0cltSec31ertwxH9+jIFBpuJabnLpekDx6 4N66srVhLnr6y1HA9PbwSdFofUDLYKxeb+l4Cll1kU/hPTndE77Py+QlorepKs/4j/Xl PPgrBT2CvTLG494BpATqHnkOhUwn3HanKJ/spuG8NVvI7dQGbixrvfPFuIXUaxY7rPfT v8ZPl3m7wFonIxeG+wHdisb8AE0BKl/3BzhDylrVHniBvXCs4oz6ry9beX4f9lZla5gH 4IKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BW6+56ZHEB2AJ9fpS2+6EEZ2EYRE+q5GuP+ZJ5UW60U=; fh=U9Vkrj/8YXu+wNKP4ImG87p6jlJYRxuB/zicT9qNons=; b=MemxzFEX1eeRYGl1zpjoHl+pBle1sf4YCxmUJhMelf1B6fllbrioxyEOUPfuINq0u7 eW5gxGBjdtJRdMOnElSxezlDTAuWjiUS+LNSIedmrsV/uEjbc+DQVFThQfpALZBsJkvO QF9Qo+GJlWGg0jR8rgC9TCld6bR+Pf4nHfAXtd5/yI7xIqIuiesi0IRdCzPH+njes0fQ EJbPBuy0ILiQ7oPKdJ2rGsAwSO0j3SIsfJbsP9h7/9FAyxWkCu9Ap5f/LUkRx7uuIuv8 M34TgWUcYURfO6pcPGwp/UKtucGp/wAlv+RyH9S7eGGNSOFJ1pJYB0eIOhUnuf+XX/Wd hEMg==; 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=20251104; t=1777520355; x=1778125155; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=BW6+56ZHEB2AJ9fpS2+6EEZ2EYRE+q5GuP+ZJ5UW60U=; b=tC48cBzfiaPlKODsJ1N3WWrq9cQwNc7M9t2trhPNxcvY8nmv51KXyMHC+f2I+wNHjM 67fEAmNPaVt+cYrpssCJCNXEQi4vhYlpYMogQUVwJj7UfYNoygoTGFoV2Rb6Zi3is6mJ B724dYYl2l6wa7Zh2hcmBaPqBbSTbzy7DXHl3i4ki+wogr3MCOyj2VF4kFuzsYB7t8j6 HgOxHaS8WOszrQyeIyqndvtufS2zb/8ff+twO/dJhj3A0mZ64SNWVo2LMhGqzRWcl5IB 55nOdfizHWQcpdPyVdSkZTSmLctEzK5NuULaHsxY6oSD/QeoTRXH6RdbuxUZyEz7SPKM kTCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777520355; x=1778125155; h=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=BW6+56ZHEB2AJ9fpS2+6EEZ2EYRE+q5GuP+ZJ5UW60U=; b=pMamtsKWIvq4mExpHLH/YkVtEUNfVJ9MEHWai9PmvBvKLKaeofiseu+TTS5lUV6r2O fAZDF0vd8CBA+PWQEde3tjrHWzKsXn+Fn2gwnOXuydqox1CP8yYF76o/DVN/ma0gv7u8 80TzZIICWHQVLMg6TJPOa57CXYIA6/uc/zcx9Ji/g/U/kVem3ux0HEzHD+GFIbEAWYbK y+1NMQyEVUTC+sRfT8W2AOG4U1qh3Cxynp+EdT/Dq90ykMd+UVtcWFFYNZEOdhqa5ju0 KQdLxOwzEAkOL1Oke9UDmo/ADRVp324+W2MNYOhbt8VzP3VXS9++oQ5M1y6s8eeY3KxF btFA== X-Gm-Message-State: AOJu0YzWXkegsbBv6Gu8lvRbnhtftVtoeeO15YHPVuQrSYPpGkNkoC1d BtCFRmlS4m+u4YQXyjUB0lAta1tpsf7oBKRz7kCoXOsihNLZO8wGWCpT48NrjPY/9QLH3u+n6XC SaeRiliu7ex27AFd4E7rYA59JvJZx/OuXCWno X-Gm-Gg: AeBDieuvbPAbTl1qR917BIL6agmftA+Zt9C5aYYRd9KhKg1sMQptrTUFsKzUTXauVR1 j8XAtFJn5YVgMYyrqXn4ExcedDqEj+7QImNBqESpA6UBTDF8hIu/nFGtT0Rie6H22NKvf8GnuTl NOQ2yNOp4D5wmTSsfWtd/RHQ014O+mC6ur01mX/oU9PmAZsqeT4I6+zkjzMy8DzUSQSZLAaOI9F Cyvq1OVPJQPf5w6qOLlthjufGvGQBgPc15Br9FyAttV3/mlILETKmRUaZL8nfH7KCtJ+RsSYnmQ 3UxDAYiYw7N5j7JaWt9+h32CaMoEqg== X-Received: by 2002:a05:6808:4f4f:b0:472:ee59:7a9c with SMTP id 5614622812f47-47c5fd9a194mr705162b6e.34.1777520355102; Wed, 29 Apr 2026 20:39:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Wed, 29 Apr 2026 23:39:03 -0400 X-Gm-Features: AVHnY4Ln4GrBcu-CRZ6XWZEuYjRi6xLns8d2p09-XD8Tw5lh-oLX3ZCiTXrY89c Message-ID: Subject: Re: Issue during partition drop To: pgsql-general Content-Type: multipart/alternative; boundary="00000000000058d2a40650a535f9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000058d2a40650a535f9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 29, 2026 at 10:37=E2=80=AFPM veem v wrote= : > Hi, > We have the Aurora Postgres database. And for a table with PK-FK > relationships, we have been running into issues while dropping partitions > using partman. We have planned to detach and drop the partitions but end = up > with the below error , so wanted to understand, if this is expected > behaviour > Absolutely. > and how to handle it? > > ERROR: cannot drop table _p20250202 because other objects > depend on it > CONTEXT: SQL statement "DROP TABLE _p20250202" > PL/pgSQL function > drop_partition_time(text,interval,boolean,boolean,text,timestamp with tim= e > zone) line 250 at EXECUTE > PL/pgSQL function partman.run_maintenance(text,boolean,boolean) line 336 > at assignment > DETAIL: constraint _fkey on table depends o= n > table _p20250202 > Whoever designed your database determined that "orphaned child" records are a bad thing. _fkey ensures that every "child" record has a "parent" record. If PG allows you to drop _p20250202, then there will be "orphaned children" in your database, but the FK means you don't want orphaned children. In order to drop _p20250202, you must first "dispose of" (aka DELETE) the child records that depend on records in _p20250202. If _fkey points to a table that is partitioned the same way that _p20250202 is partitioned, then *maybe* you can DETACH and then DROP that table full of child records. Only then can you drop _p20250202. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --00000000000058d2a40650a535f9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Apr 29, 2026 at 10:37=E2=80=AFPM = veem v <veema0000@gmail.com&g= t; wrote:
Hi,
We have the = Aurora Postgres database. And for a table with PK-FK relationships, we have= been running into issues while dropping partitions using partman.=C2=A0We = have planned to detach and drop the partitions but end up with the below er= ror , so wanted to understand, if this is expected behaviour

Absolutely.
=C2=A0
and how to handle it?=C2=A0
ERROR:=C2=A0 cannot drop table <table_name>_p20250202 beca= use other objects depend on it
CONTEXT: SQL statement "DROP TABLE &= lt;table_name>_p20250202"
PL/pgSQL function drop_partition_time(= text,interval,boolean,boolean,text,timestamp with time zone) line 250 at EX= ECUTE
PL/pgSQL function partman.run_maintenance(text,boolean,boolean) li= ne 336 at assignment
DETAIL: constraint <constraint_name>_fkey on = table <table_name> depends on table <table_name>_p20250202
<= /div>

Whoever designed your database determ= ined that "orphaned child" records are a bad=C2=A0thing.=C2=A0 &l= t;constraint_name>_fkey ensures that every "child" record has = a "parent" record.

If PG allows you to d= rop <table_name>_p20250202, then there will be "orphaned=C2=A0ch= ildren" in your database, but the FK means you don't want orphaned= children.

In order to drop <table_name>_p20= 250202, you must first "dispose of" (aka DELETE) the child record= s that depend on records in <table_name>_p20250202.=C2=A0 If <cons= traint_name>_fkey points to a table that is partitioned the same way tha= t <table_name>_p20250202 is partitioned, then maybe=C2=A0you c= an DETACH and then DROP that table full of child records.

Only then can you drop <table_name>_p20250202.

=
--
Death to <Redacted&g= t;, and butter sauce.
Don't boil me, I'm still alive.
<= div><Redacted> lobster!
--00000000000058d2a40650a535f9--