diff --git a/conn.go b/conn.go index 6ff0ef8b..c38a2aad 100644 --- a/conn.go +++ b/conn.go @@ -68,10 +68,14 @@ func (c *conn) rxMsg() (msg interface{}, err error) { } switch t { + case 'K': + return c.rxBackendKeyData(buf), nil case 'R': return c.rxAuthenticationX(buf) case 'S': return c.rxParameterStatus(buf) + case 'Z': + return c.rxReadyForQuery(buf), nil default: return nil, fmt.Errorf("Received unknown message type: %c", t) } @@ -125,3 +129,16 @@ func (c *conn) rxParameterStatus(buf []byte) (msg *parameterStatus, err error) { msg.value, err = r.ReadString(0) return } + +func (c *conn) rxBackendKeyData(buf []byte) (msg *backendKeyData) { + msg = new(backendKeyData) + msg.pid = int32(binary.BigEndian.Uint32(buf[:4])) + msg.secretKey = int32(binary.BigEndian.Uint32(buf[4:8])) + return +} + +func (c *conn) rxReadyForQuery(buf []byte) (msg *readyForQuery) { + msg = new(readyForQuery) + msg.txStatus = buf[0] + return +} diff --git a/messages.go b/messages.go index b5428742..5d24c22c 100644 --- a/messages.go +++ b/messages.go @@ -46,3 +46,20 @@ type parameterStatus struct { func (self *parameterStatus) String() string { return fmt.Sprintf("ParameterStatus %s: %s", self.name, self.value) } + +type backendKeyData struct { + pid int32 + secretKey int32 +} + +func (self *backendKeyData) String() string { + return fmt.Sprintf("BackendKeyData pid: %d, secretKey: %d", self.pid, self.secretKey) +} + +type readyForQuery struct { + txStatus byte +} + +func (self *readyForQuery) String() string { + return fmt.Sprintf("ReadyForQuery txStatus: %c", self.txStatus) +}