From: Alvaro Herrera <alvherre@alvh.no-ip.org>
Subject: [PATCH] Don't open partitions that were detached and dropped
Date: Tue, 13 Aug 2024 14:07:56 -0400
---
src/backend/optimizer/util/inherit.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
inline patch 1: src/backend/optimizer/util/inherit.c (+11/-2 lines) download inline-1.patchdiff --git a/src/backend/optimizer/util/inherit.c b/src/backend/optimizer/util/inherit.cindex 4797312ae5..c5b906a9d4 100644--- a/src/backend/optimizer/util/inherit.c+++ b/src/backend/optimizer/util/inherit.c@@ -386,8 +386,17 @@ expand_partitioned_rtentry(PlannerInfo *root, RelOptInfo *relinfo,
Index childRTindex;
RelOptInfo *childrelinfo;
- /* Open rel, acquiring required locks */- childrel = table_open(childOID, lockmode);+ /*+ * Open rel, acquiring required locks. If a partition was recently+ * detached and subsequently dropped, then opening it will fail. In+ * this case, behave as though the partition had been pruned.+ */+ childrel = try_table_open(childOID, lockmode);+ if (childrel == NULL)+ {+ relinfo->live_parts = bms_del_member(relinfo->live_parts, i);+ continue;+ }
/*
* Temporary partitions belonging to other sessions should have been
--
2.39.2
--gxl4twfi4xob65vc--
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: alvherre@alvh.no-ip.org
Subject: Re: [PATCH] Don't open partitions that were detached and dropped
In-Reply-To: <no-message-id-25496@localhost>
* 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