Thread: add operator ^= to mean not equal (like != and <>)

add operator ^= to mean not equal (like != and <>)

From
"孙诗浩(思才)"
Date:
Hi everyone,
I am doding some jobs in postgres. I want to add "^=" like "!=" and "<>".

So i modify the code in scan.l.
Plan 1:
equals_greater "=>"
less_equals  "<="
greater_equals ">="
less_greater "<>"
not_equals  (!=|\^=)
 
Maybe i can delete some code to make the code more simple.
Plan 2:
 
equals_greater "=>"
less_equals  "<="
greater_equals ">="
less_greater "<>" (delete this definition)
not_equals  (!=|\^=|<>)

Before send patch review, I want to konw whether the postgres maintainer will approve my changes.

So, please give me some advice.

Thank you!

Re: add operator ^= to mean not equal (like != and <>)

From
Andreas Karlsson
Date:
On 8/10/21 10:27 AM, 孙诗浩(思才) wrote:
> Before send patch review, I want to konw whether the postgres maintainer 
> will approve my changes.
> 
> So, please give me some advice.

Welcome!

I do not think that is a feature which will get much interest from the 
developers since it is unclear to me what the advantage of yet another 
alias for not equal would be. It just takes up yet another operator and 
means that there is yet another thing to remember for the users. 
Personally I feel it is bad enough that we have two ways of writing it.

What is he reason you want to add ^= is there any other databases which 
uses ^= for inequality?

Andreas



Re: add operator ^= to mean not equal (like != and <>)

From
Daniel Gustafsson
Date:
> On 10 Aug 2021, at 11:10, Andreas Karlsson <andreas@proxel.se> wrote:

> What is he reason you want to add ^= is there any other databases which uses ^= for inequality?

I assume it's because of Oracle compatibility which AFAIK is the only database
supporting ^=.

--
Daniel Gustafsson        https://vmware.com/




Re: add operator ^= to mean not equal (like != and <>)

From
David Rowley
Date:
On Tue, 10 Aug 2021 at 21:13, Daniel Gustafsson <daniel@yesql.se> wrote:
>
> > On 10 Aug 2021, at 11:10, Andreas Karlsson <andreas@proxel.se> wrote:
>
> > What is he reason you want to add ^= is there any other databases which uses ^= for inequality?
>
> I assume it's because of Oracle compatibility which AFAIK is the only database
> supporting ^=.

Seems likely.

I'm strongly against inheriting warts from Oracle for apparently good
reason. At the very least, anyone who's using ^= for some other
purpose is very likely to be upset with us. Anyone else who really
needs this for compatibility reasons can just create a set of
operators for themselves.

David



Re: add operator ^= to mean not equal (like != and <>)

From
Daniel Gustafsson
Date:
> On 10 Aug 2021, at 12:21, David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Tue, 10 Aug 2021 at 21:13, Daniel Gustafsson <daniel@yesql.se> wrote:
>>
>>> On 10 Aug 2021, at 11:10, Andreas Karlsson <andreas@proxel.se> wrote:
>>
>>> What is he reason you want to add ^= is there any other databases which uses ^= for inequality?
>>
>> I assume it's because of Oracle compatibility which AFAIK is the only database
>> supporting ^=.
>
> Seems likely.
>
> I'm strongly against inheriting warts from Oracle for apparently good
> reason. At the very least, anyone who's using ^= for some other
> purpose is very likely to be upset with us. Anyone else who really
> needs this for compatibility reasons can just create a set of
> operators for themselves.

Agreed, if it’s because of Oracle compatibility then this seems like something
which has a better fit in orafce or a similar extension like that.

--
Daniel Gustafsson        https://vmware.com/




Re: add operator ^= to mean not equal (like != and <>)

From
Julien Rouhaud
Date:
Le mar. 10 août 2021 à 18:41, Daniel Gustafsson <daniel@yesql.se> a écrit :
> On 10 Aug 2021, at 12:21, David Rowley <dgrowleyml@gmail.com> wrote:
>
> I'm strongly against inheriting warts from Oracle for apparently good
> reason. At the very least, anyone who's using ^= for some other
> purpose is very likely to be upset with us. Anyone else who really
> needs this for compatibility reasons can just create a set of
> operators for themselves.

Agreed, if it’s because of Oracle compatibility then this seems like something
which has a better fit in orafce or a similar extension like that.

+1

Re: add operator ^= to mean not equal (like != and <>)

From
Gavin Flower
Date:
On 10/08/21 8:27 pm, 孙诗浩(思才) wrote:
> Hi everyone,
> I am doding some jobs in postgres. I want to add "^=" like "!=" and "<>".

One problem is that '^' & '^=' is already used as the exclusive OR 
operator in programming languages such as: C, Java, JavaScript, and 
Python.  See:

    https://www.tutorialspoint.com/java/java_basic_operators.htm

    https://www.tutorialspoint.com/cprogramming/c_operators.htm

    https://docs.python.org/3/library/operator.html

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators

Please don't confuse people unnecessarily!


Cheers,
Gavin




Re: add operator ^= to mean not equal (like != and <>)

From
Michael Banck
Date:
Hi,

On Tue, Aug 10, 2021 at 11:13:03AM +0200, Daniel Gustafsson wrote:
> > On 10 Aug 2021, at 11:10, Andreas Karlsson <andreas@proxel.se> wrote:
> > What is he reason you want to add ^= is there any other databases
> > which uses ^= for inequality?
> 
> I assume it's because of Oracle compatibility which AFAIK is the only
> database supporting ^=.

DB2 also supports (or supported) it, but it's deprecated:

https://www.ibm.com/docs/en/db2/9.7?topic=predicates-basic-predicate

We encountered it at least in one customer setting, so we added it to
db2fce:

https://github.com/credativ/db2fce/blob/master/db2fce.sql#L588


Michael

-- 
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax:  +49 2166 9901-100
Email: michael.banck@credativ.de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Sascha Heuer, Geoff Richardson,
Peter Lilley

Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz