From: | Reece Hart <reece(at)harts(dot)net> |
---|---|
To: | SF PostgreSQL <sfpug(at)postgresql(dot)org> |
Subject: | Re: plperl: sort trapped by operation mask |
Date: | 2005-10-06 02:31:52 |
Message-ID: | 1128565912.4293.16.camel@whoville.homelinux.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
On Wed, 2005-10-05 at 18:11 -0700, David Fetter wrote:
> It's untrusted in the context of s///e.
...
> my $NOT_RIGHT_BRACKET = qr([^\\]]+); # parse as regex 1st.
> s@
> \\[($NOT_RIGHT_BRACKET)\\]
> @
> "[" .
> join("", sort {$a cmp $b} (split(//, $1)) ) .
> "]"
> @egmx;
David-
Kudos for digesting (and cleaning up) my obfuscated perl.
The code is intended to sort tokens within [] sets in a regexp. My
primary motivation is a canonical form for such regexps. For example, I
want A[BCBB][DEE] to become A[BC][DE]. The sort is required to get the
canonical ordering within []. (David's code is close to equivalent, but
without hashing tokens inside [], it won't compress multiple instances
of the same token.)
The problem is that sort apparently requires an untrusted language.
Example:
=> create or replace function sort_test() returns text
strict immutable language plperl as '
my @x = qw(c b a);
return join("",sort @x);
';
=> select sort_test();
ERROR: creation of function failed: 'sort' trapped by operation mask at (eval 10) line 3.
The same function defined with plperlu (untrusted) works fine.
Surely I'm not the first one to try sort in a plperl function. And I
can't think of any reason for sort to require a trusted language.
I don't see anything specifically about sort and plperl/plperlu on the
web. Enlightenment, anyone?
Thanks,
Reece
--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0
From | Date | Subject | |
---|---|---|---|
Next Message | Reece Hart | 2005-10-06 02:41:38 | Re: plperl: sort trapped by operation mask |
Previous Message | Jeff Frost | 2005-10-06 02:25:56 | order of performance |