mirror of https://github.com/jackc/pgx.git
Rename Pid to PID
parent
448d748991
commit
73124171e2
12
conn.go
12
conn.go
|
@ -48,7 +48,7 @@ type Conn struct {
|
||||||
reader *bufio.Reader // buffered reader to improve read performance
|
reader *bufio.Reader // buffered reader to improve read performance
|
||||||
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
|
||||||
|
@ -85,7 +85,7 @@ type PrepareExOptions struct {
|
||||||
|
|
||||||
// Notification is a message received from the PostgreSQL LISTEN/NOTIFY system
|
// Notification is a message received from the PostgreSQL LISTEN/NOTIFY system
|
||||||
type Notification struct {
|
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
|
Channel string // channel from which notification was received
|
||||||
Payload string
|
Payload string
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1137,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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,7 +1180,7 @@ func (c *Conn) rxParameterDescription(r *msgReader) (parameters []OID) {
|
||||||
|
|
||||||
func (c *Conn) rxNotificationResponse(r *msgReader) {
|
func (c *Conn) rxNotificationResponse(r *msgReader) {
|
||||||
n := new(Notification)
|
n := new(Notification)
|
||||||
n.Pid = r.readInt32()
|
n.PID = r.readInt32()
|
||||||
n.Channel = r.readCString()
|
n.Channel = r.readCString()
|
||||||
n.Payload = r.readCString()
|
n.Payload = r.readCString()
|
||||||
c.notifications = append(c.notifications, n)
|
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{}) {
|
func (c *Conn) log(lvl int, msg string, ctx ...interface{}) {
|
||||||
if c.Pid != 0 {
|
if c.PID != 0 {
|
||||||
ctx = append(ctx, "pid", c.Pid)
|
ctx = append(ctx, "pid", c.PID)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Log(lvl, msg, ctx...)
|
c.logger.Log(lvl, msg, ctx...)
|
||||||
|
|
|
@ -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)
|
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ func TestConnPoolBeginRetry(t *testing.T) {
|
||||||
pool.Release(victimConn)
|
pool.Release(victimConn)
|
||||||
|
|
||||||
// Terminate connection that was released to pool
|
// 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)
|
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,13 +611,13 @@ func TestConnPoolBeginRetry(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
|
|
||||||
var txPid int32
|
var txPID int32
|
||||||
err = tx.QueryRow("select pg_backend_pid()").Scan(&txPid)
|
err = tx.QueryRow("select pg_backend_pid()").Scan(&txPID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("tx.QueryRow Scan failed: %v", err)
|
t.Fatalf("tx.QueryRow Scan failed: %v", err)
|
||||||
}
|
}
|
||||||
if txPid == victimConn.Pid {
|
if txPID == victimConn.PID {
|
||||||
t.Error("Expected txPid to defer from killed conn pid, but it didn't")
|
t.Error("Expected txPID to defer from killed conn pid, but it didn't")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ func TestConnect(t *testing.T) {
|
||||||
t.Error("Runtime parameters not stored")
|
t.Error("Runtime parameters not stored")
|
||||||
}
|
}
|
||||||
|
|
||||||
if conn.Pid == 0 {
|
if conn.PID == 0 {
|
||||||
t.Error("Backend PID not stored")
|
t.Error("Backend PID not stored")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1255,7 +1255,7 @@ func TestFatalRxError(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer otherConn.Close()
|
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)
|
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ func TestFatalTxError(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer otherConn.Close()
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
|
t.Fatalf("Unable to kill backend PostgreSQL process: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ func listen() {
|
||||||
os.Exit(1)
|
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
6
v3.md
|
@ -1,7 +1,9 @@
|
||||||
# V3 Changes
|
# 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.
|
Logger interface reduced to single Log method.
|
||||||
|
|
Loading…
Reference in New Issue