Avoid failure to open dropped detached partition
authorAlvaro Herrera <[email protected]>
Mon, 19 Aug 2024 20:09:10 +0000 (16:09 -0400)
committerAlvaro Herrera <[email protected]>
Mon, 19 Aug 2024 20:09:10 +0000 (16:09 -0400)
commita6ff329e7b7231aba9789922daa25e2367709d50
treec7ba254a0347a424c22a749ee7009bfbe633540c
parentf6991cafa36ee8cb943a34f13452fd166b7907c2
Avoid failure to open dropped detached partition

When a partition is detached and immediately dropped, a prepared
statement could try to compute a new partition descriptor that includes
it.  This leads to this kind of error:
ERROR:  could not open relation with OID 457639

Avoid this by skipping the partition in expand_partitioned_rtentry if it
doesn't exist.

Noted by me while investigating bug #18559.  Kuntal Gosh helped to
identify the exact failure.

Backpatch to 14, where DETACH CONCURRENTLY was introduced.

Author: Álvaro Herrera <[email protected]>
Reviewed-by: Kuntal Ghosh <[email protected]>
Reviewed-by: Junwang Zhao <[email protected]>
Discussion: https://postgr.es/m/202408122233[email protected]
src/backend/optimizer/util/inherit.c