File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -675,16 +675,14 @@ func (h *ConnectionHandler) copyFromFileQuery(stmt *node.CopyFrom) error {
675
675
return err
676
676
}
677
677
678
- // TODO: rather than always committing the transaction here, we should respect whether a transaction was
679
- // expliclitly started and not commit if not. In order to do that, we need to not always set
680
- // ctx.GetIgnoreAutoCommit(), and instead conditionally *not* insert a transaction closing iterator during chunk
681
- // processing. We need a new query flag to effectively do the latter though.
682
- txSession , ok := sqlCtx .Session .(sql.TransactionSession )
683
- if ! ok {
684
- return fmt .Errorf ("session does not implement sql.TransactionSession" )
685
- }
686
- if err = txSession .CommitTransaction (sqlCtx , txSession .GetTransaction ()); err != nil {
687
- return err
678
+ if sqlCtx .GetTransaction () != nil && ! sqlCtx .GetIgnoreAutoCommit () {
679
+ txSession , ok := sqlCtx .Session .(sql.TransactionSession )
680
+ if ! ok {
681
+ return fmt .Errorf ("session does not implement sql.TransactionSession" )
682
+ }
683
+ if err = txSession .CommitTransaction (sqlCtx , txSession .GetTransaction ()); err != nil {
684
+ return err
685
+ }
688
686
}
689
687
690
688
return h .send (& pgproto3.CommandComplete {
You can’t perform that action at this time.
0 commit comments