agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Андрей Авакимов <aquarius1993@rambler.ru>
To: pgsql-sql@postgresql.org
Subject: PostgreSQL 9.5 operator precedence
Date: Tue, 20 Sep 2016 09:02:44 +0300
Message-ID: <1474351364.271814.29325.2780@mail.rambler.ru> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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

view thread (3+ messages)  latest in thread

Message-ID: <1474351364.271814.29325.2780@mail.rambler.ru>
Permalink:  ../1474351364.271814.29325.2780@mail.rambler.ru/
Also on:    postgresql.org/message-id/1474351364.271814.29325.2780@mail.rambler.ru

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: aquarius1993@rambler.ru
  Subject: Re: PostgreSQL 9.5 operator precedence
  In-Reply-To: <1474351364.271814.29325.2780@mail.rambler.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox