From d644901f62034d01da9f680427ef3bc3c47b5a6e Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Tue, 30 Mar 2021 19:20:24 +1100
Subject: [PATCH v2] Remove redundant errdetail "The error was".

Also the errdetail part of the message is now included as part of the
primary message to make it consistent with the usual project style for errors.
---
 src/backend/commands/subscriptioncmds.c     | 13 +++++--------
 src/backend/replication/logical/tablesync.c |  8 ++++----
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index bfd3514..5282b79 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -1320,17 +1320,15 @@ ReplicationSlotDropAtPubNode(WalReceiverConn *wrconn, char *slotname, bool missi
 		{
 			/* LOG. Error, but missing_ok = true. */
 			ereport(LOG,
-					(errmsg("could not drop the replication slot \"%s\" on publisher",
-							slotname),
-					 errdetail("The error was: %s", res->err)));
+					(errmsg("could not drop replication slot \"%s\" on publisher: %s",
+							slotname, res->err)));
 		}
 		else
 		{
 			/* ERROR. */
 			ereport(ERROR,
-					(errmsg("could not drop the replication slot \"%s\" on publisher",
-							slotname),
-					 errdetail("The error was: %s", res->err)));
+					(errmsg("could not drop replication slot \"%s\" on publisher: %s",
+							slotname, res->err)));
 		}
 
 		walrcv_clear_result(res);
@@ -1545,8 +1543,7 @@ ReportSlotConnectionError(List *rstates, Oid subid, char *slotname, char *err)
 
 	ereport(ERROR,
 			(errmsg("could not connect to publisher when attempting to "
-					"drop the replication slot \"%s\"", slotname),
-			 errdetail("The error was: %s", err),
+					"drop replication slot \"%s\": %s", slotname, err),
 	/* translator: %s is an SQL ALTER command */
 			 errhint("Use %s to disassociate the subscription from the slot.",
 					 "ALTER SUBSCRIPTION ... SET (slot_name = NONE)")));
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 8494db8..0638f5c 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1043,8 +1043,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
 					  0, NULL);
 	if (res->status != WALRCV_OK_COMMAND)
 		ereport(ERROR,
-				(errmsg("table copy could not start transaction on publisher"),
-				 errdetail("The error was: %s", res->err)));
+				(errmsg("table copy could not start transaction on publisher: %s",
+						res->err)));
 	walrcv_clear_result(res);
 
 	/*
@@ -1103,8 +1103,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
 	res = walrcv_exec(wrconn, "COMMIT", 0, NULL);
 	if (res->status != WALRCV_OK_COMMAND)
 		ereport(ERROR,
-				(errmsg("table copy could not finish transaction on publisher"),
-				 errdetail("The error was: %s", res->err)));
+				(errmsg("table copy could not finish transaction on publisher: %s",
+						res->err)));
 	walrcv_clear_result(res);
 
 	table_close(rel, NoLock);
-- 
1.8.3.1

