summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-07-28 04:51:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-07-28 04:51:21 +0000
commit44b16a2cf51a66c475a53435755724cd5cbbbd4e (patch)
tree6820ebf58460872065fe4f3d694e221d57bfe9f9 /src/test
parente83657973771cd58bcf3fc9389247478bc51e6e6 (diff)
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/subselect.out9
-rw-r--r--src/test/regress/sql/subselect.sql6
2 files changed, 15 insertions, 0 deletions
diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out
index 339b46f2972..7dd2db728bd 100644
--- a/src/test/regress/expected/subselect.out
+++ b/src/test/regress/expected/subselect.out
@@ -449,3 +449,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 46b46b4c45e..257ff9a6a59 100644
--- a/src/test/regress/sql/subselect.sql
+++ b/src/test/regress/sql/subselect.sql
@@ -289,3 +289,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);