@@ -62,7 +62,7 @@ type Conn struct {
6262 doneChan chan struct {}
6363 closedChan chan error
6464
65- ConnInfo * pgtype.ConnInfo
65+ connInfo * pgtype.ConnInfo
6666
6767 wbuf []byte
6868 preallocatedRows []connRows
@@ -171,7 +171,7 @@ func connect(ctx context.Context, config *ConnConfig) (c *Conn, err error) {
171171
172172 c = & Conn {
173173 config : config ,
174- ConnInfo : pgtype .NewConnInfo (),
174+ connInfo : pgtype .NewConnInfo (),
175175 logLevel : config .LogLevel ,
176176 logger : config .Logger ,
177177 }
@@ -408,6 +408,9 @@ func (c *Conn) PgConn() *pgconn.PgConn { return c.pgConn }
408408// StatementCache returns the statement cache used for this connection.
409409func (c * Conn ) StatementCache () stmtcache.Cache { return c .stmtcache }
410410
411+ // ConnInfo returns the connection info used for this connection.
412+ func (c * Conn ) ConnInfo () * pgtype.ConnInfo { return c .connInfo }
413+
411414// Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced
412415// positionally from the sql string as $1, $2, etc.
413416func (c * Conn ) Exec (ctx context.Context , sql string , arguments ... interface {}) (pgconn.CommandTag , error ) {
@@ -499,14 +502,14 @@ func (c *Conn) execParamsAndPreparedPrefix(sd *pgconn.StatementDescription, argu
499502 }
500503
501504 for i := range args {
502- err = c .eqb .AppendParam (c .ConnInfo , sd .ParamOIDs [i ], args [i ])
505+ err = c .eqb .AppendParam (c .connInfo , sd .ParamOIDs [i ], args [i ])
503506 if err != nil {
504507 return err
505508 }
506509 }
507510
508511 for i := range sd .Fields {
509- c .eqb .AppendResultFormat (c .ConnInfo .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
512+ c .eqb .AppendResultFormat (c .ConnInfo () .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
510513 }
511514
512515 return nil
@@ -542,7 +545,7 @@ func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *con
542545
543546 r .ctx = ctx
544547 r .logger = c
545- r .connInfo = c .ConnInfo
548+ r .connInfo = c .connInfo
546549 r .startTime = time .Now ()
547550 r .sql = sql
548551 r .args = args
@@ -642,7 +645,7 @@ optionLoop:
642645 }
643646
644647 for i := range args {
645- err = c .eqb .AppendParam (c .ConnInfo , sd .ParamOIDs [i ], args [i ])
648+ err = c .eqb .AppendParam (c .connInfo , sd .ParamOIDs [i ], args [i ])
646649 if err != nil {
647650 rows .fatal (err )
648651 return rows , rows .err
@@ -658,7 +661,7 @@ optionLoop:
658661
659662 if resultFormats == nil {
660663 for i := range sd .Fields {
661- c .eqb .AppendResultFormat (c .ConnInfo .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
664+ c .eqb .AppendResultFormat (c .ConnInfo () .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
662665 }
663666
664667 resultFormats = c .eqb .resultFormats
@@ -732,14 +735,14 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults {
732735 }
733736
734737 for i := range args {
735- err = c .eqb .AppendParam (c .ConnInfo , sd .ParamOIDs [i ], args [i ])
738+ err = c .eqb .AppendParam (c .connInfo , sd .ParamOIDs [i ], args [i ])
736739 if err != nil {
737740 return & batchResults {ctx : ctx , conn : c , err : err }
738741 }
739742 }
740743
741744 for i := range sd .Fields {
742- c .eqb .AppendResultFormat (c .ConnInfo .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
745+ c .eqb .AppendResultFormat (c .ConnInfo () .ResultFormatCodeForOID (sd .Fields [i ].DataTypeOID ))
743746 }
744747
745748 if sd .Name == "" {
@@ -770,7 +773,7 @@ func (c *Conn) sanitizeForSimpleQuery(sql string, args ...interface{}) (string,
770773 var err error
771774 valueArgs := make ([]interface {}, len (args ))
772775 for i , a := range args {
773- valueArgs [i ], err = convertSimpleArgument (c .ConnInfo , a )
776+ valueArgs [i ], err = convertSimpleArgument (c .connInfo , a )
774777 if err != nil {
775778 return "" , err
776779 }
0 commit comments