Re: [GENERAL] Small patch for PL/Perl Misbehavior with - Mailing list pgsql-hackers

From John Worsley
Subject Re: [GENERAL] Small patch for PL/Perl Misbehavior with
Date
Msg-id Pine.LNX.4.21.0210041940300.9959-100000@baby.audiophonic.com
Whole thread Raw
In response to Re: [GENERAL] Small patch for PL/Perl Misbehavior with Runtime Error Reporting  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] Small patch for PL/Perl Misbehavior with Runtime Error Reporting
List pgsql-hackers
On Thu, 3 Oct 2002, Tom Lane wrote:
>That seems a little weird.  Does Perl really expect people to do that
>(ie, is it a documented part of some API)?  I wonder whether there is
>some other action that we're supposed to take instead, but are
>missing...

Not that I know of: clearing out the $@ variable manually was just my way
of getting around the problem in practice. I think the underlying issue
may be tied to the fact that it's running a function generated within a
Safe Module, but I'm not enough of a Perl Guru to say anything more
decisive than that.

>If this is what we'd have to do, I think a better way would be
>
>    perlerrmsg = pstrdup(SvPV(ERRSV, PL_na));
>    sv_setpv(perl_get_sv("@",FALSE),"");
>    elog(ERROR, "plperl: error from function: %s", perlerrmsg);
>Splitting the ERROR into a NOTICE with the useful info and an ERROR
>without any isn't real good, because the NOTICE could get dropped on the
>floor (either because of min_message_level or a client that just plain
>loses notices).

Yeah, that's a cleaner solution. I take it anything pstrdup'd by
PostgreSQL gets freed automatically by the backend? (I wasn't familiar
enough with the backend to know how to ask for memory confident in the
understanding that it would at some point be freed. ;)

Jw.
-- 
John Worsley - lx@openvein.com
http://www.openvein.com/



pgsql-hackers by date:

Previous
From: "Curtis Faith"
Date:
Subject: Re: Potential Large Performance Gain in WAL synching
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] Small patch for PL/Perl Misbehavior with Runtime Error Reporting