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

Re: plperl & sort

From: Jeff <threshar(at)torgo(dot)978(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Alex Hunsaker <badalex(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff <threshar(at)threshar(dot)is-a-geek(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: plperl & sort
Date: 2008-11-05 14:16:26
Message-ID: 0398C703-6CF4-438A-810D-ACDBDAA7A146@torgo.978.org (view raw or flat)
Thread:
Lists: pgsql-bugs
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 ($$) { $_[0] <=> $_[1] };
>
>       my @vals = (5,3,4,2,7);
>
>       return join(' ',sort $sfunc @vals);
>
>   $f$;
>

Andrew for the win!

Thanks a lot!

I agree, a documentation note would be fine for this rather doing all  
sorts of complicated perl trickery.

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




In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-11-05 15:33:16
Subject: Re: BUG #4510: memory leak with libpg.dll
Previous:From: Hiroshi SaitoDate: 2008-11-05 14:06:10
Subject: Re: [ODBC] Behavior change of FK info query

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