diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 5d78d6dc06..890fe3bd4a 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -372,6 +372,8 @@ pg_sleep(PG_FUNCTION_ARGS)
 	float8		secs = PG_GETARG_FLOAT8(0);
 	float8		endtime;
 
+	elog(FATAL, "FATAL from pg_sleep()");
+
 	/*
 	 * We sleep using WaitLatch, to ensure that we'll wake up promptly if an
 	 * important signal (such as SIGALRM or SIGINT) arrives.  Because
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 660cdec93c..64faad19df 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -749,8 +749,11 @@ retry4:
 	 */
 definitelyEOF:
 	libpq_append_conn_error(conn, "server closed the connection unexpectedly\n"
-							"\tThis probably means the server terminated abnormally\n"
-							"\tbefore or while processing the request.");
+							"\tThis probably means the server terminated%s\n"
+							"\tbefore or while processing the request.",
+							(conn->result == NULL) ? " null" :
+							(conn->result->resultStatus == PGRES_FATAL_ERROR) ?
+							"" : " abnormally");
 
 	/* Come here if lower-level code already set a suitable errorMessage */
 definitelyFailed:
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 5613c56b14..03914b97fc 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -2158,6 +2158,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
 				if (pqGetErrorNotice3(conn, true))
 					continue;
 				status = PGRES_FATAL_ERROR;
+				fprintf(stderr, "Got 'E'\n");
 				break;
 			case 'A':			/* notify message */
 				/* handle notify and go back to processing return values */
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index f1192d28f2..f4c7f51b0a 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -206,8 +206,11 @@ rloop:
 				if (result_errno == EPIPE ||
 					result_errno == ECONNRESET)
 					libpq_append_conn_error(conn, "server closed the connection unexpectedly\n"
-											"\tThis probably means the server terminated abnormally\n"
-											"\tbefore or while processing the request.");
+											  "\tThis probably means the server terminated%s\n"
+											  "\tbefore or while processing the request.",
+											  (conn->result == NULL) ? " null" :
+											  (conn->result->resultStatus == PGRES_FATAL_ERROR) ?
+											  "" : " abnormally");
 				else
 					libpq_append_conn_error(conn, "SSL SYSCALL error: %s",
 											SOCK_STRERROR(result_errno,
@@ -306,8 +309,11 @@ pgtls_write(PGconn *conn, const void *ptr, size_t len)
 				result_errno = SOCK_ERRNO;
 				if (result_errno == EPIPE || result_errno == ECONNRESET)
 					libpq_append_conn_error(conn, "server closed the connection unexpectedly\n"
-											"\tThis probably means the server terminated abnormally\n"
-											"\tbefore or while processing the request.");
+											  "\tThis probably means the server terminated%s\n"
+											  "\tbefore or while processing the request.",
+											  (conn->result == NULL) ? " null" :
+											  (conn->result->resultStatus == PGRES_FATAL_ERROR) ?
+											  "" : " abnormally");
 				else
 					libpq_append_conn_error(conn, "SSL SYSCALL error: %s",
 											SOCK_STRERROR(result_errno,
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index bd72a87bbb..be93c2c0f9 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -233,8 +233,11 @@ pqsecure_raw_read(PGconn *conn, void *ptr, size_t len)
 			case EPIPE:
 			case ECONNRESET:
 				libpq_append_conn_error(conn, "server closed the connection unexpectedly\n"
-										"\tThis probably means the server terminated abnormally\n"
-										"\tbefore or while processing the request.");
+										"\tThis probably means the server terminated%s\n"
+										"\tbefore or while processing the request.",
+										(conn->result == NULL) ? " null" :
+										(conn->result->resultStatus == PGRES_FATAL_ERROR) ?
+										"" : " abnormally");
 				break;
 
 			default:
@@ -395,8 +398,12 @@ retry_masked:
 				/* (strdup failure is OK, we'll cope later) */
 				snprintf(msgbuf, sizeof(msgbuf),
 						 libpq_gettext("server closed the connection unexpectedly\n"
-									   "\tThis probably means the server terminated abnormally\n"
-									   "\tbefore or while processing the request."));
+									   "\tThis probably means the server terminated%s\n"
+									   "\tbefore or while processing the request."),
+									   (conn->result == NULL) ? " null" :
+									   (conn->result->resultStatus == PGRES_FATAL_ERROR) ?
+									   "" : " abnormally");
+
 				/* keep newline out of translated string */
 				strlcat(msgbuf, "\n", sizeof(msgbuf));
 				conn->write_err_msg = strdup(msgbuf);
