Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, Eugen Konkov <kes-kes(at)yandex(dot)ru>, David Fetter <david(at)fetter(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposition to use '==' as synonym for 'IS NOT DISTINCT FROM'
Date: 2019-10-28 15:35:47
Message-ID: CA+Tgmoap=pTvj4vRvTHsKOwbCGvuFNu-q=MV1d7qQhNXO8OYTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 28, 2019 at 11:20 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > I mean, do we have to break the extensions? If we just added ==
> > operators that behaved like IS NOT DISTINCT FROM to each datatype, why
> > would anything get broken?
>
> Is that the proposal? I certainly assumed that Eugen had in mind a
> parser-level hack, because adding dozens of new operators and their
> underlying functions would be a Lot Of Tedious Work. But I agree
> that if we did it like that, it (probably) wouldn't break anything.

I'm not sure we've yet converged on a single proposal yet. This seems
to be at the spitballing stage.

> I'd be somewhat inclined to adopt "===" and "!===" as the standard
> names, trading off one more keystroke to get to a point where we
> almost certainly aren't conflicting with anybody's existing usage.

Maybe. It's an open question in my mind which of those is more likely
to be taken already. Javascript uses === and !== for a certain kind
of equality comparison, so I'd guess that the chance of someone having
used === is better-than-average for that reason. Also, if we decide
that the opposite of === is !=== rather than !==, someone may hate us.

> One objection to proceeding like that is that there'd be no
> visible connection between a datatype's "=" and "===" operators,
> removing any hope of someday optimizing, for example, "x IS NOT
> DISTINCT FROM 42" into an indexscan on x. We're certainly not
> very bright about these constructs today, but at least there
> exists the possibility of doing better in future. I suppose
> we could think about extending btree opclasses to allow for
> an === entry, but that'd be another pile of work ...

Yeah. If we went this route, I think we'd probably have to do that
extension of the btree operator class machinery first. Virtually
nobody is gonna want a new spelling of IS NOT DISTINCT FROM that is
shorter but performs terribly.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2019-10-28 15:36:09 Re: WIP: System Versioned Temporal Table
Previous Message Robert Haas 2019-10-28 15:28:49 Re: WIP/PoC for parallel backup