Re: operator precedence issues

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: operator precedence issues
Date: 2013-09-03 14:05:32
Message-ID: 20130903140532.GE5783@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2013-09-03 08:59:53 -0500, Merlin Moncure wrote:
> While playing around with Andres's trick, I noticed that it works but
> will not match against operators taking "any" although those will
> match with explicit schema declaration (FWICT it goes through the
> search_path trying to explicitly match int/int operator then goes
> again matches "any"). That's pretty weird:

Not surprising. We look for the best match for an operator and
explicitly matching types will be that. If there were no operator(int,
int) your anyelement variant should get called.

> Ideally though you could specify operator precedence in the operator
> name itself though in such a way that bison pick it up. I don't know
> if that's possible since so many operator names have been given out
> without any thought to reserving characters for precedence, or if it
> would be worth the extra parsing time even if you could do it.
> Overriding stock operator behaviors is a really dodgy practice with
> the limited but important exception of handling certain classes of
> mathematical errors.

I have to say, even those it seems like it's primary advantage is
making it harder to read the code, but YMMV.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-09-03 14:13:12 Re: operator precedence issues
Previous Message Merlin Moncure 2013-09-03 13:59:53 Re: operator precedence issues