mirror of https://github.com/jackc/pgx.git
Remove Conn.TxStatus
parent
ec513248ac
commit
69434056c6
4
conn.go
4
conn.go
|
@ -53,7 +53,7 @@ type Conn struct {
|
||||||
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
|
||||||
TxStatus byte
|
txStatus byte
|
||||||
preparedStatements map[string]*PreparedStatement
|
preparedStatements map[string]*PreparedStatement
|
||||||
channels map[string]struct{}
|
channels map[string]struct{}
|
||||||
notifications []*Notification
|
notifications []*Notification
|
||||||
|
@ -1150,7 +1150,7 @@ func (c *Conn) rxBackendKeyData(r *msgReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) rxReadyForQuery(r *msgReader) {
|
func (c *Conn) rxReadyForQuery(r *msgReader) {
|
||||||
c.TxStatus = r.readByte()
|
c.txStatus = r.readByte()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) rxRowDescription(r *msgReader) (fields []FieldDescription) {
|
func (c *Conn) rxRowDescription(r *msgReader) (fields []FieldDescription) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ func (p *ConnPool) acquire(deadline *time.Time) (*Conn, error) {
|
||||||
|
|
||||||
// Release gives up use of a connection.
|
// Release gives up use of a connection.
|
||||||
func (p *ConnPool) Release(conn *Conn) {
|
func (p *ConnPool) Release(conn *Conn) {
|
||||||
if conn.TxStatus != 'I' {
|
if conn.txStatus != 'I' {
|
||||||
conn.Exec("rollback")
|
conn.Exec("rollback")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -328,14 +328,14 @@ func TestPoolReleaseWithTransactions(t *testing.T) {
|
||||||
t.Fatal("Did not receive expected error")
|
t.Fatal("Did not receive expected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if conn.TxStatus != 'E' {
|
if conn.TxStatus() != 'E' {
|
||||||
t.Fatalf("Expected TxStatus to be 'E', instead it was '%c'", conn.TxStatus)
|
t.Fatalf("Expected TxStatus to be 'E', instead it was '%c'", conn.TxStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.Release(conn)
|
pool.Release(conn)
|
||||||
|
|
||||||
if conn.TxStatus != 'I' {
|
if conn.TxStatus() != 'I' {
|
||||||
t.Fatalf("Expected release to rollback errored transaction, but it did not: '%c'", conn.TxStatus)
|
t.Fatalf("Expected release to rollback errored transaction, but it did not: '%c'", conn.TxStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err = pool.Acquire()
|
conn, err = pool.Acquire()
|
||||||
|
@ -343,14 +343,14 @@ func TestPoolReleaseWithTransactions(t *testing.T) {
|
||||||
t.Fatalf("Unable to acquire connection: %v", err)
|
t.Fatalf("Unable to acquire connection: %v", err)
|
||||||
}
|
}
|
||||||
mustExec(t, conn, "begin")
|
mustExec(t, conn, "begin")
|
||||||
if conn.TxStatus != 'T' {
|
if conn.TxStatus() != 'T' {
|
||||||
t.Fatalf("Expected txStatus to be 'T', instead it was '%c'", conn.TxStatus)
|
t.Fatalf("Expected txStatus to be 'T', instead it was '%c'", conn.TxStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
pool.Release(conn)
|
pool.Release(conn)
|
||||||
|
|
||||||
if conn.TxStatus != 'I' {
|
if conn.TxStatus() != 'I' {
|
||||||
t.Fatalf("Expected release to rollback uncommitted transaction, but it did not: '%c'", conn.TxStatus)
|
t.Fatalf("Expected release to rollback uncommitted transaction, but it did not: '%c'", conn.TxStatus())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package pgx
|
||||||
|
|
||||||
|
// This file contains methods that expose internal pgx state to tests.
|
||||||
|
|
||||||
|
func (c *Conn) TxStatus() byte {
|
||||||
|
return c.txStatus
|
||||||
|
}
|
2
v3.md
2
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()
|
||||||
|
|
||||||
|
Remove Conn.TxStatus
|
||||||
|
|
||||||
## TODO / Possible / Investigate
|
## TODO / Possible / Investigate
|
||||||
|
|
||||||
Organize errors better
|
Organize errors better
|
||||||
|
|
Loading…
Reference in New Issue