diff --git a/conn.go b/conn.go index 6faed577..a8c6cbc5 100644 --- a/conn.go +++ b/conn.go @@ -47,6 +47,7 @@ type Conn struct { lastActivityTime time.Time // the last time the connection was used reader *bufio.Reader // buffered reader to improve read performance wbuf [1024]byte + writeBuf WriteBuf Pid int32 // backend pid SecretKey int32 // key to use to send a cancel query message to the server RuntimeParams map[string]string // parameters that have been reported by the server diff --git a/messages.go b/messages.go index 7cc244c8..1fbd9cbc 100644 --- a/messages.go +++ b/messages.go @@ -91,7 +91,8 @@ func (self PgError) Error() string { func newWriteBuf(c *Conn, t byte) *WriteBuf { buf := append(c.wbuf[0:0], t, 0, 0, 0, 0) - return &WriteBuf{buf: buf, sizeIdx: 1, conn: c} + c.writeBuf = WriteBuf{buf: buf, sizeIdx: 1, conn: c} + return &c.writeBuf } // WrifeBuf is used build messages to send to the PostgreSQL server. It is used