From e4892c68184e199c3117a8f8b52da22a77702a05 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 16 Aug 2017 19:46:50 -0400
Subject: [PATCH] pg_dump: Support using synchronized snapshots on standbys

This became possible by commit
6c2003f8a1bbc7c192a2e83ec51581c018aa162f.  This just makes pg_dump aware
of it and updates the documentation.

Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
---
 doc/src/sgml/ref/pg_dump.sgml | 18 ++++++++++--------
 src/bin/pg_dump/pg_dump.c     |  4 ++--
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index bafa031e1a8..3c088f33558 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -337,14 +337,16 @@ PostgreSQL documentation
         but to abort the dump.
        </para>
        <para>
-        For a consistent backup, the database server needs to support synchronized snapshots,
-        a feature that was introduced in <productname>PostgreSQL</productname> 9.2. With this
-        feature, database clients can ensure they see the same data set even though they use
-        different connections. <command>pg_dump -j</command> uses multiple database
-        connections; it connects to the database once with the master process and
-        once again for each worker job. Without the synchronized snapshot feature, the
-        different worker jobs wouldn't be guaranteed to see the same data in each connection,
-        which could lead to an inconsistent backup.
+        For a consistent backup, the database server needs to support
+        synchronized snapshots, a feature that was introduced in
+        <productname>PostgreSQL</productname> 9.2 for primary servers and 10
+        for standbys. With this feature, database clients can ensure they see
+        the same data set even though they use different connections.
+        <command>pg_dump -j</command> uses multiple database connections; it
+        connects to the database once with the master process and once again
+        for each worker job. Without the synchronized snapshot feature, the
+        different worker jobs wouldn't be guaranteed to see the same data in
+        each connection, which could lead to an inconsistent backup.
        </para>
        <para>
         If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 2d8bb32dc07..b93dd8bf3c1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -1131,9 +1131,9 @@ setup_connection(Archive *AH, const char *dumpencoding,
 			 AH->remoteVersion >= 90200 &&
 			 !dopt->no_synchronized_snapshots)
 	{
-		if (AH->isStandby)
+		if (AH->isStandby && AH->remoteVersion < 100000)
 			exit_horribly(NULL,
-						  "Synchronized snapshots are not supported on standby servers.\n"
+						  "Synchronized snapshots on standby servers are not supported by this server version.\n"
 						  "Run with --no-synchronized-snapshots instead if you do not need\n"
 						  "synchronized snapshots.\n");
 
-- 
GitLab