Re: cleanup patches for dshash

From: Andy Fan <zhihuifan1213(at)163(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: cleanup patches for dshash
Date: 2024-01-22 02:28:42
Message-ID: 87sf2qw0wf.fsf@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Nathan Bossart <nathandbossart(at)gmail(dot)com> writes:

> While working on the dynamic shared memory registry, I noticed a couple of
> potential improvements for code that uses dshash tables.
>
> * A couple of dshash_create() callers pass in 0 for the "void *arg"
> parameter, which seemed weird. I incorrectly assumed this was some sort
> of flags parameter until I actually looked at the function signature.
> IMHO we should specify NULL here if arg is not used. 0001 makes this
> change. This is admittedly a nitpick.
>
> * There are no dshash compare/hash functions for string keys. 0002
> introduces some that simply forward to strcmp()/string_hash(), and it
> uses them for the DSM registry's dshash table. This allows us to remove
> the hacky key padding code for lookups on this table.
>
> Thoughts?

Both LGTM.

+dshash_strcmp(const void *a, const void *b, size_t size, void *arg)
+{
+ Assert(strlen((const char *) a) < size);
+ Assert(strlen((const char *) b) < size);
+

Do you think the below change will be more explicitly?

#define DSMRegistryNameSize 64

DSMRegistryEntry
{
char name[DSMRegistryNameSize];

}

Assert(strlen((const char *) a) < DSMRegistryNameSize);

--
Best Regards
Andy Fan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2024-01-22 02:33:14 Re: Remove unused fields in ReorderBufferTupleBuf
Previous Message Peter Smith 2024-01-22 02:25:13 Re: ALTER TABLE SET ACCESS METHOD on partitioned tables