Re: final patch - plpgsql: for-in-array

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: final patch - plpgsql: for-in-array
Date: 2010-11-24 07:46:09
Message-ID: AANLkTik9RjMN9sRUEMaGiyi_KmRxr9cj6XhJY9YfaM1K@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

sorry, there was a broken message

2010/11/24 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> 2010/11/24 Robert Haas <robertmhaas(at)gmail(dot)com>:
>> On Tue, Nov 23, 2010 at 8:56 PM, Cédric Villemain
>> <cedric(dot)villemain(dot)debian(at)gmail(dot)com> wrote:
>>> 2010/11/23 Robert Haas <robertmhaas(at)gmail(dot)com>:
>>>> On Mon, Nov 22, 2010 at 11:55 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>>>>> ok, I can only recapitulate so this feature was proposed cca two
>>>>> months ago, and minimally Tom and maybe you did agreement - with
>>>>> request on syntax - do you remember? I am little bit tired so this
>>>>> agreement was changed when I spent my time with this.
>>>>
>>>> I went back and reread the thread I believe you're speaking about.
>>>> The first post is here:
>>>>
>>>> http://archives.postgresql.org/pgsql-hackers/2010-09/msg01945.php
>>>
>>> Here perhaps ? (or before)
>>>
>>> http://archives.postgresql.org/pgsql-hackers/2010-09/msg01983.php
>>
>> Dang.  You're right.  I stand corrected.
>>
>
> Sorry, I though so you and Tom hasn't a problem with syntax
> FOR-IN-ARRAY (what is a Kevin Grittner's proposal). So problematic is
> just my original proposal FOR-IN-expr, but proposed feature isn't
> rejected.
>

Sorry, I though so you and Tom hasn't a problem with syntax
FOR-IN-ARRAY (what is a Kevin Grittner's proposal). I though so
problematic is just my original proposal FOR-IN-expr, but proposed
feature isn't a problem.

My proposal isn't really genial - is true so first my motivation was
to replace unwished pattern "array_lower(var,1)..array_upper(var,1)".
It's relative simple in ADA, where statement FOR is defined over range
type, and relative impossible in PL/pgSQL, where range type doesn't
exists yet. Some special construct in PL/pgSQL can to solve iteration
over array significantly better and simpler then any other solution -
there must not be used the syntax FOR-IN-ARRAY - with any next test
and next code checking I am more sure:

why?:
* there is clean indicia so developer wants to process all items in
array, or almost all
* there isn't random access to array!!
* is possibility for a reuse varlena's value stored in array without a
temporal copy - with maybe some trick!!
* there is a very low overhead

I am sorry, so I didn't speaking about these advices early.

I though about other possible syntax - what do you think about "FOR
var OVER expr LOOP ... END LOOP" ? "OVER" is keyword now

Regards

Pavel
>> --
>> Robert Haas
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shigeru HANADA 2010-11-24 09:58:46 Re: SQL/MED estimated time of arrival?
Previous Message Pavel Stehule 2010-11-24 07:43:32 Re: final patch - plpgsql: for-in-array