pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] Don't open partitions that were detached and dropped
1+ messages / 1 participants
[nested] [flat]

* [PATCH] Don't open partitions that were detached and dropped
@ 2024-08-13 18:07 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 1+ messages in thread

From: Alvaro Herrera @ 2024-08-13 18:07 UTC (permalink / raw)

---
 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.c index 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-- ^ permalink raw reply [nested|flat] 1+ messages in thread


only message in thread

Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-13 18:07 [PATCH] Don't open partitions that were detached and dropped Alvaro Herrera <alvherre@alvh.no-ip.org>

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