Re: Precedence of standard comparison operators

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Precedence of standard comparison operators
Дата
Msg-id 23431.1424451893@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Precedence of standard comparison operators  (Kevin Grittner <kgrittn@ymail.com>)
Ответы Re: Precedence of standard comparison operators  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
Kevin Grittner <kgrittn@ymail.com> writes:
> I have a memory of running into this in real-world production code
> and that it involved booleans.  I'll see whether I posted something
> to the community lists about it, but it didn't take long to produce
> an (admittedly artificial) case where incorrect results are
> silently returned:

> test=# select 'f'::boolean = 'f'::boolean >= 'f'::boolean;
> ?column? 
> ----------
> f
> (1 row)

> test=# select 'f'::boolean >= 'f'::boolean >= 'f'::boolean;
> ?column? 
> ----------
> t
> (1 row)

One of the reasons I want to make these operators %nonassoc is
so you get an error on cases like these --- if you actually meant
this, you'll be forced to parenthesize one way or the other.
        regards, tom lane



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

Предыдущее
От: Kevin Grittner
Дата:
Сообщение: Re: Precedence of standard comparison operators
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: Precedence of standard comparison operators