Re: Return DSA area for hash table from GetNamedDSHash()
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Michael Paquier <michael@paquier.xyz>, jugierwang@gmail.com
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-04-09T21:11:48Z
Lists: pgsql-hackers
Thanks for the replies!
> I think an assert check could be added in this patch for better safety.
> Assert(hash_table != NULL);
>
I followed the same approach we take for dshash_destroy() and
dshash_get_hash_table_handle(). The caller is responsible for
not passing in a NULL hash table, else that assert will segfault.
> +dsa_area *
> +dshash_get_dsa_area(dshash_table *hash_table)
> +{
> + Assert(hash_table->control->magic == DSHASH_MAGIC);
> +
> + return hash_table->area;
>
> Rather than an API that returns the DSA area, perhaps it would be more
> natural to have a wrapper that calls dsa_set_size_limit(), using an
> existing dshash_table in input?
hm, having GetNamedDSA return dsa_area for direct use while requiring
a special wrapper for the dshash case creates an inconsistent API in
dsm_registry.h. dshash_get_dsa_area() means either way the dsa_area is
obtained, dsa_set_size_limit() can be used to set the size.
--
Sami