Skip to content

Commit

Permalink
server: add log for binary execute statement (pingcap#7987)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp committed Oct 25, 2018
1 parent 73692d1 commit 56a29a3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e

err = parseStmtArgs(args, stmt.BoundParams(), nullBitmaps, stmt.GetParamsType(), paramValues)
if err != nil {
return errors.Trace(err)
return errors.Annotatef(err, "%s", cc.preparedStmt2String(stmtID))
}
}
rs, err := stmt.Execute(ctx, args...)
if err != nil {
return errors.Trace(err)
return errors.Annotatef(err, "%s", cc.preparedStmt2String(stmtID))
}
if rs == nil {
return errors.Trace(cc.writeOK())
Expand Down Expand Up @@ -558,3 +558,11 @@ func (cc *clientConn) handleSetOption(data []byte) (err error) {

return errors.Trace(cc.flush())
}

func (cc *clientConn) preparedStmt2String(stmtID uint32) string {
sv := cc.ctx.GetSessionVars()
if prepared, ok := sv.PreparedStmts[stmtID]; ok {
return prepared.Stmt.Text() + sv.GetExecuteArgumentsInfo()
}
return fmt.Sprintf("prepared statement not found, ID: %d", stmtID)
}

0 comments on commit 56a29a3

Please sign in to comment.