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

From Andrew Dunstan
Subject Re: Some questions about the array.
Date
Msg-id 5617DCC6.9080605@dunslane.net
Whole thread Raw
In response to Some questions about the array.  (YUriy Zhuravlev <u.zhuravlev@postgrespro.ru>)
Responses Re: Some questions about the array.  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
List pgsql-hackers

On 10/09/2015 08:02 AM, YUriy Zhuravlev wrote:
> We were some of the issues associated with the behavior of arrays.
> 1. We would like to implement arrays negative indices (from the end) like in
> Python or Ruby: arr[-2]  or arr[1: -1]
> but as an array can be indexed in the negative area so it probably can not be
> done.
> 2. We would like to add the ability be omitted boundaries in the slice.
> Example: arr[2:] or arr[:2]. But there was a problem with the update of an
> empty array:
> arr[1:][1:] = {1,2,3,4,5,6} can be interpreted as
> arr[1:3][1:2] or arr[1:2] [1:3] or [1:1], [1:6]
>
> What is the history of the emergence of such arrays? Maybe something can be
> improved?
>
> P.S. I would like List datatype as in Python.  Is there any fundamental
> objections? Or we just did not have the time and enthusiasm before?
> The current implementation I would call vectors or matrices but not arrays.
> IMHO
>
>

The name array is now far too baked in to change it.

jsonb and json arrays have many of the characteristics you seem to want. 
They are always 0-based and negative indexes count from the end. They 
also don't have to be regular, unlike our native arrays.

cheers

andrew



pgsql-hackers by date:

Previous
From: Anastasia Lubennikova
Date:
Subject: Re: WIP: Covering + unique indexes.
Next
From: Alvaro Herrera
Date:
Subject: Re: pg_ctl/pg_rewind tests vs. slow AIX buildfarm members