Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)
Date: 2010-12-17 17:21:35
Message-ID: AANLkTinnF3U20M8inZy_1GWZTayMDu3mH1XuSpgm9mrM@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 17, 2010 at 12:15 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
>> another way:
>
>> FOREACH scalar IN ARRAY arr_exp DIMS in dim_var
>
>> dim_var being int[], or possibly text, of length #dimensions, giving
>> per dimesion index.
>
> [ scratches head... ]  I don't follow what you envision this doing,
> exactly?
>
> I'm not thrilled with that specific syntax because it'd require making
> DIMS a reserved word, but right at the moment I'm more concerned about
> what semantics you have in mind.

It's like _pg_expandarray but alterted support multiple dimensions:

select * from unnest_dims(array[['a','b'],['c','d']]) returns
[1,1], 'a'
[1,2], 'b'
[2,1], 'c'
[2,2], 'd'

this provides alternate way of pulling slices, slower possibly, but
more abstract.

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2010-12-17 17:23:32 Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)
Previous Message Pavel Stehule 2010-12-17 17:15:57 Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)