@@ -176,12 +176,12 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e
176
176
err = parseStmtArgs (args , stmt .BoundParams (), nullBitmaps , stmt .GetParamsType (), paramValues )
177
177
stmt .Reset ()
178
178
if err != nil {
179
- return errors .Annotatef (err , "%s" , cc .preparedStmt2String (stmtID ))
179
+ return errors .Annotate (err , cc .preparedStmt2String (stmtID ))
180
180
}
181
181
}
182
182
rs , err := stmt .Execute (ctx , args ... )
183
183
if err != nil {
184
- return errors .Annotatef (err , "%s" , cc .preparedStmt2String (stmtID ))
184
+ return errors .Annotate (err , cc .preparedStmt2String (stmtID ))
185
185
}
186
186
if rs == nil {
187
187
return cc .writeOK ()
@@ -199,7 +199,11 @@ func (cc *clientConn) handleStmtExecute(ctx context.Context, data []byte) (err e
199
199
// explicitly flush columnInfo to client.
200
200
return cc .flush ()
201
201
}
202
- return cc .writeResultset (ctx , rs , true , 0 , 0 )
202
+ err = cc .writeResultset (ctx , rs , true , 0 , 0 )
203
+ if err != nil {
204
+ return errors .Annotate (err , cc .preparedStmt2String (stmtID ))
205
+ }
206
+ return nil
203
207
}
204
208
205
209
// maxFetchSize constants
@@ -216,8 +220,8 @@ func (cc *clientConn) handleStmtFetch(ctx context.Context, data []byte) (err err
216
220
217
221
stmt := cc .ctx .GetStatement (int (stmtID ))
218
222
if stmt == nil {
219
- return mysql .NewErr (mysql .ErrUnknownStmtHandler ,
220
- strconv .FormatUint (uint64 (stmtID ), 10 ), "stmt_fetch" )
223
+ return errors . Annotate ( mysql .NewErr (mysql .ErrUnknownStmtHandler ,
224
+ strconv .FormatUint (uint64 (stmtID ), 10 ), "stmt_fetch" ), cc . preparedStmt2String ( stmtID ))
221
225
}
222
226
sql := ""
223
227
if prepared , ok := cc .ctx .GetStatement (int (stmtID )).(* TiDBStatement ); ok {
@@ -226,11 +230,15 @@ func (cc *clientConn) handleStmtFetch(ctx context.Context, data []byte) (err err
226
230
cc .ctx .SetProcessInfo (sql , time .Now (), mysql .ComStmtExecute , 0 )
227
231
rs := stmt .GetResultSet ()
228
232
if rs == nil {
229
- return mysql .NewErr (mysql .ErrUnknownStmtHandler ,
230
- strconv .FormatUint (uint64 (stmtID ), 10 ), "stmt_fetch_rs" )
233
+ return errors . Annotate ( mysql .NewErr (mysql .ErrUnknownStmtHandler ,
234
+ strconv .FormatUint (uint64 (stmtID ), 10 ), "stmt_fetch_rs" ), cc . preparedStmt2String ( stmtID ))
231
235
}
232
236
233
- return cc .writeResultset (ctx , rs , true , mysql .ServerStatusCursorExists , int (fetchSize ))
237
+ err = cc .writeResultset (ctx , rs , true , mysql .ServerStatusCursorExists , int (fetchSize ))
238
+ if err != nil {
239
+ return errors .Annotate (err , cc .preparedStmt2String (stmtID ))
240
+ }
241
+ return nil
234
242
}
235
243
236
244
func parseStmtFetchCmd (data []byte ) (uint32 , uint32 , error ) {
@@ -571,5 +579,5 @@ func (cc *clientConn) preparedStmt2String(stmtID uint32) string {
571
579
if prepared , ok := sv .PreparedStmts [stmtID ]; ok {
572
580
return prepared .Stmt .Text () + sv .GetExecuteArgumentsInfo ()
573
581
}
574
- return fmt . Sprintf ( "prepared statement not found, ID: %d" , stmtID )
582
+ return "prepared statement not found, ID: " + strconv . FormatUint ( uint64 ( stmtID ), 10 )
575
583
}
0 commit comments