Skip site navigation (1) Skip section navigation (2)

Re: Hash function for numeric (WIP)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Hash function for numeric (WIP)
Date: 2007-04-27 08:09:38
Message-ID: 9197.1177661378@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Neil Conway <neilc(at)samurai(dot)com> writes:
> For any two numerics that compare equal, we need to compute the same
> hash value for both datums, even if their bit patterns differ.

I feel uncomfortable about this proposal because it will compute
different hashes for values that differ only in having different
numbers of trailing zeroes.  Now the numeric.c code is supposed to
suppress extra trailing zeroes on output, but that's never been a
correctness property ... are we willing to make it one?

There are various related cases involving unstripped leading zeroes.

Another point is that sign = NUMERIC_NAN makes it a NAN regardless
of any other fields; ignoring the sign does not get the right result
here.

Lastly, calling hashint2 seems like overkill, you might as well
just XOR the weight into the digit_hash.

			regards, tom lane

In response to

Responses

pgsql-patches by date

Next:From: Heikki LinnakangasDate: 2007-04-27 08:44:16
Subject: Re: [BUGS] BUG #3245: PANIC: failed to re-find shared lock object
Previous:From: Simon RiggsDate: 2007-04-27 08:05:38
Subject: Re: [PATCHES] Reviewers Guide to DeferredTransactions/TransactionGuarantee

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group