Skip site navigation (1) Skip section navigation (2)

Re: Proposal: plpgsql - "for in array" statement

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: plpgsql - "for in array" statement
Date: 2010-09-28 19:48:36
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
2010/9/28 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
>>>>> FOR var IN [array variable | array expression]
>>>>> LOOP
>> How about distinguishing it this way:?
>> FOR var IN ARRAY array_expression LOOP

I see one problem - when you can use a constant array, then you will
write two keywords ARRAY


iteration over cursor is supported now, and you don't write

FOR var IN CURSOR cursorvar

> That occurred to me too, but it's got a small problem: it's not
> impossible for ARRAY to be the first token of a valid scalar expression.


> But I guess you could get around that if you had to by putting the ARRAY
> expression inside parens, and it would be a pretty darn unusual case
> anyway.  So this is probably the best choice.

I don't agree - There isn't reason for complicating proposed syntax.
The situation is relative simple and we are able to print a correct


Pavel Stehule

I'm not thrilled with
> David's suggestions of using FOREACH or ITERATE --- using a different
> initial keyword makes it awkward to make generic statements about "all
> types of FOR loop".
>                        regards, tom lane

In response to


pgsql-hackers by date

Next:From: Massa, Harald ArminDate: 2010-09-28 20:02:39
Subject: Re: documentation udpates to pgupgrade.html
Previous:From: Pavel StehuleDate: 2010-09-28 19:41:16
Subject: Re: Proposal: plpgsql - "for in array" statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group