From ad076cff85b10054842423bfada7d71589f78209 Mon Sep 17 00:00:00 2001
From: Gabriele Bartolini <gabriele.bartolini@2ndQuadrant.it>
Date: Tue, 23 Aug 2016 00:32:32 +0200
Subject: [PATCH] pg_receivexlog does not report flush position with
 --synchronous

---
 src/bin/pg_basebackup/receivelog.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 595213f..208536b 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -508,21 +508,17 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
 		/*
 		 * Report the flush position, so the primary can know what WAL we'll
 		 * possibly re-request, and remove older WAL safely.
-		 *
-		 * We only report it when a slot has explicitly been used, because
-		 * reporting the flush position makes one eligible as a synchronous
-		 * replica. People shouldn't include generic names in
-		 * synchronous_standby_names, but we've protected them against it so
-		 * far, so let's continue to do so in the situations when possible. If
-		 * they've got a slot, though, we need to report the flush position,
-		 * so that the master can remove WAL.
 		 */
 		reportFlushPosition = true;
 		sprintf(slotcmd, "SLOT \"%s\" ", replication_slot);
 	}
 	else
 	{
-		reportFlushPosition = false;
+		/* In case 'synchronous' is requested, report flush position */
+		if (stream->synchronous)
+			reportFlushPosition = true;
+		else
+			reportFlushPosition = false;
 		slotcmd[0] = 0;
 	}
 
-- 
2.5.4 (Apple Git-61)

