diff --git a/conn.go b/conn.go index 6dfd5d5a..752c3ddd 100644 --- a/conn.go +++ b/conn.go @@ -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...) diff --git a/conn_pool_test.go b/conn_pool_test.go index 9aa31758..773a0272 100644 --- a/conn_pool_test.go +++ b/conn_pool_test.go @@ -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") } }() } diff --git a/conn_test.go b/conn_test.go index 62e8b7d5..60f762ed 100644 --- a/conn_test.go +++ b/conn_test.go @@ -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) } diff --git a/examples/chat/main.go b/examples/chat/main.go index 517508cc..ad8d56db 100644 --- a/examples/chat/main.go +++ b/examples/chat/main.go @@ -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) } } diff --git a/v3.md b/v3.md index 75c9385c..38c41146 100644 --- a/v3.md +++ b/v3.md @@ -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.