2
0

addressing the comments

add copy methods to the Tx struct
This commit is contained in:
Murat Kabilov
2018-08-07 23:44:02 +03:00
parent 5315995dfa
commit 4e9a696434
6 changed files with 54 additions and 35 deletions
+19
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io"
"time"
"github.com/pkg/errors"
@@ -237,6 +238,24 @@ func (tx *Tx) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFr
return tx.conn.CopyFrom(tableName, columnNames, rowSrc)
}
// CopyFromReader delegates to the underlying *Conn
func (tx *Tx) CopyFromReader(r io.Reader, sql string) error {
if tx.status != TxStatusInProgress {
return ErrTxClosed
}
return tx.conn.CopyFromReader(r, sql)
}
// CopyToWriter delegates to the underlying *Conn
func (tx *Tx) CopyToWriter(w io.Writer, sql string, args ...interface{}) error {
if tx.status != TxStatusInProgress {
return ErrTxClosed
}
return tx.conn.CopyToWriter(w, sql, args...)
}
// Status returns the status of the transaction from the set of
// pgx.TxStatus* constants.
func (tx *Tx) Status() int8 {