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

plperl & sort

From: Jeff <threshar(at)torgo(dot)978(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: plperl & sort
Date: 2008-11-04 16:02:29
Message-ID: 99F73E49-8BAE-4362-8593-3B1C9D88AE79@torgo.978.org (view raw or flat)
Thread:
Lists: pgsql-bugs
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 also tested on Linux with 8.2.5 (yes yes, I know I need to upgrade!)  
with the same results.

Is this intended behavior?


create or replace function trustedsort()
returns int
as $$

my @arr = (5, 4, 3, 2, 1);

my @sorted = sort { elog(NOTICE, "$a $b"); $a <=> $b } @arr;

return 1;

$$
language 'plperl';

create or replace function untrustedsort()
returns int
as $$

my @arr = (5, 4, 3, 2, 1);

my @sorted = sort { elog(NOTICE, "$a $b"); $a <=> $b } @arr;

return 1;

$$
language 'plperlu';


select trustedsort();
select untrustedsort();

drop function trustedsort();
drop function untrustedsort();

----

CREATE FUNCTION
CREATE FUNCTION
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
psql:stupid_plperl.sql:28: NOTICE:
  trustedsort
-------------
            1
(1 row)

psql:stupid_plperl.sql:29: NOTICE:  5 4
psql:stupid_plperl.sql:29: NOTICE:  3 2
psql:stupid_plperl.sql:29: NOTICE:  4 2
psql:stupid_plperl.sql:29: NOTICE:  4 3
psql:stupid_plperl.sql:29: NOTICE:  2 1
  untrustedsort
---------------
              1
(1 row)

DROP FUNCTION
DROP FUNCTION

--
Jeff Trout <jeff(at)jefftrout(dot)com>
http://www.stuarthamm.net/
http://www.dellsmartexitin.com/




Responses

pgsql-bugs by date

Next:From: Dave PageDate: 2008-11-04 16:39:55
Subject: Re: Behavior change of FK info query
Previous:From: Craig RingerDate: 2008-11-04 15:40:57
Subject: Re: Behavior change of FK info query

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