Disallow setting archive_library and archive_command at the same time
authorPeter Eisentraut
Tue, 15 Nov 2022 09:03:12 +0000 (10:03 +0100)
committerPeter Eisentraut
Tue, 15 Nov 2022 09:03:47 +0000 (10:03 +0100)
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 
Reviewed-by: Peter Eisentraut
Reviewed-by: Bharath Rupireddy
Discussion: https://www.postgresql.org/message-id/20220914222736.GA3042279%40nathanxps13

doc/src/sgml/config.sgml
src/backend/postmaster/pgarch.c

index 559eb898a9abc43b52be9d050b280b423d298179..bd50ea8e480896403250752e1e290130e9f3ce2c 100644 (file)
@@ -3597,9 +3597,11 @@ include_dir 'conf.d'
        
        
         This parameter can only be set in the postgresql.conf
-        file or on the server command line.  It is ignored unless
+        file or on the server command line.  It is only used if
         archive_mode was enabled at server start and
-        archive_library is set to an empty string.
+        archive_library is set to an empty string.  If both
+        archive_command and archive_library
+        are set, an error will be raised.
         If archive_command is an empty string (the default) while
         archive_mode is enabled (and archive_library
         is set to an empty string), WAL archiving is temporarily
@@ -3624,7 +3626,9 @@ include_dir 'conf.d'
        
         The library to use for archiving completed WAL file segments.  If set to
         an empty string (the default), archiving via shell is enabled, and
-         is used.  Otherwise, the specified
+         is used.  If both
+        archive_command and archive_library
+        are set, an error will be raised.  Otherwise, the specified
         shared library is used for archiving. The WAL archiver process is
         restarted by the postmaster when this parameter changes. For more
         information, see  and
index 2670e41666ac687a4ca5a8afd01f5137a1e1a6ab..fffb6a599c6fd8a0da054fc9bd19065145ad0f83 100644 (file)
@@ -792,6 +792,12 @@ HandlePgArchInterrupts(void)
        ConfigReloadPending = false;
        ProcessConfigFile(PGC_SIGHUP);
 
+       if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')
+           ereport(ERROR,
+                   (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                    errmsg("both archive_command and archive_library set"),
+                    errdetail("Only one of archive_command, archive_library may be set.")));
+
        archiveLibChanged = strcmp(XLogArchiveLibrary, archiveLib) != 0;
        pfree(archiveLib);
 
@@ -825,6 +831,12 @@ LoadArchiveLibrary(void)
 {
    ArchiveModuleInit archive_init;
 
+   if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')
+       ereport(ERROR,
+               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("both archive_command and archive_library set"),
+                errdetail("Only one of archive_command, archive_library may be set.")));
+
    memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks));
 
    /*