PL/pgSQL 'i = i + 1' Syntax - Mailing list pgsql-hackers

From David Wheeler
Subject PL/pgSQL 'i = i + 1' Syntax
Date
Msg-id 0EA30263-51D2-4620-860D-82F2E83C3E42@kineticode.com
Whole thread Raw
Responses Re: PL/pgSQL 'i = i + 1' Syntax  (Andrew Dunstan <andrew@dunslane.net>)
Re: PL/pgSQL 'i = i + 1' Syntax  (Mark Dilger <pgsql@markdilger.com>)
List pgsql-hackers
Hellow PostgreSQL hackers,

Quick question. Why does the 'i = i + 1' syntax work in this PL/pgSQL  
function?

try=# CREATE OR REPLACE FUNCTION inc_by_two(
try(#    upfrom int,
try(#    upto   int
try(# ) RETURNS SETOF INT AS $$
try$# BEGIN
try$#     FOR i IN upfrom..upto LOOP
try$#         RETURN NEXT i;
try$#         i = i + 1;
try$#     END LOOP;
try$# END;
try$# $$ LANGUAGE 'plpgsql';
CREATE FUNCTION
try=# select * from inc_by_two(1,10);
inc_by_two
------------          1          3          5          7          9
(5 rows)

Someone posted a PL/pgSQL function in my blog with this syntax, which  
is how I know about it, but I couldn't find it documented anywhere.  
Is it a special exception for loop variables, perhaps?

Thanks,

David


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Compression and on-disk sorting
Next
From: Andrew Dunstan
Date:
Subject: Re: PL/pgSQL 'i = i + 1' Syntax