Re: Return DSA area for hash table from GetNamedDSHash()

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, jugierwang(at)gmail(dot)com
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Return DSA area for hash table from GetNamedDSHash()
Date: 2026-04-09 21:11:48
Message-ID: CAA5RZ0se3N-uQHi1L_32C1HM-ZW4T_D3vw5eCf0vDO2tHwB=sg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message SATYANARAYANA NARLAPURAM 2026-04-09 21:37:44 Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures
Previous Message Andres Freund 2026-04-09 20:55:14 Heads Up: cirrus-ci is shutting down June 1st