77 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
10- * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.37 2005/06/08 23:02:05 tgl Exp $
10+ * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.38 2005/06/18 20:51:30 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
1616
1717
1818/*
19- * Hash and comparison functions must have these signatures. Comparison
20- * functions return zero for match, nonzero for no match. (The comparison
21- * function definition is designed to allow memcmp() and strncmp() to be
22- * used directly as key comparison functions.)
19+ * Hash functions must have this signature.
2320 */
2421typedef uint32 (* HashValueFunc ) (const void * key ,Size keysize );
22+
23+ /*
24+ * Key comparison functions must have this signature. Comparison functions
25+ * return zero for match, nonzero for no match. (The comparison function
26+ * definition is designed to allow memcmp() and strncmp() to be used directly
27+ * as key comparison functions.)
28+ */
2529typedef int (* HashCompareFunc ) (const void * key1 ,const void * key2 ,
26- Size keysize );
30+ Size keysize );
31+
32+ /*
33+ * Key copying functions must have this signature. The return value is not
34+ * used. (The definition is set up to allow memcpy() and strncpy() to be
35+ * used directly.)
36+ */
37+ typedef void * (* HashCopyFunc ) (void * dest ,const void * src ,Size keysize );
2738
2839/*
2940 * Space allocation function for a hashtable --- designed to match malloc().
@@ -103,6 +114,7 @@ typedef struct HTAB
103114HASHSEGMENT * dir ;/* directory of segment starts */
104115HashValueFunc hash ;/* hash function */
105116HashCompareFunc match ;/* key comparison function */
117+ HashCopyFunc keycopy ;/* key copying function */
106118HashAllocFunc alloc ;/* memory allocator */
107119MemoryContext hcxt ;/* memory context if default allocator
108120 * used */
@@ -123,6 +135,7 @@ typedef struct HASHCTL
123135Size entrysize ;/* total user element size in bytes */
124136HashValueFunc hash ;/* hash function */
125137HashCompareFunc match ;/* key comparison function */
138+ HashCopyFunc keycopy ;/* key copying function */
126139HashAllocFunc alloc ;/* memory allocator */
127140HASHSEGMENT * dir ;/* directory of segment starts */
128141HASHHDR * hctl ;/* location of header in shared mem */
@@ -140,6 +153,7 @@ typedef struct HASHCTL
140153#define HASH_ALLOC 0x100/* Set memory allocator */
141154#define HASH_CONTEXT 0x200/* Set explicit memory context */
142155#define HASH_COMPARE 0x400/* Set user defined comparison function */
156+ #define HASH_KEYCOPY 0x800/* Set user defined key-copying function */
143157
144158
145159/* max_dsize value to indicate expansible directory */