pgx-vs-pq
Jack Christensen 2013-04-08 20:16:49 -05:00
parent 86099237bd
commit d1a586ed64
4 changed files with 13 additions and 15 deletions

11
conn.go
View File

@ -9,11 +9,11 @@ import (
) )
type conn struct { type conn struct {
conn net.Conn // the underlying TCP or unix domain socket connection conn net.Conn // the underlying TCP or unix domain socket connection
rowDesc rowDescription // current query rowDescription rowDesc rowDescription // current query rowDescription
buf []byte // work buffer to avoid constant alloc and dealloc buf []byte // work buffer to avoid constant alloc and dealloc
pid int32 // backend pid pid int32 // backend pid
secretKey int32 // key to use to send a cancel query message to the server 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 runtimeParams map[string]string // parameters that have been reported by the server
} }
@ -240,7 +240,6 @@ func (c *conn) rxDataRow(buf []byte) (row map[string]string, err error) {
return return
} }
func (c *conn) rxCommandComplete(buf []byte) string { func (c *conn) rxCommandComplete(buf []byte) string {
r := newMessageReader(buf) r := newMessageReader(buf)
return r.readString() return r.readString()

View File

@ -28,7 +28,6 @@ func TestConnect(t *testing.T) {
} }
} }
func TestQuery(t *testing.T) { func TestQuery(t *testing.T) {
conn, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"}) conn, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"})
if err != nil { if err != nil {
@ -53,4 +52,4 @@ func TestQuery(t *testing.T) {
if err != nil { if err != nil {
t.Fatal("Unable to close connection") t.Fatal("Unable to close connection")
} }
} }

View File

@ -1,8 +1,8 @@
package pqx package pqx
import ( import (
"encoding/binary"
"bytes" "bytes"
"encoding/binary"
) )
type messageReader []byte type messageReader []byte

View File

@ -49,13 +49,13 @@ func (self *readyForQuery) String() string {
type oid int32 type oid int32
type fieldDescription struct { type fieldDescription struct {
name string name string
table oid table oid
attributeNumber int16 attributeNumber int16
dataType oid dataType oid
dataTypeSize int16 dataTypeSize int16
modifier int32 modifier int32
formatCode int16 formatCode int16
} }
type rowDescription struct { type rowDescription struct {