Re: Can't ri_KeysEqual() consider two nulls as equal?

From: David Fetter <david(at)fetter(dot)org>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Can't ri_KeysEqual() consider two nulls as equal?
Date: 2007-04-18 18:22:51
Message-ID: 20070418182251.GF25896@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 18, 2007 at 07:51:48AM -0700, Stephan Szabo wrote:
> On Tue, 17 Apr 2007, Tom Lane wrote:
>
> > A recent discussion led me to the idea that FK triggers are fired
> > unnecessarily during an UPDATE if the foreign-key column(s)
> > contain any NULLs, because ri_KeysEqual() treats two nulls as
> > unequal, and therefore we conclude the row has changed when it has
> > not. I claim that both ri_KeysEqual() and ri_OneKeyEqual() could
> > consider two nulls to be equal. Furthermore it seems like
> > ri_AllKeysUnequal() should do so too; the case can't arise at the
> > moment because the sole caller already knows that one of the key
> > sets contains no nulls, but if this weren't so, the optimization
> > would be actively wrong if we concluded that two nulls were
> > unequal.
>
> Do you have any suggestions for alternate names? Keeping them using
> Equal seems to be dangerous since people would likely expect it to
> act like normal equality (with nulls being different).

How about NotDistinct as in SQL's IS NOT DISTINCT FROM ?

Cheers,
D
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-04-18 18:23:04 Re: Can't ri_KeysEqual() consider two nulls as equal?
Previous Message Tom Lane 2007-04-18 18:02:33 Re: Background LRU Writer/free list