Re: [BUGS] plperl & sort

2010-01-11 Thread Alex Hunsaker
On Thu, Nov 6, 2008 at 08:37, Alex Hunsaker wrote: > On Thu, Nov 6, 2008 at 06:41, Tom Lane wrote: >> "Alex Hunsaker" writes: >>> On Wed, Nov 5, 2008 at 18:03, Andrew Gierth >>> wrote: Then explain why the problem goes away when you build perl with threading turned off. >> >>> Hrm ye

Re: [BUGS] plperl & sort

2008-11-06 Thread Alex Hunsaker
On Thu, Nov 6, 2008 at 09:00, Andrew Gierth <[EMAIL PROTECTED]> wrote: > If it helps any, I've tracked down in the perl guts exactly why this > happens: Cool > Notice, though, that without ithreads, the COP points directly to the > stash, but with ithreads, it points instead to the _name_ of the

Re: [BUGS] plperl & sort

2008-11-06 Thread Alex Hunsaker
On Thu, Nov 6, 2008 at 09:03, Andrew Gierth <[EMAIL PROTECTED]> wrote: >> "Alex" == Alex Hunsaker <[EMAIL PROTECTED]> writes: > > Alex> I submitted http://rt.perl.org/rt3/Public/Bug/Display.html?id=60374 > > Feel free to add my explanation to that (I couldn't see an obvious way > to do it mys

Re: [BUGS] plperl & sort

2008-11-06 Thread Andrew Gierth
> "Alex" == Alex Hunsaker <[EMAIL PROTECTED]> writes: Alex> I submitted http://rt.perl.org/rt3/Public/Bug/Display.html?id=60374 Feel free to add my explanation to that (I couldn't see an obvious way to do it myself) -- Andrew. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.o

Re: [BUGS] plperl & sort

2008-11-06 Thread Andrew Gierth
> "Alex" == Alex Hunsaker <[EMAIL PROTECTED]> writes: >> Then explain why the problem goes away when you build perl with >> threading turned off. Alex> Hrm yep i built one without threads problem disappears... Guess Alex> Ive just been out to lunch :) If it helps any, I've tracked down i

Re: [BUGS] plperl & sort

2008-11-06 Thread Alex Hunsaker
On Thu, Nov 6, 2008 at 06:41, Tom Lane <[EMAIL PROTECTED]> wrote: > "Alex Hunsaker" <[EMAIL PROTECTED]> writes: >> On Wed, Nov 5, 2008 at 18:03, Andrew Gierth <[EMAIL PROTECTED]> wrote: >>> Then explain why the problem goes away when you build perl with >>> threading turned off. > >> Hrm yep i buil

Re: [BUGS] plperl & sort

2008-11-06 Thread Tom Lane
"Alex Hunsaker" <[EMAIL PROTECTED]> writes: > On Wed, Nov 5, 2008 at 18:03, Andrew Gierth <[EMAIL PROTECTED]> wrote: >> Then explain why the problem goes away when you build perl with >> threading turned off. > Hrm yep i built one without threads problem disappears... Guess Ive > just been out to

Re: [BUGS] plperl & sort

2008-11-05 Thread Alex Hunsaker
On Wed, Nov 5, 2008 at 18:03, Andrew Gierth <[EMAIL PROTECTED]> wrote: >> "Alex" == Alex Hunsaker <[EMAIL PROTECTED]> writes: > > >> Hmm ... so then why are we seeing a failure? > > [...] > Alex> This is not a Safe bug IMHO its our (ab)use of it that is > Alex> causing the problem. > > Then

Re: [BUGS] plperl & sort

2008-11-05 Thread Andrew Gierth
> "Tom" == Tom Lane <[EMAIL PROTECTED]> writes: >> Nice theory, but completely wrong: sort creates $a and $b in the >> current package, not in main::. Tom> Hmm ... so then why are we seeing a failure? FWIW, I _don't_ see the failure. It seems to occur ONLY if perl was built with threading

Re: [BUGS] plperl & sort

2008-11-05 Thread Andrew Gierth
> "Alex" == Alex Hunsaker <[EMAIL PROTECTED]> writes: >> Hmm ... so then why are we seeing a failure? [...] Alex> This is not a Safe bug IMHO its our (ab)use of it that is Alex> causing the problem. Then explain why the problem goes away when you build perl with threading turned off. --

Re: [BUGS] plperl & sort

2008-11-05 Thread Alex Hunsaker
On Wed, Nov 5, 2008 at 11:14, Tom Lane <[EMAIL PROTECTED]> wrote: > Andrew Gierth <[EMAIL PROTECTED]> writes: >> Nice theory, but completely wrong: sort creates $a and $b in the >> current package, not in main::. > > Hmm ... so then why are we seeing a failure? Because Safe runs in a different nam

Re: [BUGS] plperl & sort

2008-11-05 Thread Alex Hunsaker
On Wed, Nov 5, 2008 at 10:54, Andrew Gierth <[EMAIL PROTECTED]> wrote: >> "nathan" == nathan wagner <[EMAIL PROTECTED]> writes: > > nathan> Completely untested speculation based on my knowledge of perl > nathan> and a bit of reading: > > nathan> The reason you can't see $a and $b is that sor

Re: [BUGS] plperl & sort

2008-11-05 Thread Tom Lane
Andrew Gierth <[EMAIL PROTECTED]> writes: > Nice theory, but completely wrong: sort creates $a and $b in the > current package, not in main::. Hmm ... so then why are we seeing a failure? regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) T

Re: [BUGS] plperl & sort

