/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.128 2007/04/02 03:49:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.129 2007/06/28 17:49:59 tgl Exp $
*
**********************************************************************/
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("Perl hash contains nonexistent column \"%s\"",
key)));
- if (SvOK(val) && SvTYPE(val) != SVt_NULL)
+ if (SvOK(val))
values[attn - 1] = SvPV(val, PL_na);
}
hv_iterinit(perlhash);
&typinput, &typioparam);
fmgr_info(typinput, &finfo);
atttypmod = tupdesc->attrs[attn - 1]->atttypmod;
- if (SvOK(val) && SvTYPE(val) != SVt_NULL)
+ if (SvOK(val))
{
modvalues[slotsused] = InputFunctionCall(&finfo,
SvPV(val, PL_na),
* 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 of return
- * value is an error.
+ * value is an error, except undef which means return an empty set.
*/
- if (SvTYPE(perlret) == SVt_RV &&
+ if (SvOK(perlret) &&
+ SvTYPE(perlret) == SVt_RV &&
SvTYPE(SvRV(perlret)) == SVt_PVAV)
{
int i = 0;
i++;
}
}
- else if (SvTYPE(perlret) != SVt_NULL)
+ else if (SvOK(perlret))
{
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
}
retval = (Datum) 0;
}
- else if (SvTYPE(perlret) == SVt_NULL)
+ else if (!SvOK(perlret))
{
/* Return NULL if Perl code returned undef */
if (rsi && IsA(rsi, ReturnSetInfo))
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
- if (!(perlret && SvOK(perlret) && SvTYPE(perlret) != SVt_NULL))
+ if (perlret == NULL || !SvOK(perlret))
{
/* undef result means go ahead with original tuple */
TriggerData *trigdata = ((TriggerData *) fcinfo->context);
Datum ret;
bool isNull;
- if (SvOK(sv) && SvTYPE(sv) != SVt_NULL)
+ if (SvOK(sv))
{
char *val = SvPV(sv, PL_na);
for (i = 0; i < argc; i++)
{
- if (SvTYPE(argv[i]) != SVt_NULL)
+ if (SvOK(argv[i]))
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
SvPV(argv[i], PL_na),
for (i = 0; i < argc; i++)
{
- if (SvTYPE(argv[i]) != SVt_NULL)
+ if (SvOK(argv[i]))
{
argvalues[i] = InputFunctionCall(&qdesc->arginfuncs[i],
SvPV(argv[i], PL_na),