diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/copy.c | 6 | ||||
-rw-r--r-- | src/backend/tcop/fastpath.c | 19 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 38 |
3 files changed, 51 insertions, 12 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 15f43fd3d6a..1d1eacd3fbd 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -547,7 +547,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) /* Only a \. terminator is legal EOF in old protocol */ ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection with an open transaction"))); } bytesread = minread; break; @@ -566,11 +566,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) if (mtype == EOF) ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection with an open transaction"))); if (pq_getmessage(cstate->fe_msgbuf, 0)) ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("unexpected EOF on client connection"))); + errmsg("unexpected EOF on client connection with an open transaction"))); switch (mtype) { case 'd': /* CopyData */ diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index 8506b1d60f2..5c0620689e3 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -285,9 +285,22 @@ HandleFunctionRequest(StringInfo msgBuf) { if (GetOldFunctionMessage(msgBuf)) { - ereport(COMMERROR, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("unexpected EOF on client connection"))); + if (IsTransactionState()) + ereport(COMMERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("unexpected EOF on client connection with an open transaction"))); + else + { + /* + * Can't send DEBUG log messages to client at this point. + * Since we're disconnecting right away, we don't need to + * restore whereToSendOutput. + */ + whereToSendOutput = DestNone; + ereport(DEBUG1, + (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), + errmsg("unexpected EOF on client connection"))); + } return EOF; } } diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 6a745997c55..89de154bc60 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -343,9 +343,22 @@ SocketBackend(StringInfo inBuf) if (qtype == EOF) /* frontend disconnected */ { - ereport(COMMERROR, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("unexpected EOF on client connection"))); + if (IsTransactionState()) + ereport(COMMERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("unexpected EOF on client connection with an open transaction"))); + else + { + /* + * Can't send DEBUG log messages to client at this point. + * Since we're disconnecting right away, we don't need to + * restore whereToSendOutput. + */ + whereToSendOutput = DestNone; + ereport(DEBUG1, + (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), + errmsg("unexpected EOF on client connection"))); + } return qtype; } @@ -366,9 +379,22 @@ SocketBackend(StringInfo inBuf) /* old style without length word; convert */ if (pq_getstring(inBuf)) { - ereport(COMMERROR, - (errcode(ERRCODE_PROTOCOL_VIOLATION), - errmsg("unexpected EOF on client connection"))); + if (IsTransactionState()) + ereport(COMMERROR, + (errcode(ERRCODE_CONNECTION_FAILURE), + errmsg("unexpected EOF on client connection with an open transaction"))); + else + { + /* + * Can't send DEBUG log messages to client at this + * point.Since we're disconnecting right away, we + * don't need to restore whereToSendOutput. + */ + whereToSendOutput = DestNone; + ereport(DEBUG1, + (errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST), + errmsg("unexpected EOF on client connection"))); + } return EOF; } } |