Can't ri_KeysEqual() consider two nulls as equal? - Mailing list pgsql-hackers

From Tom Lane
Subject Can't ri_KeysEqual() consider two nulls as equal?
Date
Msg-id 13541.1176844587@sss.pgh.pa.us
Whole thread Raw
Responses Re: Can't ri_KeysEqual() consider two nulls as equal?  ("Simon Riggs" <simon@2ndquadrant.com>)
Re: Can't ri_KeysEqual() consider two nulls as equal?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: Can't ri_KeysEqual() consider two nulls as equal?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-hackers
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.

Comments?

Also, I am wondering to what extent the ri_KeysEqual() calls in
ri_triggers.c are redundant, given that commands/trigger.c now has
the smarts to not even queue the trigger when those cases apply.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Unhelpful debug tools on OS X :-(
Next
From: Florian Pflug
Date:
Subject: Re: RESET command seems pretty disjointed now