Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d627ce3

Browse files
committed
Disallow setting archive_library and archive_command at the same time
Setting archive_library and archive_command at the same time is now an error. Before, archive_library would take precedence over archive_command. Author: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> Discussion: https://www.postgresql.org/message-id/20220914222736.GA3042279%40nathanxps13
1 parent 8b5262f commit d627ce3

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

doc/src/sgml/config.sgml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,9 +3597,11 @@ include_dir 'conf.d'
35973597
</para>
35983598
<para>
35993599
This parameter can only be set in the <filename>postgresql.conf</filename>
3600-
file or on the server command line. It is ignored unless
3600+
file or on the server command line. It is only used if
36013601
<varname>archive_mode</varname> was enabled at server start and
3602-
<varname>archive_library</varname> is set to an empty string.
3602+
<varname>archive_library</varname> is set to an empty string. If both
3603+
<varname>archive_command</varname> and <varname>archive_library</varname>
3604+
are set, an error will be raised.
36033605
If <varname>archive_command</varname> is an empty string (the default) while
36043606
<varname>archive_mode</varname> is enabled (and <varname>archive_library</varname>
36053607
is set to an empty string), WAL archiving is temporarily
@@ -3624,7 +3626,9 @@ include_dir 'conf.d'
36243626
<para>
36253627
The library to use for archiving completed WAL file segments. If set to
36263628
an empty string (the default), archiving via shell is enabled, and
3627-
<xref linkend="guc-archive-command"/> is used. Otherwise, the specified
3629+
<xref linkend="guc-archive-command"/> is used. If both
3630+
<varname>archive_command</varname> and <varname>archive_library</varname>
3631+
are set, an error will be raised. Otherwise, the specified
36283632
shared library is used for archiving. The WAL archiver process is
36293633
restarted by the postmaster when this parameter changes. For more
36303634
information, see <xref linkend="backup-archiving-wal"/> and

src/backend/postmaster/pgarch.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,12 @@ HandlePgArchInterrupts(void)
792792
ConfigReloadPending = false;
793793
ProcessConfigFile(PGC_SIGHUP);
794794

795+
if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')
796+
ereport(ERROR,
797+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
798+
errmsg("both archive_command and archive_library set"),
799+
errdetail("Only one of archive_command, archive_library may be set.")));
800+
795801
archiveLibChanged = strcmp(XLogArchiveLibrary, archiveLib) != 0;
796802
pfree(archiveLib);
797803

@@ -825,6 +831,12 @@ LoadArchiveLibrary(void)
825831
{
826832
ArchiveModuleInit archive_init;
827833

834+
if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')
835+
ereport(ERROR,
836+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
837+
errmsg("both archive_command and archive_library set"),
838+
errdetail("Only one of archive_command, archive_library may be set.")));
839+
828840
memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks));
829841

830842
/*

0 commit comments

Comments
 (0)