Re: Precedence of standard comparison operators - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Precedence of standard comparison operators
Date
Msg-id 23431.1424451893@sss.pgh.pa.us
Whole thread Raw
In response to Re: Precedence of standard comparison operators  (Kevin Grittner <kgrittn@ymail.com>)
Responses Re: Precedence of standard comparison operators
List 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 by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: Precedence of standard comparison operators
Next
From: Kevin Grittner
Date:
Subject: Re: Precedence of standard comparison operators