2008-11-05 Thread Andrew Gierth
> "nathan" == nathan wagner <[EMAIL PROTECTED]> writes: nathan> Completely untested speculation based on my knowledge of perl nathan> and a bit of reading: nathan> The reason you can't see $a and $b is that sort internally nathan> sets these variables in the main package. That is, sort i

Re: [BUGS] plperl & sort

2008-11-05 Thread Jeff
On Nov 4, 2008, at 4:43 PM, Andrew Dunstan wrote: OK, the first thing to note is that there is an easy workaround, which is to use a sort routine that doesn't need $a/$b. Example: create or replace function mysort() returns text language plperl as $f$ my $sfunc = sub ($$) { $_[

Re: [BUGS] plperl & sort

2008-11-04 Thread nathan wagner
Tom Lane wrote: Jeff <[EMAIL PROTECTED]> writes: I've ran into this interesting problem. It seems that while you can call sort() in a trusted plperl func you cannot access $a & $b which effectively makes it useless. I've tested this on 8.2.11, 8.3.5, and the nov 4 snapshot on ftp.postgresql

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 15:17, Andrew Dunstan <[EMAIL PROTECTED]> wrote: > > > Alex Hunsaker wrote: >> Err no you're right its only builtins that use main:: sort being the >> only one I know of off the top of my head... its a shame >> PLContainer->share('$main::a'); does not seem to work.. >> > > >

Re: [BUGS] plperl & sort

2008-11-04 Thread Andrew Dunstan
Alex Hunsaker wrote: On Tue, Nov 4, 2008 at 15:02, Alex Hunsaker <[EMAIL PROTECTED]> wrote: On Tue, Nov 4, 2008 at 14:43, Andrew Dunstan <[EMAIL PROTECTED]> wrote: But by all means if you can come up with a robust way of allowing the more traditional way of calling sort routines,

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 15:02, Alex Hunsaker <[EMAIL PROTECTED]> wrote: > On Tue, Nov 4, 2008 at 14:43, Andrew Dunstan <[EMAIL PROTECTED]> wrote: But by all means if you can come up with a robust way of allowing >> the more traditional way of calling sort routines, send it in. > > Well its not just

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 15:02, Alex Hunsaker <[EMAIL PROTECTED]> wrote: > The other idea Ive been toying this is instead of calling reval we can > just call Opcode::_safe_call_sv() something like the below: Argh gmail probably ate the whitespace in the patch... see attached plperl_safe.patch Des

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 14:43, Andrew Dunstan <[EMAIL PROTECTED]> wrote: > > We need to document that, and given that this exists I think we don't need > to backpatch old versions. Agreed. > Beyond that, we need to be very careful with any "solution" that we don't > upset the moderately fragile se

Re: [BUGS] plperl & sort

2008-11-04 Thread Andrew Dunstan
Alex Hunsaker wrote: On Tue, Nov 4, 2008 at 12:43, Alex Hunsaker <[EMAIL PROTECTED]> wrote: It has something to do with anon subs not sure what... It has to do with us returning the anonymous sub inside of the safe and then calling the function outside of the safe (or at least in a d

Re: [BUGS] plperl & sort

2008-11-04 Thread Jeff
On Nov 4, 2008, at 2:27 PM, Alex Hunsaker wrote: On Tue, Nov 4, 2008 at 09:02, Jeff <[EMAIL PROTECTED]> wrote: I've ran into this interesting problem. It seems that while you can call sort() in a trusted plperl func you cannot access $a & $b which effectively makes it useless. Hrm works f

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 12:43, Alex Hunsaker <[EMAIL PROTECTED]> wrote: > It has something to do with anon subs not sure what... It has to do with us returning the anonymous sub inside of the safe and then calling the function outside of the safe (or at least in a different namespace) we do someth

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 12:39, Tom Lane <[EMAIL PROTECTED]> wrote: > "Alex Hunsaker" <[EMAIL PROTECTED]> writes: >> Hrm works for me if I take out the elog from sort() > > Even more interesting, this variant *doesn't* work: > > regression=# create or replace function trustedsort() > returns int > as

Re: [BUGS] plperl & sort

2008-11-04 Thread Tom Lane
"Alex Hunsaker" <[EMAIL PROTECTED]> writes: > Hrm works for me if I take out the elog from sort() Even more interesting, this variant *doesn't* work: regression=# create or replace function trustedsort() returns int as $$ my @arr = qw(5 4 3 2 1); my @sorted = sort { "$a" <=> "$b" } @arr; elog(NOT

Re: [BUGS] plperl & sort

2008-11-04 Thread Alex Hunsaker
On Tue, Nov 4, 2008 at 09:02, Jeff <[EMAIL PROTECTED]> wrote: > I've ran into this interesting problem. > It seems that while you can call sort() in a trusted plperl func you cannot > access $a & $b which effectively makes it useless. Hrm works for me if I take out the elog from sort() create or

Re: [BUGS] plperl & sort

2008-11-04 Thread Tom Lane
Jeff <[EMAIL PROTECTED]> writes: > I've ran into this interesting problem. > It seems that while you can call sort() in a trusted plperl func you > cannot access $a & $b which effectively makes it useless. > I've tested this on 8.2.11, 8.3.5, and the nov 4 snapshot on > ftp.postgresql.org > In

[BUGS] plperl & sort

2008-11-04 Thread Jeff
I've ran into this interesting problem. It seems that while you can call sort() in a trusted plperl func you cannot access $a & $b which effectively makes it useless. I've tested this on 8.2.11, 8.3.5, and the nov 4 snapshot on ftp.postgresql.org In all cases its on a mac with perl 5.8.8. I a