Re: Return DSA area for hash table from GetNamedDSHash() - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: Return DSA area for hash table from GetNamedDSHash()
Date
Msg-id CAA5RZ0se3N-uQHi1L_32C1HM-ZW4T_D3vw5eCf0vDO2tHwB=sg@mail.gmail.com
Whole thread Raw
In response to Re: Return DSA area for hash table from GetNamedDSHash()  (Michael Paquier <michael@paquier.xyz>)
List 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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Heads Up: cirrus-ci is shutting down June 1st
Next
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Re: Bug: WAIT FOR LSN crashes with assertion failure inside PL/pgSQL DO blocks and procedures