Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: add log for binary execute statement #7987

Merged
merged 4 commits into from
Oct 23, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,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 @@ -564,3 +564,11 @@ func (cc *clientConn) handleSetOption(data []byte) (err error) {

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

func (cc *clientConn) preparedStmt2String(stmtID uint32) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comment for this function if we only use it for errorMsg
or
s/ preparedStmt2String/ preparedStmt2ErrMsg

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we the function name should describe what it does. This function could also be used in other features, e.g. show processlist, so I think it is not necessary to change the name.

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)
}