Re: PL/pgSQL loops? - Mailing list pgsql-sql

From Tom Lane
Subject Re: PL/pgSQL loops?
Date
Msg-id 19090.1007053375@sss.pgh.pa.us
Whole thread Raw
In response to Re: PL/pgSQL loops?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: PL/pgSQL loops?
List pgsql-sql
Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> In addition, this seems to work:
> for intvar in 1 .. (select max(a) from a) LOOP
> and this doesn't:
> for intvar in 1 .. (select max(loop) from a) LOOP
> and this does:
> for intvar in (select max(loop) from a) .. 1 LOOP

> I'm guessing that plpgsql doesn't want to try to determine if
> an expression is valid and so just concats stuff to pass off,

Correct ...

> but that seems to mean that you need to double quote loop in
> the second (which is somewhat unobvious).

I would've expected it to count nested parentheses, at least.
A quick look makes it appear that some places in plpgsql's
gram.y do, and some don't.  Ugh.
        regards, tom lane


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: PL/pgSQL loops?
Next
From: Peter Eisentraut
Date:
Subject: Re: date_part vs extract