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

From Tom Lane
Subject Re: PL/pgSQL 'i = i + 1' Syntax
Date
Msg-id 19568.1147875099@sss.pgh.pa.us
Whole thread Raw
In response to Re: PL/pgSQL 'i = i + 1' Syntax  ("Andrew Dunstan" <andrew@dunslane.net>)
Responses Re: PL/pgSQL 'i = i + 1' Syntax
Re: PL/pgSQL 'i = i + 1' Syntax
List pgsql-hackers
"Andrew Dunstan" <andrew@dunslane.net> writes:
> Albe Laurenz said:
>> ERROR at line 3:
>> ORA-06550: line 3, column 7:
>> PLS-00363: expression 'I' cannot be used as an assignment target
>> ORA-06550: line 3, column 7:
>> PL/SQL: Statement ignored
>> 
>> And the documentation also explicitly states that it is not allowed.

> So should we if it can be done conveniently. That might be a big IF - IIRC
> many Pascal compilers ignore the similar language rule because implementing
> it is a pain in the neck.

Since we already have the notion of a "const" variable in plpgsql,
I think it might work to just mark the loop variable as const.

>> By the way, PL/SQL screams if you want to do an assignment with '='.
>> But I guess that the current behaviour of PL/pgSQL should not reflect
>> that to maintain backward compatibility, right?

> I think it should. The current behaviour is undocumented and more than icky.

The lack of documentation is easily fixed ;-).  I don't think this is
icky enough to justify breaking all the existing functions we'd
undoubtedly break if we changed it.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: What default is - SET behavior
Next
From: Cristiano Duarte
Date:
Subject: Re: [BUGS] BUG #2429: Explain does not report object's schema