Add a hash function for "numeric". Mark the equality operator for
authorNeil Conway <neilc@samurai.com>
Tue, 8 May 2007 18:56:48 +0000 (18:56 +0000)
committerNeil Conway <neilc@samurai.com>
Tue, 8 May 2007 18:56:48 +0000 (18:56 +0000)
commitade493e02d25f4807c02dcd763a25d4232b3b68d
treea234ff952a89a742ceb5b668adc31fc0e0ddbbda
parent97f796942fe529ed080a6b1695ec00fa19dfb191
Add a hash function for "numeric". Mark the equality operator for
numerics as "oprcanhash", and make the corresponding system catalog
updates. As a result, hash indexes, hashed aggregation, and hash
joins can now be used with the numeric type. Bump the catversion.

The only tricky aspect to doing this is writing a correct hash
function: it's possible for two Numerics to be equal according to
their equality operator, but have different in-memory bit patterns.
To cope with this, the hash function doesn't consider the Numeric's
"scale" or "sign", and explictly skips any leading or trailing
zeros in the Numeric's digit buffer (the current implementation
should suppress any such zeros, but it seems unwise to rely upon
this). See discussion on pgsql-patches for more details.
src/backend/utils/adt/numeric.c
src/include/catalog/catversion.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_opfamily.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h