Re: hstore improvements?

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: hstore improvements?
Дата
Msg-id ADD28245-5B7B-465D-B2B0-69689F4C6920@kineticode.com
обсуждение исходный текст
Ответ на Re: hstore improvements?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: hstore improvements?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: hstore improvements?