Skip to content

Commit b1ef6d9

Browse files
committed
Merge commit 'cec5ebac'
2 parents 59c73af + cec5eba commit b1ef6d9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pgconn/pgconn.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,14 @@ func (pgConn *PgConn) CopyFrom(ctx context.Context, r io.Reader, sql string) (Co
13741374
close(pgConn.cleanupDone)
13751375
return CommandTag{}, normalizeTimeoutError(ctx, err)
13761376
}
1377-
msg, _ := pgConn.receiveMessage()
1377+
// peekMessage never returns err in the bufferingReceive mode - it only forwards the bufferingReceive variables.
1378+
// Therefore, the only case for receiveMessage to return err is during handling of the ErrorResponse message type
1379+
// and using pgOnError handler to determine the connection is no longer valid (and thus closing the conn).
1380+
msg, serverError := pgConn.receiveMessage()
1381+
if serverError != nil {
1382+
close(abortCopyChan)
1383+
return CommandTag{}, serverError
1384+
}
13781385

13791386
switch msg := msg.(type) {
13801387
case *pgproto3.ErrorResponse:

0 commit comments

Comments
 (0)