From 67d25e5a853146e272c6934ab0436eb06f7bb06e Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 29 Dec 2009 17:41:18 +0000 Subject: Previous fix for temporary file management broke returning a set from PL/pgSQL function within an exception handler. Make sure we use the right resource owner when we create the tuplestore to hold returned tuples. Simplify tuplestore API so that the caller doesn't need to be in the right memory context when calling tuplestore_put* functions. tuplestore.c automatically switches to the memory context used when the tuplestore was created. Tuplesort was already modified like this earlier. This patch also removes the now useless MemoryContextSwitch calls from callers. Report by Aleksei on pgsql-bugs on Dec 22 2009. Backpatch to 8.1, like the previous patch that broke this. --- src/pl/plperl/plperl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/pl/plperl/plperl.c') diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 0a6f8f78616..6a6fcd0db53 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1,7 +1,7 @@ /********************************************************************** * plperl.c - perl as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.136.2.5 2009/11/29 21:02:28 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.136.2.6 2009/12/29 17:41:18 heikki Exp $ * **********************************************************************/ @@ -1995,11 +1995,9 @@ plperl_return_next(SV *sv) tuple = heap_form_tuple(current_call_data->ret_tdesc, &ret, &isNull); } - /* Make sure to store the tuple in a long-lived memory context */ - MemoryContextSwitchTo(rsi->econtext->ecxt_per_query_memory); tuplestore_puttuple(current_call_data->tuple_store, tuple); - MemoryContextSwitchTo(old_cxt); + MemoryContextSwitchTo(old_cxt); MemoryContextReset(current_call_data->tmp_cxt); } -- cgit v1.2.3