Re: PL/pgSQL 'i = i + 1' Syntax

Поиск
Список
Период
Сортировка
От Mark Dilger
Тема Re: PL/pgSQL 'i = i + 1' Syntax
Дата
Msg-id 446D0FE7.4090203@markdilger.com
обсуждение исходный текст
Ответ на Re: PL/pgSQL 'i = i + 1' Syntax  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: PL/pgSQL 'i = i + 1' Syntax
Re: PL/pgSQL 'i = i + 1' Syntax
Список pgsql-hackers
Tom Lane wrote:
> Josh Berkus <josh@agliodbs.com> writes:
> 
>>>True, but there were clear benefits from doing so.  Disallowing "="
>>>assignment in plpgsql wouldn't buy anything, just break programs.
> 
> 
>>But it's already disallowed in most places.
> 
> 
> No it isn't.  The plpgsql scanner treats := and = as *the same token*.
> They can be interchanged freely.  This has nothing to do with the case
> of modifying a loop variable in particular.

I disagree.  If the scanner treated them the same, then
 if i := 1 then ...

would work, but it doesn't.  The := is rejected in a conditional.  Try the
following code if you don't believe me:

CREATE OR REPLACE FUNCTION foo () RETURNS INTEGER AS $$
DECLARE   i integer;
BEGIN   i := 1;   if i := 1 then       return 1;   end if;   return 0;
END;
$$ LANGUAGE plpgsql;


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mark Dilger
Дата:
Сообщение: text_position worst case runtime
Следующее
От: Robert Treat
Дата:
Сообщение: Re: [OT] MySQL is bad, but THIS bad?