Is the member name of hashctl inappropriate? - Mailing list pgsql-hackers

From ywgrit
Subject Is the member name of hashctl inappropriate?
Date
Msg-id CAPt2h2acO1pmKO5aoVtkZa74vgFuXP2aEn8vigkr1GDUpwLWgA@mail.gmail.com
Whole thread Raw
Responses Re: Is the member name of hashctl inappropriate?
List 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

pgsql-hackers by date:

Previous
From: Erik Wienhold
Date:
Subject: Re: JSON Path and GIN Questions
Next
From: Michael Paquier
Date:
Subject: Re: Avoid a possible null pointer (src/backend/utils/adt/pg_locale.c)