Skip to content

Commit

Permalink
server,session: make sure ResultSet.Close() errors return to the clie…
Browse files Browse the repository at this point in the history
…nt (#48447) (#48486)

ref #48411, close #48446
  • Loading branch information
ti-chi-bot authored Nov 10, 2023
1 parent edd6080 commit 87107b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
9 changes: 4 additions & 5 deletions pkg/server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,11 +2050,7 @@ func (cc *clientConn) handleStmt(ctx context.Context, stmt ast.StmtNode, warns [
execStmt.(*executor.ExecStmt).FinishExecuteStmt(0, err, false)
}
}
if err != nil {
return false, err
}

return false, nil
return false, err
}

func (cc *clientConn) handleFileTransInConn(ctx context.Context, status uint16) (bool, error) {
Expand Down Expand Up @@ -2282,6 +2278,9 @@ func (cc *clientConn) writeChunks(ctx context.Context, rs resultset.ResultSet, b
stmtDetail.WriteSQLRespDuration += time.Since(start)
}
}
if err := rs.Close(); err != nil {
return false, err
}

if stmtDetail != nil {
start = time.Now()
Expand Down
16 changes: 10 additions & 6 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2475,16 +2475,20 @@ const ExecStmtVarKey ExecStmtVarKeyType = 0
// RecordSet, so this struct exists and RecordSet.Close() is overrided handle that.
type execStmtResult struct {
sqlexec.RecordSet
se *session
sql sqlexec.Statement
se *session
sql sqlexec.Statement
closed bool
}

func (rs *execStmtResult) Close() error {
se := rs.se
if err := rs.RecordSet.Close(); err != nil {
return finishStmt(context.Background(), se, err, rs.sql)
if rs.closed {
return nil
}
return finishStmt(context.Background(), se, nil, rs.sql)
se := rs.se
err := rs.RecordSet.Close()
err = finishStmt(context.Background(), se, err, rs.sql)
rs.closed = true
return err
}

// rollbackOnError makes sure the next statement starts a new transaction with the latest InfoSchema.
Expand Down

0 comments on commit 87107b5

Please sign in to comment.