From: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: hstore improvements? |
Date: | 2009-03-13 21:31:23 |
Message-ID: | ADD28245-5B7B-465D-B2B0-69689F4C6920@kineticode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mar 13, 2009, at 2:26 PM, Andrew Gierth wrote:
> David> Is a more Perlish syntax out of the question?
>
> Yes. Sorry.
>
> David> SELECT ('a=>1,b=>2,c=>3'::hstore)['a', 'b'];
> David> -- returns '{1,2}'
>
> That would require integrating hstore into core - array subscripting
> isn't a user-definable operation.
>
> David> select ('a=>1,b=>2,c=>3'::hstore){'a','b'};
> David> -- returns 'a=>1,b=>2'
>
> And that would require changing the parser...
How functionS, then?
SELECT slice(('a=>1,b=>2,c=>3'::hstore), ARRAY['a', 'b']);
-- returns '{1,2}'
SELECT hslice(('a=>1,b=>2,c=>3'::hstore), ARRAY['a','b']);
-- returns 'a=>1,b=>2'
Better names welcome, of course. But there isn't even a slice
interface for array, is there?
SELECT slice(ARRAY[ 'a', 'b', 'c' ], ARRAY[1, 3]);
-- returns '{a,c}'
Best,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-03-13 21:35:29 | Re: hstore improvements? |
Previous Message | Andrew Gierth | 2009-03-13 21:26:51 | Re: hstore improvements? |