Skip site navigation (1) Skip section navigation (2)

Re: plperl: sort trapped by operation mask

From: David Fetter <david(at)fetter(dot)org>
To: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: plperl: sort trapped by operation mask
Date: 2005-10-06 01:11:34
Message-ID: 20051006011134.GA7542@fetter.org (view raw or flat)
Thread:
Lists: sfpug
On Wed, Oct 05, 2005 at 05:56:25PM -0700, Reece Hart wrote:
> I'm getting 'sort trapped by operation mask' from plperl in postgresql
> 7.4.8.  I understand what this message means, but can some one out
> there tell me why sort is privileged?  Or, is it just untrusted in
> the context of s///e ?

It's untrusted in the context of s///e.

> The relevant code snippet will be hard to understand, but it is:
> 
> s(at)\\[([^\\]]+)\\](at){my %aa=map {$_=>1} split(//,$1); "[".join("",sort
> keys %aa)."]"}(at)eg; 
> 
> This works fine when 'sort' is removed.

Zoiks!  Could you do the 

"[" . join("", sort keys %aa) . "]"

after regex?

WARNING untested code:

my $NOT_RIGHT_BRACKET = qr([^\\]]+); # parse as regex 1st.
s@
    \\[($NOT_RIGHT_BRACKET)\\]
 @
    "[" .
    join("", sort {$a cmp $b} (split(//, $1)) ) .
    "]"
 @egmx;

HTH :)

Cheers,
D
-- 
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

In response to

Responses

sfpug by date

Next:From: Jeff FrostDate: 2005-10-06 02:25:56
Subject: order of performance
Previous:From: Reece HartDate: 2005-10-06 00:56:25
Subject: plperl: sort trapped by operation mask

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group