From: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Precedence of standard comparison operators |
Date: | 2015-08-10 16:46:50 |
Message-ID: | CAEzk6fd-SOSaEDF76PM8U6jxpLi-SYynNjZEsk3MjfScLuZsvw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 10 August 2015 at 16:31, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> >> On Sun, Aug 09, 2015 at 08:06:11PM -0400, Tom Lane wrote:
> >>> 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,
>
> Yeah, it would sure be nice to throw something better than "syntax error".
> But I've looked at bison's facilities for that, and they're pretty bad.
> I'm not sure there's much we can do short of moving to some other parser
> generator tool, which would be a Large Undertaking ... and I don't know
> of any arguably-better tool anyway.
>
I would say that anyone who's tricksy enough to be using boolean logic in
the way you describe would be expected to have enough nouse about them to
either a) know what the precedences are or b) know that their lack of
knowledge means they should sprinkle their code with
brackets
.
Returning a syntax error for something that isn't actually an error in
syntax is a poor showing.
Are we to start
expecting
syntax errors when people use comparison operators on
NULLable
columns
without a COALESCE
because the comparison might do something they don't expect
if they haven't tested their code with NULL values
?
IMO using a = b < c as described is unnecessarily* horrid, *whichever* way
you mean it, and will only produce the sort of unreadability that generates
errors in the long run anyway (even if you understand it, chances are the
next poor sap reading your code won't) and deserves code that breaks,
especially if you're the sort of person who uses it without fully
understanding it.
(*Unnecessarily because there are clearer constructs - CASE springs to mind
- that do the same thing without the associated unreadability and/or
ambiguity)
Geoff
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-08-10 16:50:15 | Re: WIP: Rework access method interface |
Previous Message | Pavel Stehule | 2015-08-10 16:43:36 | Re: PL/pgSQL, RAISE and error context |