Hash function for numeric (WIP)

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Hash function for numeric (WIP)
Date: 2007-04-27 07:47:49
Message-ID: 1177660069.6440.114.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
numeric_hash_func-2.patch text/x-patch 8.0 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2007-04-27 08:05:38 Re: [PATCHES] Reviewers Guide to DeferredTransactions/TransactionGuarantee
Previous Message Zoltan Boszormenyi 2007-04-27 06:08:14 Re: New version of GENERATED/IDENTITY, was Re: parser dilemma