Late last year, I did some work to make it possible to use simplehash in frontend code.[1] However, a hash table is not much good unless one also has some hash functions that one can use to hash the keys that need to be inserted into that hash table. I initially thought that solving this problem was going to be pretty annoying, but when I looked at it again today I found what I think is a pretty simple way to adapt things so that the hashing routines we use in the backend are easily available to frontend code.
Here are some patches for that. It may make sense to combine some of these in terms of actually getting this committed, but I have separated them here so that it is, hopefully, easy to see what I did and why I did it. There are three basic problems which are solved by the three preparatory patches: 0001 - hashfn.c has a couple of routines that depend on bitmapsets, and bitmapset.c is currently backend-only. Fix by moving this code near related code in bitmapset.c. 0002 - some of the prototypes for functions in hashfn.c are in hsearch.h, mixed with the dynahash stuff, and others are in hashutils.c. Fix by making hashutils.h the one true header for hashfn.c. 0003 - Some of hashfn.c's routines return Datum, but that's backend-only. Fix by renaming the functions and changing the return types to uint32 and uint64, and add static inline wrappers with the old names that convert to Datum. Just changing the return types of the existing functions seemed like it would've required a lot more code churn, and also seems like it could cause silent breakage in the future. Thanks, -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company [1] http://postgr.es/m/CA+Tgmob8oyh02NrZW=xCScB+5GyJ-jVowE3+TWTUmPF=fsg...@mail.gmail.com
0001-Move-bitmap_hash-and-bitmap_match-to-bitmapset.c.patch
Description: Binary data
0004-Move-src-backend-utils-hash-hashfn.c-to-src-common.patch
Description: Binary data
0003-Adapt-hashfn.c-and-hashutils.h-for-frontend-use.patch
Description: Binary data
0002-Put-all-the-prototypes-for-hashfn.c-into-the-same-he.patch
Description: Binary data