Re: final patch - plpgsql: for-in-array - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: final patch - plpgsql: for-in-array
Date
Msg-id AANLkTi=iEY3OtWwEe+JgXBTb88rTnQyLNRmxXncbsip6@mail.gmail.com
Whole thread Raw
In response to Re: final patch - plpgsql: for-in-array  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: final patch - plpgsql: for-in-array
List pgsql-hackers
2010/11/18 Tom Lane <tgl@sss.pgh.pa.us>:
> Merlin Moncure <mmoncure@gmail.com> writes:
>> On Wed, Nov 17, 2010 at 7:08 PM, Jaime Casanova <jaime@2ndquadrant.com> wrote:
>>> i will start the review of this one... but before that sorry for
>>> suggesting this a bit later but about using UNNEST as part of the
>>> sintax?
>
>> Does for-in-array do what unnset does?
>
> Yes, which begs the question of why bother at all.  AFAICS this patch
> simply allows you to replace
>
>        for x in select unnest(array_value) loop
>
> with
>
>        for x in unnest array_value loop
>
> (plus or minus a parenthesis or so).  I do not think we need to add a
> bunch of code and create even more syntactic ambiguity (FOR loops are
> already on the hairy edge of unparsability) to save people from writing
> "select".

this patch is semantically equal to SELECT unnest(..), but it is
evaluated as simple expression and does directly array unpacking and
iteration, - so it means this fragment is significantly >>faster<<.

Regards

Pavel Stehule

>
>                        regards, tom lane
>


pgsql-hackers by date:

Previous
From: Stuart Bishop
Date:
Subject: Re: Indent authentication overloading
Next
From: Shigeru HANADA
Date:
Subject: Unused parameter in vacuum.c