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

From David G. Johnston
Subject Re: PostgreSQL 9.5 operator precedence
Date
Msg-id CAKFQuwbY1c1iUZGLzi5430tZN9==ozM7bh3uUXDfcbZ3KcRWew@mail.gmail.com
Whole thread Raw
In response to PostgreSQL 9.5 operator precedence  (Андрей Авакимов <aquarius1993@rambler.ru>)
Responses Re: PostgreSQL 9.5 operator precedence
List pgsql-sql
On Mon, Sep 19, 2016 at 11:02 PM, Андрей Авакимов <aquarius1993@rambler.ru> wrote:

Hello,
I've got a question about operator precedence is version 9.5

Versions lower than 9.5 worked well with constructions like
    select a is null = b is null
(it calculates if a is null, then if b is null and then compare two booleans)

But now everything is changed, and official 9.5 documentations says that
IS operator has lower precedence than = operator

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
                             ^
    HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

​Your query reads:

SELECT ( ( 1 IS (NULL = 2) ) IS NULL​
 
​)

So the error is in:

1 IS (NULL = 2)

which indeed is integer = boolean

David J.

pgsql-sql by date:

Previous
From: Андрей Авакимов
Date:
Subject: PostgreSQL 9.5 operator precedence
Next
From: Tom Lane
Date:
Subject: Re: PostgreSQL 9.5 operator precedence