Re: PostgreSQL 9.5 operator precedence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Андрей Авакимов <aquarius1993(at)rambler(dot)ru>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: PostgreSQL 9.5 operator precedence
Date: 2016-09-20 14:47:50
Message-ID: 20513.1474382870@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Mon, Sep 19, 2016 at 11:02 PM, <aquarius1993(at)rambler(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Moore 2016-09-22 21:42:56 insert values from a ROW object
Previous Message David G. Johnston 2016-09-20 14:10:58 Re: PostgreSQL 9.5 operator precedence