mirror of https://github.com/jackc/pgx.git
Remove one allocation per pool query
parent
09f1ca5b00
commit
7e43eca3d3
18
conn_pool.go
18
conn_pool.go
|
@ -30,6 +30,8 @@ type ConnPool struct {
|
|||
pgTypes map[Oid]PgType
|
||||
pgsql_af_inet *byte
|
||||
pgsql_af_inet6 *byte
|
||||
txAfterClose func(tx *Tx)
|
||||
rowsAfterClose func(rows *Rows)
|
||||
}
|
||||
|
||||
type ConnPoolStat struct {
|
||||
|
@ -68,6 +70,14 @@ func NewConnPool(config ConnPoolConfig) (p *ConnPool, err error) {
|
|||
p.logLevel = LogLevelNone
|
||||
}
|
||||
|
||||
p.txAfterClose = func(tx *Tx) {
|
||||
p.Release(tx.Conn())
|
||||
}
|
||||
|
||||
p.rowsAfterClose = func(rows *Rows) {
|
||||
p.Release(rows.Conn())
|
||||
}
|
||||
|
||||
p.allConnections = make([]*Conn, 0, p.maxConnections)
|
||||
p.availableConnections = make([]*Conn, 0, p.maxConnections)
|
||||
p.preparedStatements = make(map[string]*PreparedStatement)
|
||||
|
@ -486,11 +496,3 @@ func (p *ConnPool) BeginIso(iso string) (*Tx, error) {
|
|||
return tx, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ConnPool) txAfterClose(tx *Tx) {
|
||||
p.Release(tx.Conn())
|
||||
}
|
||||
|
||||
func (p *ConnPool) rowsAfterClose(rows *Rows) {
|
||||
p.Release(rows.Conn())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue