server: add sql to com_exec/com_fetch dispatch error log (#12174)
This commit is contained in:
@ -177,12 +177,12 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e
|
||||
err = parseExecArgs(cc.ctx.GetSessionVars().StmtCtx, args, stmt.BoundParams(), nullBitmaps, stmt.GetParamsType(), paramValues)
|
||||
stmt.Reset()
|
||||
if err != nil {
|
||||
return errors.Annotatef(err, "%s", cc.preparedStmt2String(stmtID))
|
||||
return errors.Annotate(err, cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
}
|
||||
rs, err := stmt.Execute(ctx, args)
|
||||
if err != nil {
|
||||
return errors.Annotatef(err, "%s", cc.preparedStmt2String(stmtID))
|
||||
return errors.Annotate(err, cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
if rs == nil {
|
||||
return cc.writeOK()
|
||||
@ -200,7 +200,11 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e
|
||||
// explicitly flush columnInfo to client.
|
||||
return cc.flush()
|
||||
}
|
||||
return cc.writeResultset(ctx, rs, true, 0, 0)
|
||||
err = cc.writeResultset(ctx, rs, true, 0, 0)
|
||||
if err != nil {
|
||||
return errors.Annotate(err, cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// maxFetchSize constants
|
||||
@ -217,8 +221,8 @@ func (cc *clientConn) handleStmtFetch(ctx context.Context, data []byte) (err err
|
||||
|
||||
stmt := cc.ctx.GetStatement(int(stmtID))
|
||||
if stmt == nil {
|
||||
return mysql.NewErr(mysql.ErrUnknownStmtHandler,
|
||||
strconv.FormatUint(uint64(stmtID), 10), "stmt_fetch")
|
||||
return errors.Annotate(mysql.NewErr(mysql.ErrUnknownStmtHandler,
|
||||
strconv.FormatUint(uint64(stmtID), 10), "stmt_fetch"), cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
sql := ""
|
||||
if prepared, ok := cc.ctx.GetStatement(int(stmtID)).(*TiDBStatement); ok {
|
||||
@ -227,11 +231,15 @@ func (cc *clientConn) handleStmtFetch(ctx context.Context, data []byte) (err err
|
||||
cc.ctx.SetProcessInfo(sql, time.Now(), mysql.ComStmtExecute, 0)
|
||||
rs := stmt.GetResultSet()
|
||||
if rs == nil {
|
||||
return mysql.NewErr(mysql.ErrUnknownStmtHandler,
|
||||
strconv.FormatUint(uint64(stmtID), 10), "stmt_fetch_rs")
|
||||
return errors.Annotate(mysql.NewErr(mysql.ErrUnknownStmtHandler,
|
||||
strconv.FormatUint(uint64(stmtID), 10), "stmt_fetch_rs"), cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
|
||||
return cc.writeResultset(ctx, rs, true, mysql.ServerStatusCursorExists, int(fetchSize))
|
||||
err = cc.writeResultset(ctx, rs, true, mysql.ServerStatusCursorExists, int(fetchSize))
|
||||
if err != nil {
|
||||
return errors.Annotate(err, cc.preparedStmt2String(stmtID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseStmtFetchCmd(data []byte) (uint32, uint32, error) {
|
||||
@ -619,5 +627,5 @@ func (cc *clientConn) preparedStmt2String(stmtID uint32) string {
|
||||
if prepared, ok := sv.PreparedStmts[stmtID]; ok {
|
||||
return prepared.Stmt.Text() + sv.GetExecuteArgumentsInfo()
|
||||
}
|
||||
return fmt.Sprintf("prepared statement not found, ID: %d", stmtID)
|
||||
return "prepared statement not found, ID: " + strconv.FormatUint(uint64(stmtID), 10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user