From b7fc3ebbfd5f8d7a1813021738fdffafd5bd8777 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 10 Aug 2023 18:31:37 +0200 Subject: [PATCH] conn#readReadyForQuery(): on error (E) message throw that specific error not a generic one, so that the application can decide how to handle it. Sure it is an "unexpected message", but not a protocol error: > A frontend must be prepared to accept ErrorResponse and NoticeResponse > messages whenever it is expecting any other type of message. -- https://www.postgresql.org/docs/current/protocol-flow.html --- conn.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conn.go b/conn.go index bc098360..7de91866 100644 --- a/conn.go +++ b/conn.go @@ -1809,6 +1809,10 @@ func (cn *conn) readReadyForQuery() { case 'Z': cn.processReadyForQuery(r) return + case 'E': + err := parseError(r) + cn.err.set(driver.ErrBadConn) + panic(err) default: cn.err.set(driver.ErrBadConn) errorf("unexpected message %q; expected ReadyForQuery", t)