operator precedence issues

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: operator precedence issues
Date: 2013-09-04 00:00:30
Message-ID: CAHyXU0z45jKpiNj6E7qBrKbA48hdSHmtoM464B0D4=_c_cUK+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 3, 2013 at 9:13 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
>> 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.
>
> Yeah, this has exactly nothing to do with operator precedence.
> Precedence is about which operator binds tighter in cases like "A+B*C".

That all makes perfect sense -- thanks guys. For posterity, Andres's trick
worked and did end up saving me some coding after all -- in my case I have
to eval() some externally generated fairly complex expressions in SQL (via
pl/pgsql EXECUTE) in the context of a much larger query. My de-parsing
code ended up having bugs and it was much easier to tip-toe around the
search_path (via SET LOCAL) and force the modified operator.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Boguk, Maksym 2013-09-04 00:13:09 Re: UTF8 national character data type support WIP patch and list of open issues.
Previous Message Andres Freund 2013-09-03 23:10:46 Re: logical changeset generation v5