mirror of https://github.com/jackc/pgx.git
Privatize Conn.SecretKey
parent
e390ac33f5
commit
ccc65c361a
6
conn.go
6
conn.go
|
@ -74,7 +74,7 @@ type Conn struct {
|
||||||
wbuf [1024]byte
|
wbuf [1024]byte
|
||||||
writeBuf WriteBuf
|
writeBuf WriteBuf
|
||||||
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
|
||||||
PgTypes map[OID]PgType // oids to PgTypes
|
PgTypes map[OID]PgType // oids to PgTypes
|
||||||
config ConnConfig // config used when establishing this connection
|
config ConnConfig // config used when establishing this connection
|
||||||
|
@ -1148,7 +1148,7 @@ func (c *Conn) rxErrorResponse(r *msgReader) (err PgError) {
|
||||||
|
|
||||||
func (c *Conn) rxBackendKeyData(r *msgReader) {
|
func (c *Conn) rxBackendKeyData(r *msgReader) {
|
||||||
c.pid = r.readInt32()
|
c.pid = r.readInt32()
|
||||||
c.SecretKey = r.readInt32()
|
c.secretKey = r.readInt32()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) rxReadyForQuery(r *msgReader) {
|
func (c *Conn) rxReadyForQuery(r *msgReader) {
|
||||||
|
@ -1321,7 +1321,7 @@ func (c *Conn) cancelQuery() {
|
||||||
binary.BigEndian.PutUint32(buf[0:4], 16)
|
binary.BigEndian.PutUint32(buf[0:4], 16)
|
||||||
binary.BigEndian.PutUint32(buf[4:8], 80877102)
|
binary.BigEndian.PutUint32(buf[4:8], 80877102)
|
||||||
binary.BigEndian.PutUint32(buf[8:12], uint32(c.pid))
|
binary.BigEndian.PutUint32(buf[8:12], uint32(c.pid))
|
||||||
binary.BigEndian.PutUint32(buf[12:16], uint32(c.SecretKey))
|
binary.BigEndian.PutUint32(buf[12:16], uint32(c.secretKey))
|
||||||
_, err = cancelConn.Write(buf)
|
_, err = cancelConn.Write(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -32,10 +32,6 @@ func TestConnect(t *testing.T) {
|
||||||
t.Error("Backend PID not stored")
|
t.Error("Backend PID not stored")
|
||||||
}
|
}
|
||||||
|
|
||||||
if conn.SecretKey == 0 {
|
|
||||||
t.Error("Backend secret key not stored")
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentDB string
|
var currentDB string
|
||||||
err = conn.QueryRow("select current_database()").Scan(¤tDB)
|
err = conn.QueryRow("select current_database()").Scan(¤tDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
4
v3.md
4
v3.md
|
@ -18,6 +18,8 @@ Transaction isolation level constants are now typed strings instead of bare stri
|
||||||
|
|
||||||
Conn.Pid changed to accessor method Conn.PID()
|
Conn.Pid changed to accessor method Conn.PID()
|
||||||
|
|
||||||
|
Conn.SecretKey removed
|
||||||
|
|
||||||
Remove Conn.TxStatus
|
Remove Conn.TxStatus
|
||||||
|
|
||||||
Added Context methods
|
Added Context methods
|
||||||
|
@ -50,7 +52,7 @@ dValueReader / msgReader cleanup
|
||||||
|
|
||||||
Make easier / possible to mock Conn or ConnPool (https://github.com/jackc/pgx/pull/162)
|
Make easier / possible to mock Conn or ConnPool (https://github.com/jackc/pgx/pull/162)
|
||||||
|
|
||||||
Every field that should not be set by user should be replaced by accessor method (e.g. Conn.PID, Conn.SecretKey)
|
Every field that should not be set by user should be replaced by accessor method (only ones left are Conn.RuntimeParams and Conn.PgTypes)
|
||||||
|
|
||||||
Investigate strongly typed queries. i.e. Some sort of interface where varargs of Query, Exec, and Scan wouldn't happen. Need to be some low-level interface where (probably generated) functions could (more or less) directly read and write to the connection. Clean code and type-safety / control would be the benefits. Row scanning performance is already so fast there is little to improve (go_db_bench shows under 1 microsecond per row).
|
Investigate strongly typed queries. i.e. Some sort of interface where varargs of Query, Exec, and Scan wouldn't happen. Need to be some low-level interface where (probably generated) functions could (more or less) directly read and write to the connection. Clean code and type-safety / control would be the benefits. Row scanning performance is already so fast there is little to improve (go_db_bench shows under 1 microsecond per row).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue