Re: unary operators, precedence, grouping

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "woger151" <woger151(at)jqpx37(dot)cotse(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: unary operators, precedence, grouping
Date: 2007-03-10 17:14:19
Message-ID: 16862.1173546859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"woger151" <woger151(at)jqpx37(dot)cotse(dot)net> writes:
> Why wouldn't <~~(item_1) + <~~(item_2) be parsed as (<~~(item_1)) +
> (<~~(item_2))?

Because it's parsed as
<~~ ( (item_1) + ( <~~ (item_2) ) )
"+" binds more tightly than any non-built-in operator, per the
precedence chart in the manual:
http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-PRECEDENCE
so this interpretation is preferred over the alternative
( <~~ (item_1) ) + ( <~~ (item_2) )
Those are the only two possibilities without getting into right-unary
operators, which the parser is generally designed not to do if it can
avoid it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-03-10 17:23:51 Re: HIPPA (was Re: Anyone know ...)
Previous Message Rich Shepard 2007-03-10 15:59:49 Re: Re: Anyone know a good opensource CRM that actually installs with Posgtres?