Re: Boolean operators without commutators vs. ALL/ANY

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Boolean operators without commutators vs. ALL/ANY
Date: 2011-06-17 14:03:56
Message-ID: 716ED499-D53F-4B02-A0DB-705BB401503B@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jun17, 2011, at 15:36 , Alvaro Herrera wrote:
> Excerpts from Florian Pflug's message of vie jun 17 04:46:32 -0400 2011:
>> On Jun17, 2011, at 03:42 , Alvaro Herrera wrote:
>>> To make matters worse, our delimiters for regexes are the same as for
>>> strings, the single quote. So you get
>>>
>>> foo =~ 'bar' /* foo is the text column, bar is the regex */
>>> 'bar' =~ foo /* no complaint but it's wrong */
>>>
>>> 'bar' ~= foo /* okay */
>>> 'foo' ~= bar /* no complaint but it's wrong */
>>>
>>> How do I tell which is the regex here? If we used, say, /, that would
>>> be a different matter:
>>
>> How is this different from the situation today where the operator
>> is just "~"?
>
> Err, we don't have commutators today?

So? How does that reduce that risk of somebody writing "pattern ~ text"
instead of "text ~ pattern"? Modifying your quote from above
--------
foo ~ 'bar' /* foo is the text column, bar is the regex */
'bar' ~ foo /* no complaint but it's wrong */

How do I tell which is the regex here?
--------

How is that worse than the situation with "=~" and "~="?

"=~" and "~=" at least don't *look* symmetric when they really are
not, which is the heart of the complaint, and also what makes defining
a sensible commutator impossible.

Also, do you have a better suggestion for how we can fix my original
gripe? Adding support for 'ANY/ALL op scalar" was shot down by Tom,
so it looks like we need a commutator for "~". "@" is severely disliked
by Tom, on the grounds that it's already been deprecated in other places.
"=~" is argued against by you and Robert Haas (I think). We're running
out of options here...

best regards,
Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-06-17 14:20:04 Re: Boolean operators without commutators vs. ALL/ANY
Previous Message Tom Lane 2011-06-17 13:59:40 Re: Patch: add GiST support for BOX @> POINT queries