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

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: plpgsql - "for in array" statement
Date: 2010-09-28 20:32:50
Message-ID: 28428.1285705970@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> 2010/9/28 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> As an example, is this a for-in-query or a
>> for-in-array?
>> 
>>    FOR v IN (SELECT arraycol FROM tab) LOOP ...

> This is a subquery - so it is a for-in-array - should return one row
> with one column.

That's not obvious at all.  It's legal right now to write that, and it
will be interpreted as for-in-query.  Furthermore, there are cases where
it's essential to be able to write a left paren before SELECT, so that
you can control the precedence of UNION/INTERSECT/EXCEPT constructs.
So you're proposing to remove functionality and break existing code in
order to have a "simple" syntax for for-in-array.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2010-09-28 20:37:57
Subject: Re: Proposal: plpgsql - "for in array" statement
Previous:From: Pavel StehuleDate: 2010-09-28 20:24:30
Subject: Re: Proposal: plpgsql - "for in array" statement

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