From 581fe9331daab6bf65219fb842a75a90a438b605 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 28 Jul 2010 04:51:14 +0000 Subject: 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/test/regress/expected/subselect.out | 9 +++++++++ src/test/regress/sql/subselect.sql | 6 ++++++ 2 files changed, 15 insertions(+) (limited to 'src/test') diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out index a3be2997b50..468829a572c 100644 --- a/src/test/regress/expected/subselect.out +++ b/src/test/regress/expected/subselect.out @@ -492,3 +492,12 @@ from ----- (0 rows) +-- +-- Test case for premature memory release during hashing of subplan output +-- +select '1'::text in (select '1'::name union all select '1'::name); + ?column? +---------- + t +(1 row) + diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql index bfc0c33f245..6e1eda157a4 100644 --- a/src/test/regress/sql/subselect.sql +++ b/src/test/regress/sql/subselect.sql @@ -321,3 +321,9 @@ from from int8_tbl) sq0 join int4_tbl i4 on dummy = i4.f1; + +-- +-- Test case for premature memory release during hashing of subplan output +-- + +select '1'::text in (select '1'::name union all select '1'::name); -- cgit v1.2.3