Add GUC to show EXEC_BACKEND state
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 26 Nov 2025 13:24:27 +0000 (14:24 +0100)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 26 Nov 2025 13:24:27 +0000 (14:24 +0100)
There is no straightforward way to determine if a cluster is running
in EXEC_BACKEND mode or not, which is useful for tests to know. This
adds a GUC debug_exec_backend similar to debug_assertions which will
be true when the server is running in EXEC_BACKEND mode.

Author: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://postgr.es/m/5F301096-921A-427D-8EC1-EBAEC2A35082@yesql.se

doc/src/sgml/config.sgml
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/guc_tables.c

index 07ff5873a97d786925c36663792ab0d83de32dda..737b90736bf1f8fb067f8429b66bd877e0a5e387 100644 (file)
@@ -11833,6 +11833,23 @@ dynamic_library_path = '/usr/local/lib/postgresql:$libdir'
       </listitem>
      </varlistentry>
 
+     <varlistentry id="guc-debug-exec-backend" xreflabel="debug_exec_backend">
+      <term><varname>debug_exec_backend</varname> (<type>boolean</type>)
+      <indexterm>
+       <primary><varname>debug_exec_backend</varname> configuration parameter</primary>
+      </indexterm>
+      </term>
+      <listitem>
+       <para>
+        Reports whether <productname>PostgreSQL</productname> has been built
+        with <literal>EXEC_BACKEND</literal> enabled. That is the case on
+        <systemitem class="osname">Windows</systemitem> or if the
+        macro <symbol>EXEC_BACKEND</symbol> is defined
+        when <productname>PostgreSQL</productname> is built.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry id="guc-huge-pages-status" xreflabel="huge_pages_status">
       <term><varname>huge_pages_status</varname> (<type>enum</type>)
       <indexterm>
index 1128167c0251505ba1375a0e6c918c6772f3624c..3b9d8349078b693125aa4704fbc4b7693837197d 100644 (file)
   max => 'MAX_DEBUG_DISCARD_CACHES',
 },
 
+{ name => 'debug_exec_backend', type => 'bool', context => 'PGC_INTERNAL', group => 'PRESET_OPTIONS',
+  short_desc => 'Shows whether the running server is built with EXEC_BACKEND enabled.',
+  flags => 'GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE',
+  variable => 'exec_backend_enabled',
+  boot_val => 'EXEC_BACKEND_ENABLED',
+},
+
 { name => 'debug_io_direct', type => 'string', context => 'PGC_POSTMASTER', group => 'DEVELOPER_OPTIONS',
   short_desc => 'Use direct I/O for file access.',
   long_desc => 'An empty string disables direct I/O.',
index 0209b2067a2284f21b95a6927a5e6758fa2145db..f87b558c2c66c1d103f0cd5d2e3bead7a90f8ff8 100644 (file)
@@ -627,6 +627,13 @@ static bool integer_datetimes;
 #endif
 static bool assert_enabled = DEFAULT_ASSERT_ENABLED;
 
+#ifdef EXEC_BACKEND
+#define EXEC_BACKEND_ENABLED true
+#else
+#define EXEC_BACKEND_ENABLED false
+#endif
+static bool exec_backend_enabled = EXEC_BACKEND_ENABLED;
+
 static char *recovery_target_timeline_string;
 static char *recovery_target_string;
 static char *recovery_target_xid_string;