Hi,

On Wed, 18 Nov 2026 at 23:07, Andres Freund <[email protected]> wrote:
>
> On 2026-11-18 16:14:28 +0200, Heikki Linnakangas wrote:
> > On 23/09/2026 21:42, Jelte Fennema-Nio wrote:
> > > On Wed, 22 Jul 2026 at 08:56, Nazir Bilal Yavuz <[email protected]> 
> > > wrote:
> > > > Attached is an attempt to implement 'PG_TEST_SERVER_POSTGRES_OPTS'.
> > >
> > > I'm starting to get kinda annoyed that this (or my earlier version)
> > > hasn't been committed yet, or at least made some progress. There's a
> > > trivial way to improve CI runtime by 25-30%. Why has this patch been
> > > in limbo for more than 2 months?
>
> > Committed, thanks!
>
> Thanks for doing that!
>
> I'd like to see this backpatched, in preparation to backpatching CI. I don't
> want to start out with a larger set of differences than necessary.

I think this makes sense.

There is one problem, 'PG_TEST_INITDB_EXTRA_OPTS' is introduced in the
PG_17 [1] and not backpatched to 15 (where CI introduced). Because of
this, 'PG_TEST_INITDB_EXTRA_OPTS' mentions are removed from
REL_[15,16] patch for now. Backpatching [1] is another option, though.

[1] 
https://github.com/postgres/postgres/commit/995d400ceca3e552f84fe19f150fb03327bdc0c2

-- 
Regards,
Nazir Bilal Yavuz
Microsoft
From cf3ec1ddd2bf63b876b3c50b8ca3a806c4815588 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <[email protected]>
Date: Thu, 19 Nov 2026 10:05:10 +0300
Subject: [PATCH v3] Add PG_TEST_SERVER_POSTGRES_OPTS to inject server GUCs in
 tests

Allow pg_regress and TAP tests to append name=value settings to
postgresql.conf through the environment.

The GitHub Actions CI commit has not been backpatched to this branch
yet.  Including this commit reduces the backporting burden when we do.

Author: Nazir Bilal Yavuz <[email protected]>
Reviewed-by: Andrey Borodin <[email protected]>
Reviewed-by: Jakub Wartak <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAN55FZ3jqqX9Th23XmDv6U-xwJjzsuc1JffYmswFT=oqy8j...@mail.gmail.com
Backpatch: 15-, where CI support was added
---
 doc/src/sgml/regress.sgml                | 10 ++++++++++
 src/test/perl/PostgreSQL/Test/Cluster.pm | 16 ++++++++++++++++
 src/test/regress/pg_regress.c            | 22 ++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index aa380c20de6..dc8f73f304a 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -367,4 +367,14 @@ make check LANG=C ENCODING=EUC_JP
    <title>Custom Server Settings</title>
 
+   <para>
+    Run-time server settings can be added to the
+    <filename>postgresql.conf</filename> using the environment variable
+    <envar>PG_TEST_SERVER_POSTGRES_OPTS</envar>.  The settings are given as
+    whitespace-separated <literal>name=value</literal> pairs.  For example:
+<screen>
+make check PG_TEST_SERVER_POSTGRES_OPTS='work_mem=50MB debug_discard_caches=1'
+</screen>
+   </para>
+
    <para>
     Custom server settings to use when running a regression test suite can be
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index bcde0cacf08..b2f9fe6eec6 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -654,4 +654,20 @@ sub init
 	}
 
