2
0

Ensure write failure in CopyFrom closes connection

This commit is contained in:
Jack Christensen
2020-01-25 20:40:21 -06:00
parent 67f2418279
commit c9abb86f21
+3
View File
@@ -1101,6 +1101,9 @@ func (pgConn *PgConn) CopyFrom(ctx context.Context, r io.Reader, sql string) (Co
_, writeErr := pgConn.conn.Write(buf)
if writeErr != nil {
// Write errors are always fatal, but we can't use asyncClose because we are in a different goroutine.
pgConn.conn.Close()
copyErrChan <- writeErr
return
}