agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Convert all remaining subsystems to use the new shmem allocation
Date: Mon, 6 Apr 2026 14:41:04 +0900
Message-ID: <adNHcBVJO5gIOp1l@paquier.xyz> (raw)
In-Reply-To: <E1w9WsZ-0039AO-1J@gemulon.postgresql.org>
References: <E1w9WsZ-0039AO-1J@gemulon.postgresql.org>

On Sun, Apr 05, 2026 at 11:27:44PM +0000, Heikki Linnakangas wrote:
> Convert all remaining subsystems to use the new shmem allocation API
> 
> This removes all remaining uses of ShmemInitStruct() and
> ShmemInitHash() from built-in code.
>
> src/backend/utils/misc/injection_point.c           |  57 ++++---

drongo, that compiles without USE_INJECTION_POINTS, is complaining
about this bit around line 240:
const ShmemCallbacks InjectionPointShmemCallbacks = {
#ifdef USE_INJECTION_POINTS
    .request_fn = InjectionPointShmemRequest,
    .init_fn = InjectionPointShmemInit,
#endif
};

Link:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=drongo&dt=2026-04-06%2004%3A09%3A20
And the error:
../pgsql/src/backend/utils/misc/injection_point.c(240): error C2059: syntax error: '}'

Why not putting the whole InjectionPointShmemCallbacks inside a
USE_INJECTION_POINTS block?  We should not care about shmem
allocations when --enable-injection-points is not used.

subsystemlist.h expects the callbacks to always be defined, so your
intention is to have no ifdefs there.  Still, it seems a bit pointless
to me to define callbacks we are not going to use depending on the
build options evoked?  Attached is one idea, which I doubt you'll
like.  :)
--
Michael
diff --git a/src/include/storage/subsystemlist.h b/src/include/storage/subsystemlist.h
index 5e092552c725..9ad619080be2 100644
--- a/src/include/storage/subsystemlist.h
+++ b/src/include/storage/subsystemlist.h
@@ -79,7 +79,9 @@ PG_SHMEM_SUBSYSTEM(SyncScanShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(AsyncShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(StatsShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(WaitEventCustomShmemCallbacks)
+#ifdef USE_INJECTION_POINTS
 PG_SHMEM_SUBSYSTEM(InjectionPointShmemCallbacks)
+#endif
 PG_SHMEM_SUBSYSTEM(WaitLSNShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(LogicalDecodingCtlShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(DataChecksumsShmemCallbacks)
diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c
index a7c99e097ea4..aa455c62bcc0 100644
--- a/src/backend/utils/misc/injection_point.c
+++ b/src/backend/utils/misc/injection_point.c
@@ -230,19 +230,15 @@ injection_point_cache_get(const char *name)
 
 	return NULL;
 }
-#endif							/* USE_INJECTION_POINTS */
 
 const ShmemCallbacks InjectionPointShmemCallbacks = {
-#ifdef USE_INJECTION_POINTS
 	.request_fn = InjectionPointShmemRequest,
 	.init_fn = InjectionPointShmemInit,
-#endif
 };
 
 /*
  * Reserve space for the dynamic shared hash table
  */
-#ifdef USE_INJECTION_POINTS
 static void
 InjectionPointShmemRequest(void *arg)
 {
@@ -259,7 +255,7 @@ InjectionPointShmemInit(void *arg)
 	for (int i = 0; i < MAX_INJECTION_POINTS; i++)
 		pg_atomic_init_u64(&ActiveInjectionPoints->entries[i].generation, 0);
 }
-#endif
+#endif							/* USE_INJECTION_POINTS */
 
 /*
  * Attach a new injection point.

Attachments:

  [text/plain] inj-shmem-subsystem.patch (1.6K, ../adNHcBVJO5gIOp1l@paquier.xyz/2-inj-shmem-subsystem.patch)
  download | inline diff:
diff --git a/src/include/storage/subsystemlist.h b/src/include/storage/subsystemlist.h
index 5e092552c725..9ad619080be2 100644
--- a/src/include/storage/subsystemlist.h
+++ b/src/include/storage/subsystemlist.h
@@ -79,7 +79,9 @@ PG_SHMEM_SUBSYSTEM(SyncScanShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(AsyncShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(StatsShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(WaitEventCustomShmemCallbacks)
+#ifdef USE_INJECTION_POINTS
 PG_SHMEM_SUBSYSTEM(InjectionPointShmemCallbacks)
+#endif
 PG_SHMEM_SUBSYSTEM(WaitLSNShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(LogicalDecodingCtlShmemCallbacks)
 PG_SHMEM_SUBSYSTEM(DataChecksumsShmemCallbacks)
diff --git a/src/backend/utils/misc/injection_point.c b/src/backend/utils/misc/injection_point.c
index a7c99e097ea4..aa455c62bcc0 100644
--- a/src/backend/utils/misc/injection_point.c
+++ b/src/backend/utils/misc/injection_point.c
@@ -230,19 +230,15 @@ injection_point_cache_get(const char *name)
 
 	return NULL;
 }
-#endif							/* USE_INJECTION_POINTS */
 
 const ShmemCallbacks InjectionPointShmemCallbacks = {
-#ifdef USE_INJECTION_POINTS
 	.request_fn = InjectionPointShmemRequest,
 	.init_fn = InjectionPointShmemInit,
-#endif
 };
 
 /*
  * Reserve space for the dynamic shared hash table
  */
-#ifdef USE_INJECTION_POINTS
 static void
 InjectionPointShmemRequest(void *arg)
 {
@@ -259,7 +255,7 @@ InjectionPointShmemInit(void *arg)
 	for (int i = 0; i < MAX_INJECTION_POINTS; i++)
 		pg_atomic_init_u64(&ActiveInjectionPoints->entries[i].generation, 0);
 }
-#endif
+#endif							/* USE_INJECTION_POINTS */
 
 /*
  * Attach a new injection point.

  [application/pgp-signature] signature.asc (832B, ../adNHcBVJO5gIOp1l@paquier.xyz/3-signature.asc)
  download

view thread (3+ messages)  latest in thread

Message-ID: <adNHcBVJO5gIOp1l@paquier.xyz>
Permalink:  ../adNHcBVJO5gIOp1l@paquier.xyz/
Also on:    postgresql.org/message-id/adNHcBVJO5gIOp1l@paquier.xyz

reply

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-committers@postgresql.org
  Cc: michael@paquier.xyz, heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Convert all remaining subsystems to use the new shmem allocation
  In-Reply-To: <adNHcBVJO5gIOp1l@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox