Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 65790b9

Browse files
committed
Un-break plperl for non-set case.
1 parent 7d781c6 commit 65790b9

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/pl/plperl/plperl.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ENHANCEMENTS, OR MODIFICATIONS.
3434
*
3535
* IDENTIFICATION
36-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.88 2005/08/12 21:09:34 momjian Exp $
36+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.89 2005/08/12 21:26:32 tgl Exp $
3737
*
3838
**********************************************************************/
3939

@@ -923,14 +923,16 @@ plperl_func_handler(PG_FUNCTION_ARGS)
923923

924924
rsi = (ReturnSetInfo *)fcinfo->resultinfo;
925925

926-
if (!rsi || !IsA(rsi, ReturnSetInfo) ||
927-
(rsi->allowedModes & SFRM_Materialize) == 0 ||
928-
rsi->expectedDesc == NULL)
926+
if (prodesc->fn_retisset)
929927
{
930-
ereport(ERROR,
931-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
932-
errmsg("set-valued function called in context that "
933-
"cannot accept a set")));
928+
/* Check context before allowing the call to go through */
929+
if (!rsi || !IsA(rsi, ReturnSetInfo) ||
930+
(rsi->allowedModes & SFRM_Materialize) == 0 ||
931+
rsi->expectedDesc == NULL)
932+
ereport(ERROR,
933+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
934+
errmsg("set-valued function called in context that "
935+
"cannot accept a set")));
934936
}
935937

936938
perlret = plperl_call_perl_func(prodesc, fcinfo);
@@ -944,12 +946,14 @@ plperl_func_handler(PG_FUNCTION_ARGS)
944946
if (SPI_finish() != SPI_OK_FINISH)
945947
elog(ERROR, "SPI_finish() failed");
946948

947-
if (prodesc->fn_retisset)
949+
if (prodesc->fn_retisset)
948950
{
949-
/* If the Perl function returned an arrayref, we pretend that it
951+
/*
952+
* If the Perl function returned an arrayref, we pretend that it
950953
* called return_next() for each element of the array, to handle
951954
* old SRFs that didn't know about return_next(). Any other sort
952-
* of return value is an error. */
955+
* of return value is an error.
956+
*/
953957
if (SvTYPE(perlret) == SVt_RV &&
954958
SvTYPE(SvRV(perlret)) == SVt_PVAV)
955959
{

0 commit comments

Comments
 (0)