PostgreSQL 9.5 operator precedence

From: Андрей Авакимов <aquarius1993(at)rambler(dot)ru>
To: pgsql-sql(at)postgresql(dot)org
Subject: PostgreSQL 9.5 operator precedence
Date: 2016-09-20 06:02:44
Message-ID: 1474351364.271814.29325.2780@mail.rambler.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

For me it means that postgres calculated value in the left side of the =
operator, then it decided not to calculate right side and compare boolean and
integer.
Why did it not compare null and 2 firstly?
Maybe the truth is IS operator and = operator has the same precedence, and then
calculated from left to right?
Maybe I miss something?

Best Regards,
Andrew

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2016-09-20 14:10:58 Re: PostgreSQL 9.5 operator precedence
Previous Message Andreas Kretschmer 2016-08-27 09:42:21 Re: error-org.postgresql.Driver for 9.5.3 postgres version