Recreate the frontend in Construct with the new bgReader
https://github.com/jackc/pgx/pull/1629#discussion_r1251472215
This commit is contained in:
@@ -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
|
// 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.
|
// 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
|
// Due to the necessary exposure of internal implementation details, it is not covered by the semantic versioning
|
||||||
// compatibility.
|
// compatibility.
|
||||||
func Construct(hc *HijackedConn) (*PgConn, error) {
|
func Construct(hc *HijackedConn) (*PgConn, error) {
|
||||||
@@ -1801,6 +1803,7 @@ func Construct(hc *HijackedConn) (*PgConn, error) {
|
|||||||
pgConn.bgReader = bgreader.New(pgConn.conn)
|
pgConn.bgReader = bgreader.New(pgConn.conn)
|
||||||
pgConn.slowWriteTimer = time.AfterFunc(time.Duration(math.MaxInt64), pgConn.bgReader.Start)
|
pgConn.slowWriteTimer = time.AfterFunc(time.Duration(math.MaxInt64), pgConn.bgReader.Start)
|
||||||
pgConn.slowWriteTimer.Stop()
|
pgConn.slowWriteTimer.Stop()
|
||||||
|
pgConn.frontend = hc.Config.BuildFrontend(pgConn.bgReader, pgConn.conn)
|
||||||
|
|
||||||
return pgConn, nil
|
return pgConn, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user