Re: unnest on multi-dimensional arrays

From: Zev Benjamin <zev-pgsql(at)strangersgate(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: unnest on multi-dimensional arrays
Date: 2013-12-02 16:44:52
Message-ID: 529CB904.5080202@strangersgate.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the explanation and examples!

Zev

On 11/28/2013 10:03 AM, Tom Lane wrote:
> David Johnston <polobo(at)yahoo(dot)com> writes:
>> Zev Benjamin wrote
>>> It appears that unnest, when called on a multi-dimensional array,
>>> effectively flattens the array first. For example: ...
>
>> Multidimensional arrays do have shortcomings in the current implementation
>> of which this is one. I'm not sure, though, if there is anything
>> substantial and centralized in the docs so pertaining.
>
> It might be worth explaining that this is a consequence of the fact that
> Postgres treats all arrays over the same element type as being of the
> same data type --- that is, 1-D and 2-D arrays are not distinguished
> by the type system. Thus, when the polymorphic function "unnest(anyarray)
> returns setof anyelement" is applied to an integer array, it must return
> a series of integers; not a series of lower-dimensional arrays.
>
> There have been some discussions over whether this could be changed
> without a backwards-compatibility disaster, but nobody sees how.
>
> regards, tom lane
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2013-12-02 17:44:08 Re: Trust intermediate CA for client certificates
Previous Message Bruce Momjian 2013-12-02 16:41:10 Re: [GENERAL] pg_upgrade ?deficiency