Re: Array behavior oddities - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: Array behavior oddities
Date
Msg-id 874pdfhxqx.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: Array behavior oddities  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Array behavior oddities  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
"Bruce Momjian" <bruce@momjian.us> writes:

> Tom Lane wrote:
>> Why do you find that surprising?  It's either a slice or it isn't,
>> there's no halfway point.  Are you proposing to throw an error if only
>> some of the subscripts have colons?  What would be the point?
>
> What is confusing is if I see [1:3][2], I assume that is [1:3][2:2], not
>  [1:3][1:2].  By what logic does [2] mean from 1 to 2?

Here's something else which confused me just now. Why does the second query
return NULL instead of an array slice?

postgres=# select (array['{foo}'::text[],'{bar}'])[1][1];array 
-------foo
(1 row)

postgres=# select (array['{foo}'::text[],'{bar}'])[1];array 
-------
(1 row)


--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's PostGIS support!


pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Declarative partitioning grammar
Next
From: Yoshiyuki Asaba
Date:
Subject: ts_headline() dumps core