Return proper error in Tx.CopyFrom when tx has failed

issue421
Jack Christensen 2018-05-12 10:33:08 -05:00
parent 7181a0b52c
commit e096a14b3e
1 changed files with 3 additions and 0 deletions

3
tx.go
View File

@ -241,6 +241,9 @@ func (tx *Tx) QueryRowEx(ctx context.Context, sql string, options *QueryExOption
// CopyFrom delegates to the underlying *Conn
func (tx *Tx) CopyFrom(tableName Identifier, columnNames []string, rowSrc CopyFromSource) (int, error) {
if tx.Status() == TxStatusInFailure {
return 0, ErrTxInFailure
}
if tx.Status() != TxStatusInProgress {
return 0, ErrTxClosed
}