Hash function for numeric (WIP) - Mailing list pgsql-patches

From Neil Conway
Subject Hash function for numeric (WIP)
Date
Msg-id 1177660069.6440.114.camel@localhost.localdomain
Whole thread Raw
Responses Re: Hash function for numeric (WIP)
List pgsql-patches
There is currently no support for hashing numerics. This prevents
numerics from being hash indexed or used in a hashed aggregation. This
patch makes the necessary changes to the catalogs to enable hashing for
numerics, and implements a first sketch at a hash function for numerics.

For any two numerics that compare equal, we need to compute the same
hash value for both datums, even if their bit patterns differ. This
patch computes the hash from the "n_weight" and "n_data" fields of the
numeric -- notably, it doesn't use the numeric's "scale" field, since
two equal numerics may have different scales. The hash seems to return
the correct results for the simple test cases that I've tried, but I'm
not very familiar with the details of the numeric implementation -- can
anyone comment on whether this hash function is correct?

Thanks to Sailesh Krishnamurthy for reporting this problem.

-Neil


Attachment

pgsql-patches by date:

Previous
From: Zoltan Boszormenyi
Date:
Subject: Re: New version of GENERATED/IDENTITY, was Re: parser dilemma
Next
From: Tom Lane
Date:
Subject: Re: Hash function for numeric (WIP)