Re: BUG #3822: Nonstandard precedence for comparison operators

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "Pedro Gimeno" <pgsql-001(at)personal(dot)formauri(dot)es>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3822: Nonstandard precedence for comparison operators
Date: 2007-12-27 22:22:10
Message-ID: 21242.1198794130@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> That said, bringing PostgreSQL into compliance with the standard
> would undoubtedly break some people's existing applications.

The spec seems to barely have a notion of operator precedence at all ---
for example, all the variants of <predicate> are at the same precedence
level, and if I'm reading it right they actively disallow ambiguous
cases by requiring parentheses; note the way that <boolean primary>
is defined. This entire arrangement breaks down as soon as you consider
user-defined operators that yield boolean results. So I'm not
particularly excited about the idea of slavish compliance with the spec
in this area.

To the extent that you do believe the spec, there are more problems with
our precedence rules than just where <= fits --- it looks to me like IS
[NOT] NULL is at the wrong precedence, too. And then there's the whole
question of associativity.

> It seems to call for the same phased approach as the standard
> conforming string literals, with GUCs to control warnings for problem
> constructs and legacy versus standard runtime behavior.

Good luck implementing that --- the precedence is hard-wired into the
bison grammar rules. There are also extremely good reasons for not
having GUC variables that affect parsing behavior.

Given that it's been this way for ten years and no one has complained
before, I'm disinclined to change it, and even more disinclined to
invest the effort that would be involved in letting the behavior vary
at runtime.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2007-12-27 23:16:30 Re: BUG #3822: Nonstandard precedence for comparison operators
Previous Message Kevin Grittner 2007-12-27 21:25:30 Re: BUG #3822: Nonstandard precedence for comparison operators