Is the member name of hashctl inappropriate?

From: ywgrit <yw987194828(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Is the member name of hashctl inappropriate?
Date: 2023-09-13 01:14:04
Message-ID: CAPt2h2acO1pmKO5aoVtkZa74vgFuXP2aEn8vigkr1GDUpwLWgA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The definition of hashctl is shown below

typedef struct HASHCTL
{
long num_partitions; /* # partitions (must be power of 2) */
long ssize; /* segment size */
long dsize; /* (initial) directory size */
long max_dsize; /* limit to dsize if dir
size is limited */
long ffactor; /* fill factor */
Size keysize; /* hash key length in bytes */
Size entrysize; /* total user element size
in bytes */
HashValueFunc hash; /* hash function */
HashCompareFunc match; /* key comparison function */
HashCopyFunc keycopy; /* key copying function */
HashAllocFunc alloc; /* memory allocator */
MemoryContext hcxt; /* memory context to use
for allocations */
HASHHDR *hctl; /* location of header in
shared mem */
} HASHCTL;

/*
* Key copying functions must have this signature. The return value is not
* used. (The definition is set up to allow memcpy() and strlcpy() to be
* used directly.)
*/
typedef void *(*HashCopyFunc) (void *dest, const void *src, Size keysize);

According to the description, the keycopy function only copies the key, but
in reality it copies the entire entry, i.e., the key and the value, is the
name wrong? This may make the developer pass in an inappropriate keycopy
parameter when creating the htab.

Thanks

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-09-13 01:16:45 Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)
Previous Message Erik Wienhold 2023-09-13 01:00:07 Re: JSON Path and GIN Questions