+	# PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+	# environment variable.  The options are given as whitespace-separated
+	# "name=value" pairs.
+	#
+	# There's very similar code in pg_regress.c.
+	my $server_opts_env = $ENV{PG_TEST_SERVER_POSTGRES_OPTS};
+	if (defined $server_opts_env)
+	{
+		print $conf "# options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+		foreach my $opt (split(/\s+/, $server_opts_env))
+		{
+			print $conf "$opt\n" if $opt ne '';
+		}
+		print $conf "# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+	}
+
 	print $conf "port = $port\n";
 	if ($use_tcp)
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 81d763470b5..c7542591323 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2250,4 +2250,5 @@ regression_main(int argc, char *argv[],
 		const char *env_wait;
 		int			wait_seconds;
+		const char *server_opts_env;
 
 		/*
@@ -2332,4 +2333,25 @@ regression_main(int argc, char *argv[],
 		}
 
+		/*
+		 * PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+		 * environment variable.  The options are given as whitespace-separated
+		 * "name=value" pairs.
+		 *
+		 * There's very similar code in Cluster.pm.
+		 */
+		server_opts_env = getenv("PG_TEST_SERVER_POSTGRES_OPTS");
+		if (server_opts_env != NULL)
+		{
+			char	   *opts = pg_strdup(server_opts_env);
+			char	   *tok;
+
+			fputs("# options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+			for (tok = strtok(opts, " \t\n"); tok != NULL;
+				 tok = strtok(NULL, " \t\n"))
+				fprintf(pg_conf, "%s\n", tok);
+			free(opts);
+			fputs("# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+		}
+
 		fclose(pg_conf);
 
-- 
2.47.3

From 14520ee72f2c60f9ece7807be64f753729d3b884 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <[email protected]>
Date: Thu, 19 Nov 2026 10:05:10 +0300
Subject: [PATCH v3] Add PG_TEST_SERVER_POSTGRES_OPTS to inject server GUCs in
 tests

Unlike PG_TEST_INITDB_EXTRA_OPTS, this only appends name=value
settings to postgresql.conf without disabling the initdb template
mechanism.  This speeds up CI, which sets such options in most jobs
and previously paid the full initdb cost per test cluster.

The GitHub Actions CI commit has not been backpatched to this branch
yet.  Including this commit reduces the backporting burden when we do.

Author: Nazir Bilal Yavuz <[email protected]>
Reviewed-by: Andrey Borodin <[email protected]>
Reviewed-by: Jakub Wartak <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAN55FZ3jqqX9Th23XmDv6U-xwJjzsuc1JffYmswFT=oqy8j...@mail.gmail.com
Backpatch: 15-, where CI support was added
---
 doc/src/sgml/regress.sgml                | 10 ++++++++++
 src/test/perl/PostgreSQL/Test/Cluster.pm | 18 ++++++++++++++++++
 src/test/regress/pg_regress.c            | 24 ++++++++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index 8838fe7f022..0a8beef7469 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -454,6 +454,16 @@ make check PG_TEST_INITDB_EXTRA_OPTS='-k --wal-segsize=4 -c work_mem=50MB'
 </screen>
    </para>
 
+   <para>
+    Run-time server settings can be added to the
+    <filename>postgresql.conf</filename> using the environment variable
+    <envar>PG_TEST_SERVER_POSTGRES_OPTS</envar>.  The settings are given as
+    whitespace-separated <literal>name=value</literal> pairs.  For example:
+<screen>
+make check PG_TEST_SERVER_POSTGRES_OPTS='work_mem=50MB debug_discard_caches=1'
+</screen>
+   </para>
+
    <para>
     For the core regression test suite and other tests driven by
     <command>pg_regress</command>, custom run-time server settings can also be
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index a2930fd1f2f..83ceba47063 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -726,6 +726,24 @@ sub init
 		print $conf "max_wal_senders = 0\n";
 	}
 
+	# PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+	# environment variable.  Unlike PG_TEST_INITDB_EXTRA_OPTS, it does not
+	# disable the initdb template mechanism, as the options are only added to
+	# postgresql.conf and not passed to initdb.  The options are given as
+	# whitespace-separated "name=value" pairs.
+	#
+	# There's very similar code in pg_regress.c.
+	my $server_opts_env = $ENV{PG_TEST_SERVER_POSTGRES_OPTS};
+	if (defined $server_opts_env)
+	{
+		print $conf "# options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+		foreach my $opt (split(/\s+/, $server_opts_env))
+		{
+			print $conf "$opt\n" if $opt ne '';
+		}
+		print $conf "# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+	}
+
 	print $conf "port = $port\n";
 	if ($use_tcp)
 	{
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 7862bb2277a..b4c40fe55a7 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2297,6 +2297,7 @@ regression_main(int argc, char *argv[],
 		const char *values[4];
 		PGPing		rv;
 		const char *initdb_extra_opts_env;
+		const char *server_opts_env;
 
 		/*
 		 * Prepare the temp instance
@@ -2424,6 +2425,29 @@ regression_main(int argc, char *argv[],
 			fclose(extra_conf);
 		}
 
+		/*
+		 * PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+		 * environment variable.  Unlike PG_TEST_INITDB_EXTRA_OPTS, it does
+		 * not disable the initdb template mechanism, as the options are only
+		 * added to postgresql.conf and not passed to initdb.  The options are
+		 * given as whitespace-separated "name=value" pairs.
+		 *
+		 * There's very similar code in Cluster.pm.
+		 */
+		server_opts_env = getenv("PG_TEST_SERVER_POSTGRES_OPTS");
+		if (server_opts_env != NULL)
+		{
+			char	   *opts = pg_strdup(server_opts_env);
+			char	   *tok;
+
+			fputs("# options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+			for (tok = strtok(opts, " \t\n"); tok != NULL;
+				 tok = strtok(NULL, " \t\n"))
+				fprintf(pg_conf, "%s\n", tok);
+			free(opts);
+			fputs("# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+		}
+
 		fclose(pg_conf);
 
 #ifdef ENABLE_SSPI
-- 
2.47.3

From 8cda4bd161493b08824b5f5944f4bd1691e2dd1c Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <[email protected]>
Date: Wed, 18 Nov 2026 16:13:05 +0200
Subject: [PATCH v3] Add PG_TEST_SERVER_POSTGRES_OPTS to inject server GUCs in
 tests

Unlike PG_TEST_INITDB_EXTRA_OPTS, this only appends name=value
settings to postgresql.conf without disabling the initdb template
mechanism.  This speeds up CI, which sets such options in most jobs
and previously paid the full initdb cost per test cluster.

Author: Nazir Bilal Yavuz <[email protected]>
Reviewed-by: Andrey Borodin <[email protected]>
Reviewed-by: Jakub Wartak <[email protected]>
Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: https://www.postgresql.org/message-id/CAN55FZ3jqqX9Th23XmDv6U-xwJjzsuc1JffYmswFT=oqy8j...@mail.gmail.com
Backpatch: 15-, where CI support was added
---
 .github/workflows/pg-ci.yml              | 16 ++++++++--------
 doc/src/sgml/regress.sgml                | 10 ++++++++++
 src/test/perl/PostgreSQL/Test/Cluster.pm | 18 ++++++++++++++++++
 src/test/regress/pg_regress.c            | 24 ++++++++++++++++++++++++
 4 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml
index 9e55f0fbc45..5f922243a23 100644
--- a/.github/workflows/pg-ci.yml
+++ b/.github/workflows/pg-ci.yml
@@ -513,7 +513,7 @@ jobs:
           echo "CXX=${CXX}" >> "$GITHUB_ENV"
 
           echo "PG_TEST_PG_UPGRADE_MODE=${PG_TEST_PG_UPGRADE_MODE}" >> "$GITHUB_ENV"
-          echo "PG_TEST_INITDB_EXTRA_OPTS=${PG_TEST_INITDB_EXTRA_OPTS}" >> "$GITHUB_ENV"
+          echo "PG_TEST_SERVER_POSTGRES_OPTS=${PG_TEST_SERVER_POSTGRES_OPTS}" >> "$GITHUB_ENV"
           echo "PG_TEST_PG_COMBINEBACKUP_MODE=${PG_TEST_PG_COMBINEBACKUP_MODE}" >> "$GITHUB_ENV"
 
       - *nix_sysinfo_step
@@ -575,7 +575,7 @@ jobs:
       - name: Update Environment
         env:
           SANITIZER_FLAGS: -fsanitize=alignment,undefined
-          PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring
+          PG_TEST_SERVER_POSTGRES_OPTS: io_method=io_uring
           CC: ccache gcc -m32
           CXX: ccache g++ -m32
         run: *linux_update_config_cmd
@@ -669,7 +669,7 @@ jobs:
       - name: Update Environment
         env:
           SANITIZER_FLAGS: -fsanitize=address
-          PG_TEST_INITDB_EXTRA_OPTS: -c io_method=io_uring
+          PG_TEST_SERVER_POSTGRES_OPTS: io_method=io_uring
         run: *linux_update_config_cmd
 
       - *nix_sysinfo_step
@@ -753,11 +753,11 @@ jobs:
       # Several buildfarm animals enable these options. Without testing them
       # during CI, it would be easy to cause breakage on the buildfarm with CI
       # passing.
-      PG_TEST_INITDB_EXTRA_OPTS: >-
-        -c debug_copy_parse_plan_trees=on
-        -c debug_write_read_parse_plan_trees=on
-        -c debug_raw_expression_coverage_test=on
-        -c debug_parallel_query=regress
+      PG_TEST_SERVER_POSTGRES_OPTS: >-
+        debug_copy_parse_plan_trees=on
+        debug_write_read_parse_plan_trees=on
+        debug_raw_expression_coverage_test=on
+        debug_parallel_query=regress
 
     steps:
       - *nix_sysinfo_step
diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index 873387ec168..a5005272930 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -540,6 +540,16 @@ make check PG_TEST_INITDB_EXTRA_OPTS='-k --wal-segsize=4 -c work_mem=50MB'
 </screen>
    </para>
 
+   <para>
+    Run-time server settings can be added to the
+    <filename>postgresql.conf</filename> using the environment variable
+    <envar>PG_TEST_SERVER_POSTGRES_OPTS</envar>.  The settings are given as
+    whitespace-separated <literal>name=value</literal> pairs.  For example:
+<screen>
+make check PG_TEST_SERVER_POSTGRES_OPTS='work_mem=50MB debug_discard_caches=1'
+</screen>
+   </para>
+
    <para>
     For the core regression test suite and other tests driven by
     <command>pg_regress</command>, custom run-time server settings can also be
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index f3a9583e42f..dcf0dba5b92 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -752,6 +752,24 @@ sub init
 		print $conf "max_wal_senders = 0\n";
 	}
 
+	# PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+	# environment variable.  Unlike PG_TEST_INITDB_EXTRA_OPTS, it does not
+	# disable the initdb template mechanism, as the options are only added to
+	# postgresql.conf and not passed to initdb.  The options are given as
+	# whitespace-separated "name=value" pairs.
+	#
+	# There's very similar code in pg_regress.c.
+	my $server_opts_env = $ENV{PG_TEST_SERVER_POSTGRES_OPTS};
+	if (defined $server_opts_env)
+	{
+		print $conf "# options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+		foreach my $opt (split(/\s+/, $server_opts_env))
+		{
+			print $conf "$opt\n" if $opt ne '';
+		}
+		print $conf "# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n";
+	}
+
 	print $conf "port = $port\n";
 	if ($use_tcp)
 	{
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 83073da0bcf..4da8b36369f 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2372,6 +2372,7 @@ regression_main(int argc, char *argv[],
 		const char *values[4];
 		PGPing		rv;
 		const char *initdb_extra_opts_env;
+		const char *server_opts_env;
 
 		/*
 		 * Prepare the temp instance
@@ -2500,6 +2501,29 @@ regression_main(int argc, char *argv[],
 			fclose(extra_conf);
 		}
 
+		/*
+		 * PG_TEST_SERVER_POSTGRES_OPTS allows adding server settings via an
+		 * environment variable.  Unlike PG_TEST_INITDB_EXTRA_OPTS, it does
+		 * not disable the initdb template mechanism, as the options are only
+		 * added to postgresql.conf and not passed to initdb.  The options are
+		 * given as whitespace-separated "name=value" pairs.
+		 *
+		 * There's very similar code in Cluster.pm.
+		 */
+		server_opts_env = getenv("PG_TEST_SERVER_POSTGRES_OPTS");
+		if (server_opts_env != NULL)
+		{
+			char	   *opts = pg_strdup(server_opts_env);
+			char	   *tok;
+
+			fputs("# options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+			for (tok = strtok(opts, " \t\n"); tok != NULL;
+				 tok = strtok(NULL, " \t\n"))
+				fprintf(pg_conf, "%s\n", tok);
+			free(opts);
+			fputs("# end of options from PG_TEST_SERVER_POSTGRES_OPTS\n", pg_conf);
+		}
+
 		fclose(pg_conf);
 
 #ifdef ENABLE_SSPI
-- 
2.47.3

Reply via email to