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

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 (view raw, whole thread or download thread mbox)
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.


Attachment: numeric_hash_func-2.patch
Description: text/x-patch (8.0 KB)


pgsql-patches by date

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

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