Rename Pid to PID

v3-experimental-wait-ping-context
Jack Christensen 2016-08-02 15:10:00 -05:00
parent 448d748991
commit 73124171e2
5 changed files with 20 additions and 18 deletions

12
conn.go
View File

@ -48,7 +48,7 @@ type Conn struct {
reader *bufio.Reader // buffered reader to improve read performance
wbuf [1024]byte
writeBuf WriteBuf
Pid int32 // backend pid
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
PgTypes map[OID]PgType // oids to PgTypes
@ -85,7 +85,7 @@ type PrepareExOptions struct {
// Notification is a message received from the PostgreSQL LISTEN/NOTIFY system
type Notification struct {
Pid int32 // backend pid that sent the notification
PID int32 // backend pid that sent the notification
Channel string // channel from which notification was received
Payload string
}
@ -1137,7 +1137,7 @@ func (c *Conn) rxErrorResponse(r *msgReader) (err PgError) {
}
func (c *Conn) rxBackendKeyData(r *msgReader) {
c.Pid = r.readInt32()
c.PID = r.readInt32()
c.SecretKey = r.readInt32()
}
@ -1180,7 +1180,7 @@ func (c *Conn) rxParameterDescription(r *msgReader) (parameters []OID) {
func (c *Conn) rxNotificationResponse(r *msgReader) {
n := new(Notification)
n.Pid = r.readInt32()
n.PID = r.readInt32()
n.Channel = r.readCString()
n.Payload = r.readCString()
c.notifications = append(c.notifications, n)
@ -1248,8 +1248,8 @@ func (c *Conn) shouldLog(lvl int) bool {
}
func (c *Conn) log(lvl int, msg string, ctx ...interface{}) {
if c.Pid != 0 {
ctx = append(ctx, "pid", c.Pid)
if c.PID != 0 {
ctx = append(ctx, "pid", c.PID)
}
c.logger.Log(lvl, msg, ctx...)

View File

@ -428,7 +428,7 @@ func TestPoolReleaseDiscardsDeadConnections(t *testing.T) {
}
}()
if _, err = c2.Exec("select pg_terminate_backend($1)", c1.Pid); err != nil {
if _, err = c2.Exec("select pg_terminate_backend($1)", c1.PID); err != nil {
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
}
@ -599,7 +599,7 @@ func TestConnPoolBeginRetry(t *testing.T) {
pool.Release(victimConn)
// Terminate connection that was released to pool
if _, err = killerConn.Exec("select pg_terminate_backend($1)", victimConn.Pid); err != nil {
if _, err = killerConn.Exec("select pg_terminate_backend($1)", victimConn.PID); err != nil {
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
}
@ -611,13 +611,13 @@ func TestConnPoolBeginRetry(t *testing.T) {
}
defer tx.Rollback()
var txPid int32
err = tx.QueryRow("select pg_backend_pid()").Scan(&txPid)
var txPID int32
err = tx.QueryRow("select pg_backend_pid()").Scan(&txPID)
if err != nil {
t.Fatalf("tx.QueryRow Scan failed: %v", err)
}
if txPid == victimConn.Pid {
t.Error("Expected txPid to defer from killed conn pid, but it didn't")
if txPID == victimConn.PID {
t.Error("Expected txPID to defer from killed conn pid, but it didn't")
}
}()
}

View File

@ -27,7 +27,7 @@ func TestConnect(t *testing.T) {
t.Error("Runtime parameters not stored")
}
if conn.Pid == 0 {
if conn.PID == 0 {
t.Error("Backend PID not stored")
}
@ -1255,7 +1255,7 @@ func TestFatalRxError(t *testing.T) {
}
defer otherConn.Close()
if _, err := otherConn.Exec("select pg_terminate_backend($1)", conn.Pid); err != nil {
if _, err := otherConn.Exec("select pg_terminate_backend($1)", conn.PID); err != nil {
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
}
@ -1281,7 +1281,7 @@ func TestFatalTxError(t *testing.T) {
}
defer otherConn.Close()
_, err = otherConn.Exec("select pg_terminate_backend($1)", conn.Pid)
_, err = otherConn.Exec("select pg_terminate_backend($1)", conn.PID)
if err != nil {
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
}

View File

@ -67,7 +67,7 @@ func listen() {
os.Exit(1)
}
fmt.Println("PID:", notification.Pid, "Channel:", notification.Channel, "Payload:", notification.Payload)
fmt.Println("PID:", notification.PID, "Channel:", notification.Channel, "Payload:", notification.Payload)
}
}

6
v3.md
View File

@ -1,7 +1,9 @@
# V3 Changes
Rename Oid to OID in accordance with Go conventions.
Rename Oid to OID in accordance with Go naming conventions.
Rename Json(b) to JSON(B) in accordance with Go conventions.
Rename Json(b) to JSON(B) in accordance with Go naming conventions.
Rename Pid to PID in accordance with Go naming conventions.
Logger interface reduced to single Log method.