From 12c6319244e4836c5bb6bbff2f786bf73487c574 Mon Sep 17 00:00:00 2001 From: Kale Blankenship Date: Wed, 28 Aug 2019 12:50:51 -0700 Subject: [PATCH] Include ParameterOIDs when preparing statements on new pool connections ParameterOIDs passed to ConnPool.PrepareEx are used to prepare the statement on existing connections in the pool. If additional connections are later created ParameterOIDs are omitted, potentially causing query failures. --- conn_pool.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conn_pool.go b/conn_pool.go index e8972a0b..344f00d7 100644 --- a/conn_pool.go +++ b/conn_pool.go @@ -341,7 +341,8 @@ func (p *ConnPool) afterConnectionCreated(c *Conn) (*Conn, error) { } for _, ps := range p.preparedStatements { - if _, err := c.Prepare(ps.Name, ps.SQL); err != nil { + opts := &PrepareExOptions{ParameterOIDs: ps.ParameterOIDs} + if _, err := c.PrepareEx(context.Background(), ps.Name, ps.SQL, opts); err != nil { c.die(err) return nil, err }