Skip to content

Commit

Permalink
This is an automated cherry-pick of #48447
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
tiancaiamao authored and ti-chi-bot committed Nov 9, 2023
1 parent 8b2e9f9 commit 3b1327e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 17 additions & 5 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2053,11 +2053,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) handleQuerySpecial(ctx context.Context, status uint16) (bool, error) {
Expand Down Expand Up @@ -2250,7 +2246,23 @@ func (cc *clientConn) writeChunks(ctx context.Context, rs ResultSet, binary bool
stmtDetail.WriteSQLRespDuration += time.Since(start)
}
}
<<<<<<< HEAD:server/conn.go
return false, cc.writeEOF(serverStatus)
=======
if err := rs.Close(); err != nil {
return false, err
}

if stmtDetail != nil {
start = time.Now()
}

err := cc.writeEOF(ctx, serverStatus)
if stmtDetail != nil {
stmtDetail.WriteSQLRespDuration += time.Since(start)
}
return false, err
>>>>>>> 24c7f8c39b3 (server,session: make sure ResultSet.Close() errors return to the client (#48447)):pkg/server/conn.go
}

// writeChunksWithFetchSize writes data from a Chunk, which filled data by a ResultSet, into a connection.
Expand Down
16 changes: 10 additions & 6 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2164,16 +2164,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 3b1327e

Please sign in to comment.