From cd46cdd450a2c447d50bf30d6a5be513a0631fdf Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 8 Jul 2023 11:39:39 -0500 Subject: [PATCH] Recreate the frontend in Construct with the new bgReader https://github.com/jackc/pgx/pull/1629#discussion_r1251472215 --- pgconn/pgconn.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pgconn/pgconn.go b/pgconn/pgconn.go index 46920cb4..8a9f80a6 100644 --- a/pgconn/pgconn.go +++ b/pgconn/pgconn.go @@ -1780,6 +1780,8 @@ func (pgConn *PgConn) Hijack() (*HijackedConn, error) { // Construct created a PgConn from an already established connection to a PostgreSQL server. This is the inverse of // PgConn.Hijack. The connection must be in an idle state. // +// hc.Frontend is replaced by a new pgproto3.Frontend built by hc.Config.BuildFrontend. +// // Due to the necessary exposure of internal implementation details, it is not covered by the semantic versioning // compatibility. func Construct(hc *HijackedConn) (*PgConn, error) { @@ -1801,6 +1803,7 @@ func Construct(hc *HijackedConn) (*PgConn, error) { pgConn.bgReader = bgreader.New(pgConn.conn) pgConn.slowWriteTimer = time.AfterFunc(time.Duration(math.MaxInt64), pgConn.bgReader.Start) pgConn.slowWriteTimer.Stop() + pgConn.frontend = hc.Config.BuildFrontend(pgConn.bgReader, pgConn.conn) return pgConn, nil }