Re: array_length(anyarray)

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Florian Pflug <fgp(at)phlo(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, PostGreSql hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_length(anyarray)
Date: 2014-01-10 10:00:40
Message-ID: CAHyXU0wu81O8ypkC6+2e_OH0bJgDFfvJtrsKaRRtEmCreZ+xeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 10, 2014 at 3:52 AM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
> On 1/10/14, 10:41 AM, Merlin Moncure wrote:
>>
>> What's needed for better iteration support (IMO)
>> is a function that does what unnest does but returns an array on
>> indexes (one per dimsension) -- a generalization of the
>> _pg_expandarray function. Lets' say 'unnest_dims'.
>
>
> So unnest_dims('{{1,2},{3,4}}'::int[]) would return VALUES (1,
> '{1,2}'::int[]), (2, '{3,4}'::int[])? If so, then yes, that's a
> functionality I've considered us to have been missing for a long time.

not quite. it returns int[], anyelement: so, using your example, you'd get:

[1,1], 1
[1,2], 2
[2,1], 3
[2,2], 4

like unnest() it would fully decompose the array do individual
elements. what you have above slices the array which is useful,but
probably shouldn't live under the 'unnest' name -- perhaps 'slice'.
Pavel added it to pl/pgsql under the FOREACH syntax (FYI).

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gabriele Bartolini 2014-01-10 11:25:52 Re: [PATCH] Relocation of tablespaces in pg_basebackup
Previous Message Marko Tiikkaja 2014-01-10 09:52:21 Re: array_length(anyarray)