Re: Multi-dimensional arrays

From: Thom Brown <thom(at)linux(dot)com>
To: rod <rod(at)iol(dot)ie>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multi-dimensional arrays
Date: 2014-03-15 14:01:42
Message-ID: CAA-aLv5yMtK_TrNarGfHjnNmUnxGfaxNJCWO0Q=A7c9Y_j2Z=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15 March 2014 12:51, Raymond O'Donnell <rod(at)iol(dot)ie> wrote:
> Hello all,
>
> Here's an odd one (to me anyway) which I ran into today.... if I have a
> multidimensional array, why does the following return NULL?
>
> select (array[['abc','def'], ['ghi','jkl']])[1]
>
> I would have expected it to return {abc, def}. This, however, returns
> 'abc' as expected:
>
> select (array[['abc','def'], ['ghi','jkl']])[1][1]

Hmm... I'm not sure. You can get to it with slices for some reason:

# select (array[['abc','def'], ['ghi','jkl']])[0:1];
array
-------------
{{abc,def}}
(1 row)

# select (array[['abc','def'], ['ghi','jkl']])[1:2];
array
-----------------------
{{abc,def},{ghi,jkl}}
(1 row)

# select (array[['abc','def'], ['ghi','jkl']])[2:3];
array
-------------
{{ghi,jkl}}
(1 row)

--
Thom

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Olivier Chaussavoine 2014-03-15 14:39:49 pg_worker and notify
Previous Message Yngve N. Pettersen 2014-03-15 13:53:19 Re: Possible multiprocess lock/unlock-loop problem in Postgresql 9.2