> The attached patch moves a plperl sanity check into the correct

> position. Performing the check in the existing position allows the call
> to go through to perl first, possibly resulting in a SEGV.

Andrew Dunstan
This commit is contained in:
Bruce Momjian 2005-08-12 20:48:03 +00:00
parent 88a2b5c10f
commit 60672b59b8

View File

@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.86 2005/07/12 20:35:42 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.87 2005/08/12 20:48:03 momjian Exp $
*
**********************************************************************/
@ -921,6 +921,16 @@ plperl_func_handler(PG_FUNCTION_ARGS)
plperl_current_tuple_store = 0;
plperl_current_tuple_desc = 0;
if (!rsi || !IsA(rsi, ReturnSetInfo) ||
(rsi->allowedModes & SFRM_Materialize) == 0 ||
rsi->expectedDesc == NULL)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("set-valued function called in context that "
"cannot accept a set")));
}
perlret = plperl_call_perl_func(prodesc, fcinfo);
/************************************************************
@ -936,16 +946,6 @@ plperl_func_handler(PG_FUNCTION_ARGS)
if (prodesc->fn_retisset)
{
if (!rsi || !IsA(rsi, ReturnSetInfo) ||
(rsi->allowedModes & SFRM_Materialize) == 0 ||
rsi->expectedDesc == NULL)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("set-valued function called in context that "
"cannot accept a set")));
}
/* If the Perl function returned an arrayref, we pretend that it
* called return_next() for each element of the array, to handle
* old SRFs that didn't know about return_next(). Any other sort