From: Michael Paquier Date: Mon, 3 Aug 2026 11:05:23 +0000 (+0900) Subject: Add dshash_get_dsa_area(), able to retrieve the DSA area of a dshash table X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=762e329e83f2194969a6ea859ddd08361a18ac98;p=thirdparty%2Fpostgresql.git Add dshash_get_dsa_area(), able to retrieve the DSA area of a dshash table Code using GetNamedDSHash() to retrieve a dshash table may also want to limit its size, but there is actually no easy way to do so because the dsa_area of a hash table is hidden within dshash.c. This commit adds dshash_get_dsa_area() to close the gap, which returns the dsa_area for a given dshash_table. The DSA area retrieved can then be passed to dsa_set_size_limit(), to limit its size. This accessor routine also opens the door for allocating additional objects in the same DSA area as a hash table, which may be useful for some. Author: Sami Imseih Discussion: https://postgr.es/m/CAA5RZ0tKfCVqFnMZtavM42H63ha2Haf_C4mbJNWqkaW30cPW1w@mail.gmail.com --- diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c index 1999989c14f..62ac68d4add 100644 --- a/src/backend/lib/dshash.c +++ b/src/backend/lib/dshash.c @@ -363,6 +363,17 @@ dshash_destroy(dshash_table *hash_table) pfree(hash_table); } +/* + * Get the DSA area used by this hash table. + */ +dsa_area * +dshash_get_dsa_area(dshash_table *hash_table) +{ + Assert(hash_table->control->magic == DSHASH_MAGIC); + + return hash_table->area; +} + /* * Get a handle that can be used by other processes to attach to this hash * table. diff --git a/src/include/lib/dshash.h b/src/include/lib/dshash.h index 64b758b381b..b868084df04 100644 --- a/src/include/lib/dshash.h +++ b/src/include/lib/dshash.h @@ -89,6 +89,7 @@ extern dshash_table *dshash_attach(dsa_area *area, dshash_table_handle handle, void *arg); extern void dshash_detach(dshash_table *hash_table); +extern dsa_area *dshash_get_dsa_area(dshash_table *hash_table); extern dshash_table_handle dshash_get_hash_table_handle(dshash_table *hash_table); extern void dshash_destroy(dshash_table *hash_table);