Bug #63375 Change the state from "Sending data" when running do_select
Submitted: 22 Nov 2011 5:36 Modified: 24 Feb 2012 10:52
Reporter: xiaobin lin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.1,5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: show processlist, State

[22 Nov 2011 5:36] xiaobin lin
Description:
The code in sql_select.cc

  thd_proc_info(thd, "Sending data");
  DBUG_PRINT("info", ("%s", thd->proc_info));
  result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list :
                                    *curr_fields_list),
                                   Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
  error= do_select(curr_join, curr_fields_list, NULL, procedure);

  This results that when running do_select, "Sending data" is shown in "show processlist", it confuses users.

How to repeat:
read the soruce code

Suggested fix:
Add a new proc_info state before run into do_select 

  thd_proc_info(thd, "Sending data");
  DBUG_PRINT("info", ("%s", thd->proc_info));
  result->send_result_set_metadata((procedure ? curr_join->procedure_fields_list :
                                    *curr_fields_list),
                                   Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
  
  thd_proc_info(thd, "Doing select");
  DBUG_PRINT("info", ("%s", thd->proc_info));
  error= do_select(curr_join, curr_fields_list, NULL, procedure);
[23 Nov 2011 16:56] Valeriy Kravchuk
Hmmm, doesn't do_select() really send some data, at least in some cases?
[24 Nov 2011 2:46] xiaobin lin
hi, Valeriy , 
  You mean that it call the function  "send_data" in do_select? But send_data do not really send data to client, the real net action is not in "protocol->send_data" but in "protocol->end_statement".
  If you mean that the proc_info of "Sending data" really means "send data to sending buffer", I seems understand it :)
[24 Nov 2011 3:01] xiaobin lin
And some case of "return big packetage", thank you
[24 Feb 2012 10:52] Georgi Kodinov
Thanks for spotting this.

I totally agree that "Sending data" is too generic and may sometimes even not be true.
If you e.g. execute a SELECT query from a stored procedure with SELECT INTO no data will be sent to the client at this point, but the state will still be "Sending data".