Skip to content

Commit

Permalink
Bug fix: restore the session auto-commit setting after commiting a tr…
Browse files Browse the repository at this point in the history
…ansaction on copy
  • Loading branch information
zachmu committed Jan 6, 2025
1 parent 8ef2480 commit 6e1dc9b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/connection_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ func (h *ConnectionHandler) copyFromFileQuery(stmt *node.CopyFrom) error {
if err = txSession.CommitTransaction(sqlCtx, txSession.GetTransaction()); err != nil {
return err
}
sqlCtx.SetIgnoreAutoCommit(false)
}

return h.send(&pgproto3.CommandComplete{
Expand Down Expand Up @@ -841,6 +842,7 @@ func (h *ConnectionHandler) handleCopyDone(_ *pgproto3.CopyDone) (stop bool, end
if err = txSession.CommitTransaction(sqlCtx, txSession.GetTransaction()); err != nil {
return false, false, err
}
sqlCtx.SetIgnoreAutoCommit(false)

h.copyFromStdinState = nil
// We send back endOfMessage=true, since the COPY DONE message ends the COPY DATA flow and the server is ready
Expand Down

0 comments on commit 6e1dc9b

Please sign in to comment.