Fix potential failure when hashing the output of a subplan that produces
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 28 Jul 2010 04:51:08 +0000 (04:51 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 28 Jul 2010 04:51:08 +0000 (04:51 +0000)
commit5a188dcb87d73c2ab8496186b412c1bd99ca05cb
tree11e6cfcece9dc1600f3d59ff1f0a6a459df13871
parent29789a8b7a43e3ab525e9dff1b2d800f22c51c4e
Fix potential failure when hashing the output of a subplan that produces
a pass-by-reference datatype with a nontrivial projection step.
We were using the same memory context for the projection operation as for
the temporary context used by the hashtable routines in execGrouping.c.
However, the hashtable routines feel free to reset their temp context at
any time, which'd lead to destroying input data that was still needed.
Report and diagnosis by Tao Ma.

Back-patch to 8.1, where the problem was introduced by the changes that
allowed us to work with "virtual" tuples instead of materializing intermediate
tuple values everywhere.  The earlier code looks quite similar, but it doesn't
suffer the problem because the data gets copied into another context as a
result of having to materialize ExecProject's output tuple.
src/backend/executor/nodeSubplan.c
src/include/nodes/execnodes.h
src/test/regress/expected/subselect.out
src/test/regress/sql/subselect.sql