Re: Some questions about the array. - Mailing list pgsql-hackers

From Vitaly Burovoy
Subject Re: Some questions about the array.
Date
Msg-id CAKOSWNk-+=QDn-7VH6ROex=t9fKyb8Q5ATxcQNQRfbkbtM6UKw@mail.gmail.com
Whole thread Raw
In response to Re: Some questions about the array.  (YUriy Zhuravlev <u.zhuravlev@postgrespro.ru>)
Responses Re: Some questions about the array.  (YUriy Zhuravlev <u.zhuravlev@postgrespro.ru>)
List pgsql-hackers
On 11/9/15, YUriy Zhuravlev <u.zhuravlev@postgrespro.ru> wrote:
> On Monday 09 November 2015 12:48:54 you wrote:
>> I am sorry - it is looking pretty obscure. Really need this feature?
>
> IMHO yes.
> Now for write: array[~2:~-2] you need like:
> array[array_lower(array, 1)+3: array_upper(array, 1)-2]
>
> Worse when long names. Besides the extra functions calls.

You can write it as a separate function instead of changing current syntax.
Call would be like :
SELECT slice_abs('[-3:3]={1,2,3,4,5,6,7}'::int[], 2, -2)  == {3,4,5,6}
SELECT slice_abs('[-3:3]={1,2,3,4,5,6,7}'::int[], 2, NULL)  ==
{3,4,5,6,7}  -- omitting boundaries
-- 
Best regards,
Vitaly Burovoy



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Some questions about the array.
Next
From: YUriy Zhuravlev
Date:
Subject: Re: Some questions about the array.