Re: Precedence of standard comparison operators

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Precedence of standard comparison operators
Date: 2015-08-10 08:11:16
Message-ID: CAFj8pRBoxNgCTB7YJvbgdG4xSmh+zYQHvezQyL1DH3JAER_0Vw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-08-10 5:37 GMT+02:00 Noah Misch <noah(at)leadboat(dot)com>:

> On Sun, Aug 09, 2015 at 08:06:11PM -0400, Tom Lane wrote:
> > Noah Misch <noah(at)leadboat(dot)com> writes:
> > > In SQL:2008 and SQL:2011 at least, "=", "<" and "BETWEEN" are all in
> the same
> > > boat. They have no precedence relationships to each other; SQL
> sidesteps the
> > > question by requiring parentheses. They share a set of precedence
> > > relationships to other constructs. SQL does not imply whether to put
> them in
> > > one %nonassoc precedence group or in a few, but we can contemplate
> whether
> > > users prefer an error or prefer the 9.4 behavior for affected queries.
> >
> > Part of my thinking was that the 9.4 behavior fails the principle of
> least
> > astonishment, because I seriously doubt that people expect '=' to be
> > either right-associative or lower priority than '<'. Here's one example:
> >
> > regression=# select false = true < false;
> > ?column?
> > ----------
> > t
> > (1 row)
>
> > So yeah, I do think that getting a syntax error if you don't use
> > parentheses is the preferable behavior here.
>

If we raise a syntax error, then there should be very informative message,
because pattern

true = 2 > 1 is probably relative often

and it is hard to find syntax error on this trivial expression

Regards

Pavel

>
> I agree.
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-08-10 08:17:14 Re: Summary of plans to avoid the annoyance of Freezing
Previous Message Ashutosh Bapat 2015-08-10 08:10:46 Re: Commitfest remaining "Needs Review" items