From: Nathan Bossart <nathandbossart@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: anonymous unions (C11)
Date: Tue, 23 Sep 2025 09:17:50 -0500
Message-ID: <aNKsDg0fJwqhZdXX@nathan> (raw)
In-Reply-To: <f00a9968-388e-4f8c-b5ef-5102e962d997@eisentraut.org>
References: <f00a9968-388e-4f8c-b5ef-5102e962d997@eisentraut.org>
On Tue, Sep 23, 2025 at 11:38:22AM +0200, Peter Eisentraut wrote:
> That said, I did go overboard here and converted all the struct/union
> combinations I could find, but I'm not necessarily proposing to apply
> all of them. I'm proposing patches 0001 through 0004, which are
> relatively simple or in areas that have already changed a few times
> recently (so backpatching would not be trivial anyway), and/or they
> are somewhat close to my heart because they originally motivated this
> work a long time ago. But if someone finds among the other patches
> one that they particularly like, we could add that one as well.
I would have used this in the DSM registry if it was available. Patch
attached.
--
nathan
Attachments:0001-C11-anonymous-unions-DSM-registry.patch (text/plain, 3.2K) download
From 4d28101c17fd94761069009ef04017bc022e1b13 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <nathan@postgresql.org>
Date: Tue, 23 Sep 2025 09:15:21 -0500
Subject: [PATCH 1/1] C11 anonymous unions [DSM registry]
---
src/backend/storage/ipc/dsm_registry.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/backend/storage/ipc/dsm_registry.c b/src/backend/storage/ipc/dsm_registry.cindex 97130925106..a926b9c3f32 100644--- a/src/backend/storage/ipc/dsm_registry.c+++ b/src/backend/storage/ipc/dsm_registry.c@@ -98,7 +98,7 @@ typedef struct DSMRegistryEntry
NamedDSMState dsm;
NamedDSAState dsa;
NamedDSHState dsh;
- } data;+ };
} DSMRegistryEntry;
static const dshash_parameters dsh_params = {
@@ -212,7 +212,7 @@ GetNamedDSMSegment(const char *name, size_t size,
entry = dshash_find_or_insert(dsm_registry_table, name, found);
if (!(*found))
{
- NamedDSMState *state = &entry->data.dsm;+ NamedDSMState *state = &entry->dsm;
dsm_segment *seg;
entry->type = DSMR_ENTRY_TYPE_DSM;
@@ -232,12 +232,12 @@ GetNamedDSMSegment(const char *name, size_t size,
else if (entry->type != DSMR_ENTRY_TYPE_DSM)
ereport(ERROR,
(errmsg("requested DSM segment does not match type of existing entry")));
- else if (entry->data.dsm.size != size)+ else if (entry->dsm.size != size)
ereport(ERROR,
(errmsg("requested DSM segment size does not match size of existing segment")));
else
{
- NamedDSMState *state = &entry->data.dsm;+ NamedDSMState *state = &entry->dsm;
dsm_segment *seg;
/* If the existing segment is not already attached, attach it now. */
@@ -294,7 +294,7 @@ GetNamedDSA(const char *name, bool *found)
entry = dshash_find_or_insert(dsm_registry_table, name, found);
if (!(*found))
{
- NamedDSAState *state = &entry->data.dsa;+ NamedDSAState *state = &entry->dsa;
entry->type = DSMR_ENTRY_TYPE_DSA;
@@ -314,7 +314,7 @@ GetNamedDSA(const char *name, bool *found)
(errmsg("requested DSA does not match type of existing entry")));
else
{
- NamedDSAState *state = &entry->data.dsa;+ NamedDSAState *state = &entry->dsa;
if (dsa_is_attached(state->handle))
ereport(ERROR,
@@ -367,7 +367,7 @@ GetNamedDSHash(const char *name, const dshash_parameters *params, bool *found)
entry = dshash_find_or_insert(dsm_registry_table, name, found);
if (!(*found))
{
- NamedDSHState *dsh_state = &entry->data.dsh;+ NamedDSHState *dsh_state = &entry->dsh;
dshash_parameters params_copy;
dsa_area *dsa;
@@ -395,7 +395,7 @@ GetNamedDSHash(const char *name, const dshash_parameters *params, bool *found)
(errmsg("requested DSHash does not match type of existing entry")));
else
{
- NamedDSHState *dsh_state = &entry->data.dsh;+ NamedDSHState *dsh_state = &entry->dsh;
dsa_area *dsa;
/* XXX: Should we verify params matches what table was created with? */
@@ -447,7 +447,7 @@ pg_get_dsm_registry_allocations(PG_FUNCTION_ARGS)
* attaching to them, return NULL for those.
*/
if (entry->type == DSMR_ENTRY_TYPE_DSM)
- vals[2] = Int64GetDatum(entry->data.dsm.size);+ vals[2] = Int64GetDatum(entry->dsm.size);
else
nulls[2] = true;
--
2.39.5 (Apple Git-154)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, peter@eisentraut.org
Subject: Re: anonymous unions (C11)
In-Reply-To: <aNKsDg0fJwqhZdXX@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox