From: | John Worsley <lx(at)openvein(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | [PATCH] PL/Perl (Mis-)Behavior with Runtime Error Reporting |
Date: | 2002-10-02 23:08:36 |
Message-ID: | Pine.LNX.4.21.0210021600230.5468-200000@baby.audiophonic.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Good day,
I just stumbled across this peculiarity in PL/Perl today writing a method
toinvoke Perl Regexes from a function: if a run-time error is raised in an
otherwise good function, the function will not run correctly again until
the connection to the database is reset. I poked around in the code and it
appears that it's because when elog() raises the ERROR, it doesn't first
take action to erase the system error message ($@) and consequently every
subsequent run has an error raised, even if it runs succesfully.
For example:
-- This comparison works fine.
template1=# SELECT perl_re_match('test', 'test');
perl_re_match
---------------
t
(1 row)
-- This one dies, for obvious reasons.
template1=# SELECT perl_re_match('test', 't{1}+?');
ERROR: plperl: error from function: (in cleanup) Nested quantifiers
before HERE mark in regex m/t{1}+ << HERE ?/ at (eval 2) line 4.
-- This should work fine again, but we still have this error raised...!
template1=# SELECT perl_re_match('test', 'test');
ERROR: plperl: error from function: (in cleanup) Nested quantifiers
before HERE mark in regex m/t{1}+ << HERE ?/ at (eval 2) line 4.
I don't know if the following is the best way to solve it, but I got
around it by modifying the error report in this part of PL/Perl to be a
NOTICE, cleared the $@ variable, and then raised the fatal ERROR. A simple
three line patch to plperl.c follows, and is attached.
plperl.c:
443c443,445
< elog(ERROR, "plperl: error from function: %s", SvPV(ERRSV, PL_na));
---
> elog(NOTICE, "plperl: error from function: %s", SvPV(ERRSV, PL_na));
> sv_setpv(perl_get_sv("@",FALSE),"");
> elog(ERROR, "plperl: error was fatal.");
Best Regards,
Jw.
--
John Worsley - lx(at)openvein(dot)com
Attachment | Content-Type | Size |
---|---|---|
plperl.c.diff | text/plain | 301 bytes |
From | Date | Subject | |
---|---|---|---|
Postgresql : | Michael Paesold | 2002-10-02 23:21:00 | Re: [HACKERS] Anyone want to assist with the translation of the Advocacy site? |
Previous Message | Tom Lane | 2002-10-02 22:58:02 | Re: foreach in sql functions |
From | Date | Subject | |
---|---|---|---|
Postgresql : | Michael Paesold | 2002-10-02 23:21:00 | Re: [HACKERS] Anyone want to assist with the translation of the Advocacy site? |
Previous Message | Laurette Cisneros | 2002-10-02 23:03:34 | Re: pg7.3b1 |