Re: Checking for undefined in Perl interface code?

From: Teodor Sigaev <teodor(at)stack(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Checking for undefined in Perl interface code?
Date: 2002-01-24 09:25:48
Message-ID: 3C4FD31C.4050807@stack.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

man perlguts:
If you want to know if this variable (or any other SV) is
actually defined, you can call:

SvOK(SV*)

The scalar undef value is stored in an SV instance called
PL_sv_undef. Its address can be used whenever an SV* is
needed.

May be:
if (! (SvOK(perlret) && perlret != &PL_sv_undef) ) {...

Tom Lane wrote:

> PL/Perl tries to handle an "undef" result from a Perl function (which
> should convert to a SQL NULL) with code like so:
>
> /* XXX is this the approved way to check for an undef result? */
> if (perlret == &PL_sv_undef)
> {
> retval = (Datum) 0;
> fcinfo->isnull = true;
> }
> else
> {
> // handle non-null result
> }
>
> But I find that it doesn't work, at least not on RH Linux 7.2 with
> perl 5.6.0. The if-test fails to notice undef results.
>
> Anyone know what the correct way to do this is?
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>

--
Teodor Sigaev
teodor(at)stack(dot)net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2002-01-24 10:01:29 7.1.4
Previous Message Peter Eisentraut 2002-01-24 05:28:16 Re: RFD: schemas and different kinds of Postgres objects