]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid dangling-pointer problem with partitionwise joins under GEQO.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Feb 2024 20:21:53 +0000 (15:21 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 23 Feb 2024 20:21:53 +0000 (15:21 -0500)
commit9061fd23c28faebcb29bdfb262975639715975c0
treeccc820555c4251abc4fbb5fc6c66af96cdac12d4
parenteb1d008a7a18f2cf863e21e285b6db5858d0d5d9
Avoid dangling-pointer problem with partitionwise joins under GEQO.

build_child_join_sjinfo creates a derived SpecialJoinInfo in
the short-lived GEQO context, but afterwards the semi_rhs_exprs
from that may be used in a UniquePath for a child base relation.
This breaks the expectation that all base-relation-level structures
are in the planning-lifespan context, leading to use of a dangling
pointer with probable ensuing crash later on in create_unique_plan.
To fix, copy the expression trees when making a UniquePath.

Per bug #18360 from Alexander Lakhin.  This has been broken since
partitionwise joins were added, so back-patch to all supported
branches.

Discussion: https://postgr.es/m/18360-a23caf3157f34e62@postgresql.org
src/backend/optimizer/util/pathnode.c