Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?) - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)
Date
Msg-id AANLkTinnF3U20M8inZy_1GWZTayMDu3mH1XuSpgm9mrM@mail.gmail.com
Whole thread Raw
In response to Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Dec 17, 2010 at 12:15 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Merlin Moncure <mmoncure@gmail.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


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)
Next
From: Andrew Dunstan
Date:
Subject: Re: proposal: FOREACH-IN-ARRAY (probably for 9.2?)