33
33
* ENHANCEMENTS, OR MODIFICATIONS.
34
34
*
35
35
* 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 $
37
37
*
38
38
**********************************************************************/
39
39
@@ -923,14 +923,16 @@ plperl_func_handler(PG_FUNCTION_ARGS)
923
923
924
924
rsi = (ReturnSetInfo * )fcinfo -> resultinfo ;
925
925
926
- if (!rsi || !IsA (rsi , ReturnSetInfo ) ||
927
- (rsi -> allowedModes & SFRM_Materialize ) == 0 ||
928
- rsi -> expectedDesc == NULL )
926
+ if (prodesc -> fn_retisset )
929
927
{
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" )));
934
936
}
935
937
936
938
perlret = plperl_call_perl_func (prodesc , fcinfo );
@@ -944,12 +946,14 @@ plperl_func_handler(PG_FUNCTION_ARGS)
944
946
if (SPI_finish () != SPI_OK_FINISH )
945
947
elog (ERROR , "SPI_finish() failed" );
946
948
947
- if (prodesc -> fn_retisset )
949
+ if (prodesc -> fn_retisset )
948
950
{
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
950
953
* called return_next() for each element of the array, to handle
951
954
* 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
+ */
953
957
if (SvTYPE (perlret ) == SVt_RV &&
954
958
SvTYPE (SvRV (perlret )) == SVt_PVAV )
955
959
{
0 commit comments