]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Allow PostgreSQL::Test::Cluster::start() to pass postmaster options
authorFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 12:40:31 +0000 (21:40 +0900)
committerFujii Masao <fujii@postgresql.org>
Mon, 20 Jul 2026 12:40:31 +0000 (21:40 +0900)
Previously, tests that needed extra postmaster command-line options had
to invoke pg_ctl start directly, because
PostgreSQL::Test::Cluster::start() provided no way to pass them. That
bypassed the test framework's postmaster PID tracking, so a postmaster
could be left running if the test failed after startup.

Add an options parameter to
PostgreSQL::Test::Cluster::start(), which is passed to pg_ctl's
--options argument. This allows tests to use start() while
preserving the framework's normal cleanup behavior.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: JoongHyuk Shin <sjh910805@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwEpfE0CDUUODjBt7GO9U4ZF11hqga_Ci3wP8=O49oFKVw@mail.gmail.com

src/test/perl/PostgreSQL/Test/Cluster.pm

index 529f49efee1f31fb31e1c62d514bbddce46af8c5..3eae4cf6281d2869db1fc6767e5bbfd023f9f49b 100644 (file)
@@ -1139,6 +1139,12 @@ Start the node and wait until it is ready to accept connections.
 By default, failure terminates the entire F<prove> invocation.  If given,
 instead return a true or false value to indicate success or failure.
 
+=item options => B<string>
+
+Additional postmaster options passed as the value of pg_ctl's C<--options>
+argument. This must be a single string, quoted as needed by the caller.
+Do not specify C<cluster_name>; it is set from the node name.
+
 =back
 
 =cut
@@ -1150,6 +1156,12 @@ sub start
        my $pgdata = $self->data_dir;
        my $name = $self->name;
        my $ret;
+       my $options = "";
+
+       $options .= "$params{options} "
+         if defined $params{options} && $params{options} ne "";
+
+       $options .= "--cluster-name=$name";
 
        BAIL_OUT("node \"$name\" is already running") if defined $self->{_pid};
 
@@ -1168,7 +1180,7 @@ sub start
                'pg_ctl', '--wait',
                '--pgdata' => $self->data_dir,
                '--log' => $self->logfile,
-               '--options' => "--cluster-name=$name",
+               '--options' => $options,
                'start');
 
        if ($ret != 0)