pg_plan_advice: Avoid a crash under GEQO.

Robert Haas <rhaas@postgresql.org>

Commit: 01b02c0ecad1bb4e884614a00a5c619f20480823
Author: Robert Haas <rhaas@postgresql.org>
Date: 2026-03-17T18:25:43Z
pg_plan_advice: Avoid a crash under GEQO.

The previous code could allocate pgpa_sj_unique_rel objects in a context
that had too short a lifespan. Fix by allocating them (and any
associated List-related allocations) in the same context as the
pgpa_planner_state to which they are attached. We also need to copy
uniquerel->relids, because the associated RelOptInfo may also be
allocated within a short-lived context.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: http://postgr.es/m/a6e6d603-e847-44dc-acd5-879fb4570062@gmail.com

Files

PathChange+/−
contrib/pg_plan_advice/pgpa_planner.c modified +15 −2

Discussion