Re: PostgreSQL 9.5 operator precedence - Mailing list pgsql-sql

From Tom Lane
Subject Re: PostgreSQL 9.5 operator precedence
Date
Msg-id 20513.1474382870@sss.pgh.pa.us
Whole thread Raw
In response to Re: PostgreSQL 9.5 operator precedence  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Sep 19, 2016 at 11:02 PM, Андрей Авакимов <aquarius1993@rambler.ru>
>> The thing I don't understand is the error message that I receive:
>> select 1 is null = 2 is null;
>> -----------------------------
>> ERROR:  operator does not exist: boolean = integer
>> LINE 1: select 1 is null = 2 is null

> ​Your query reads:
> SELECT ( ( 1 IS (NULL = 2) ) IS NULL​

No, certainly not that --- IS isn't some sort of standalone operator,
rather IS NULL is an indivisible combination of tokens representing a
postfix operator.  The query's really getting parsed like this:

select ((1 is null) = 2) is null;

whereas the pre-9.5 interpretation was

select (1 is null) = (2 is null);

If you add those parentheses explicitly then your query will work fine
in either version.
        regards, tom lane



pgsql-sql by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: PostgreSQL 9.5 operator precedence
Next
From: Michael Moore
Date:
Subject: insert values from a ROW object