Re: Boolean operators without commutators vs. ALL/ANY - Mailing list pgsql-hackers

From Florian Pflug
Subject Re: Boolean operators without commutators vs. ALL/ANY
Date
Msg-id 716ED499-D53F-4B02-A0DB-705BB401503B@phlo.org
Whole thread Raw
In response to Re: Boolean operators without commutators vs. ALL/ANY  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Boolean operators without commutators vs. ALL/ANY
List 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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch: add GiST support for BOX @> POINT queries
Next
From: Alvaro Herrera
Date:
Subject: Re: Boolean operators without commutators vs. ALL/ANY