From 3901f3ef884e37bae69ea18962533af74521b1aa Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Fri, 12 Apr 2019 16:57:25 -0500 Subject: [PATCH] Add Conn.PgConn escape hatch --- conn.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/conn.go b/conn.go index 00f3eb2d..05b07e11 100644 --- a/conn.go +++ b/conn.go @@ -724,6 +724,13 @@ func (c *Conn) LastStmtSent() bool { return c.lastStmtSent } +// PgConn returns the underlying *pgconn.PgConn. This is an escape hatch method that allows lower level access to the +// PostgreSQL connection than pgx exposes. +// +// It is strongly recommended that the connection be idle (no in-progress queries) before the underlying *pgconn.PgConn +// is used and the connection must be returned to the same state before any *pgx.Conn methods are again used. +func (c *Conn) PgConn() *pgconn.PgConn { return c.pgConn } + // Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced // positionally from the sql string as $1, $2, etc. func (c *Conn) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error) {