Lists: | pgsql-patches |
---|
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Subject: | PL/Perl regression tests with use_strict |
Date: | 2005-08-20 19:52:42 |
Message-ID: | 20050820195242.GA77165@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
The attached patch allows the PL/Perl regression tests to pass when
use_strict is enabled. I've also attached a variant of plperl_elog.out
to account for an elog() message that shows a different line number
when run under use_strict.
--
Michael Fuhr
Attachment | Content-Type | Size |
---|---|---|
plperl-regression.patch | text/plain | 2.6 KB |
plperl_elog_1.out | text/plain | 506 bytes |
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 02:22:28 |
Message-ID: | 20050824022228.GA32113@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
On Sat, Aug 20, 2005 at 01:52:42PM -0600, Michael Fuhr wrote:
> The attached patch allows the PL/Perl regression tests to pass when
> use_strict is enabled. I've also attached a variant of plperl_elog.out
> to account for an elog() message that shows a different line number
> when run under use_strict.
Here's an updated version of the PL/Perl regression test patch that
works with Andrew Dunstan's strict mode patch, both when use_strict
is enabled and when it's disabled. The variant of plperl_elog.out
is no longer needed.
--
Michael Fuhr
Attachment | Content-Type | Size |
---|---|---|
plperl-regression.patch | text/plain | 3.3 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | pgsql-patches(at)postgresql(dot)org, Andrew Dunstan <andrew(at)dunslane(dot)net> |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 03:58:25 |
Message-ID: | 20955.1124855905@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Michael Fuhr <mike(at)fuhr(dot)org> writes:
> Here's an updated version of the PL/Perl regression test patch that
> works with Andrew Dunstan's strict mode patch, both when use_strict
> is enabled and when it's disabled. The variant of plperl_elog.out
> is no longer needed.
Actually, the main reason I didn't apply the prior version right
away was that the variant .out file was bugging me. Why does the
error report contain a line number that's dependent on implementation
internals in the first place? Changing it to a different number
doesn't seem like an improvement; can't we get rid of that entirely?
regards, tom lane
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-patches(at)postgresql(dot)org, Andrew Dunstan <andrew(at)dunslane(dot)net> |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 04:30:51 |
Message-ID: | 20050824043051.GA33460@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
On Tue, Aug 23, 2005 at 11:58:25PM -0400, Tom Lane wrote:
> Michael Fuhr <mike(at)fuhr(dot)org> writes:
> > Here's an updated version of the PL/Perl regression test patch that
> > works with Andrew Dunstan's strict mode patch, both when use_strict
> > is enabled and when it's disabled. The variant of plperl_elog.out
> > is no longer needed.
>
> Actually, the main reason I didn't apply the prior version right
> away was that the variant .out file was bugging me. Why does the
> error report contain a line number that's dependent on implementation
> internals in the first place? Changing it to a different number
> doesn't seem like an improvement; can't we get rid of that entirely?
Actually, I just noticed that the varying number isn't a line number
but rather a sequence number. Example:
% cat foo
#!/usr/bin/perl
use strict;
use warnings;
my $code = '$x = 123;';
eval $code; print $@;
eval $code; print $@;
eval $code; print $@;
% ./foo
Global symbol "$x" requires explicit package name at (eval 1) line 1.
Global symbol "$x" requires explicit package name at (eval 2) line 1.
Global symbol "$x" requires explicit package name at (eval 3) line 1.
If I'm reading the Perl source code correctly (pp_ctl.c), the number
following "eval" comes from a variable named PL_evalseq that's
incremented each time it appears in one of these messages. It looks
like we'd have to munge the error message to get rid of that.
--
Michael Fuhr
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-patches(at)postgresql(dot)org, Andrew Dunstan <andrew(at)dunslane(dot)net> |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 05:37:26 |
Message-ID: | 20050824053726.GA34097@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
On Tue, Aug 23, 2005 at 10:30:51PM -0600, Michael Fuhr wrote:
> Global symbol "$x" requires explicit package name at (eval 3) line 1.
>
> If I'm reading the Perl source code correctly (pp_ctl.c), the number
> following "eval" comes from a variable named PL_evalseq that's
> incremented each time it appears in one of these messages. It looks
> like we'd have to munge the error message to get rid of that.
Hmmm...tests suggest that we might be able to munge $@ in the
mk*safefunc functions. That is, instead of doing
return eval($stuff);
we might be able to do
my $retval = eval($stuff);
$@ =~ s/ \(eval \d+\) / /g if $@;
return $retval;
That would convert messages like
Global symbol "$x" requires explicit package name at (eval 3) line 1.
into
Global symbol "$x" requires explicit package name at line 1.
Is that what you're looking for? So far I've done only simple tests
in standalone embedded Perl programs, so I don't know if this approach
would work in PL/Perl or have unintended effects.
--
Michael Fuhr
From: | "Andrew Dunstan" <andrew(at)dunslane(dot)net> |
---|---|
To: | <mike(at)fuhr(dot)org> |
Cc: | <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 05:38:46 |
Message-ID: | 1741.24.211.165.134.1124861926.squirrel@www.dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Michael Fuhr said:
> On Tue, Aug 23, 2005 at 10:30:51PM -0600, Michael Fuhr wrote:
>> Global symbol "$x" requires explicit package name at (eval 3) line 1.
>>
>> If I'm reading the Perl source code correctly (pp_ctl.c), the number
>> following "eval" comes from a variable named PL_evalseq that's
>> incremented each time it appears in one of these messages. It looks
>> like we'd have to munge the error message to get rid of that.
>
> Hmmm...tests suggest that we might be able to munge $@ in the
> mk*safefunc functions. That is, instead of doing
>
> return eval($stuff);
>
> we might be able to do
>
> my $retval = eval($stuff);
> $@ =~ s/ \(eval \d+\) / /g if $@;
> return $retval;
>
> That would convert messages like
>
> Global symbol "$x" requires explicit package name at (eval 3) line 1.
>
> into
>
> Global symbol "$x" requires explicit package name at line 1.
>
> Is that what you're looking for? So far I've done only simple tests in
> standalone embedded Perl programs, so I don't know if this approach
> would work in PL/Perl or have unintended effects.
It would probably be more efficient and less convoluted to munge this in a
__DIE__ handler. The we wouldn't need the extra level of eval.
e.g.
$SIG{__DIE__} =
sub { my $msg = $_[0]; $msg =~ s/\(eval \d+\) //; die $msg; };
cheers
andrew
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Cc: | mike(at)fuhr(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 13:50:06 |
Message-ID: | 430C7B0E.2050805@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
I wrote:
>Michael Fuhr said:
>
>
>>we might be able to do
>>
>> my $retval = eval($stuff);
>> $@ =~ s/ \(eval \d+\) / /g if $@;
>> return $retval;
>>
>>T
>>
>It would probably be more efficient and less convoluted to munge this in a
>__DIE__ handler. The we wouldn't need the extra level of eval.
>
>e.g.
>
>$SIG{__DIE__} =
> sub { my $msg = $_[0]; $msg =~ s/\(eval \d+\) //; die $msg; };
>
>
>
>
Or rather it would do if we didn't carefully avoid the die handler so we
can get our hands on the message.
Here's an updated patch incorporating Michael's ideas, and this time
*with* a small regression test that dynamically turns strict mode on/off.
cheers
andrew
Attachment | Content-Type | Size |
---|---|---|
plperl-strict2.patch | text/x-patch | 10.8 KB |
From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | pgsql-patches(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 14:12:04 |
Message-ID: | 20050824141203.GA53239@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
On Wed, Aug 24, 2005 at 09:50:06AM -0400, Andrew Dunstan wrote:
> Here's an updated patch incorporating Michael's ideas, and this time
> *with* a small regression test that dynamically turns strict mode on/off.
Shouldn't the $@ munging patterns include the /g flag so they remove
all occurrences of the pattern?
SET plperl.use_strict TO on;
CREATE FUNCTION foo() RETURNS integer AS $$
$x = 1;
$y = 2;
return $x + $y;
$$ LANGUAGE plperl;
ERROR: creation of Perl function failed: Global symbol "$x" requires explicit package name at line 2.
Global symbol "$y" requires explicit package name at (eval 10) line 3.
Global symbol "$x" requires explicit package name at (eval 10) line 4.
Global symbol "$y" requires explicit package name at (eval 10) line 4.
--
Michael Fuhr
From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | pgsql-patches(at)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 14:28:31 |
Message-ID: | 430C840F.6020802@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Michael Fuhr wrote:
>On Wed, Aug 24, 2005 at 09:50:06AM -0400, Andrew Dunstan wrote:
>
>
>>Here's an updated patch incorporating Michael's ideas, and this time
>>*with* a small regression test that dynamically turns strict mode on/off.
>>
>>
>
>Shouldn't the $@ munging patterns include the /g flag so they remove
>all occurrences of the pattern?
>
>SET plperl.use_strict TO on;
>
>CREATE FUNCTION foo() RETURNS integer AS $$
>$x = 1;
>$y = 2;
>return $x + $y;
>$$ LANGUAGE plperl;
>
>ERROR: creation of Perl function failed: Global symbol "$x" requires explicit package name at line 2.
>Global symbol "$y" requires explicit package name at (eval 10) line 3.
>Global symbol "$x" requires explicit package name at (eval 10) line 4.
>Global symbol "$y" requires explicit package name at (eval 10) line 4.
>
>
>
good point.
Here's yet another revision ;-)
cheers
andrew
Attachment | Content-Type | Size |
---|---|---|
plperl-strict3.patch | text/x-patch | 10.9 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Fuhr <mike(at)fuhr(dot)org> |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: PL/Perl regression tests with use_strict |
Date: | 2005-08-24 19:25:28 |
Message-ID: | 8163.1124911528@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-patches |
Michael Fuhr <mike(at)fuhr(dot)org> writes:
> The attached patch allows the PL/Perl regression tests to pass when
> use_strict is enabled. I've also attached a variant of plperl_elog.out
> to account for an elog() message that shows a different line number
> when run under use_strict.
Now that we've got the use_strict mess sorted, I've applied this.
regards, tom lane