| 709 | const uchar progress_header[2]= {(uchar) 255, (uchar) 255 }; |
| 710 | |
| 711 | void net_send_progress_packet(THD *thd) |
| 712 | { |
| 713 | uchar buff[200], *pos; |
| 714 | const char *proc_info= thd->proc_info ? thd->proc_info : ""; |
| 715 | size_t length= strlen(proc_info); |
| 716 | ulonglong progress; |
| 717 | DBUG_ENTER("net_send_progress_packet"); |
| 718 | |
| 719 | if (unlikely(!thd->net.vio)) |
| 720 | DBUG_VOID_RETURN; // Socket is closed |
| 721 | |
| 722 | pos= buff; |
| 723 | /* |
| 724 | Store number of strings first. This allows us to later expand the |
| 725 | progress indicator if needed. |
| 726 | */ |
| 727 | *pos++= (uchar) 1; // Number of strings |
| 728 | *pos++= (uchar) thd->progress.stage + 1; |
| 729 | /* |
| 730 | We have the MY_MAX() here to avoid problems if max_stage is not set, |
| 731 | which may happen during automatic repair of table |
| 732 | */ |
| 733 | *pos++= (uchar) MY_MAX(thd->progress.max_stage, thd->progress.stage + 1); |
| 734 | progress= 0; |
| 735 | if (thd->progress.max_counter) |
| 736 | progress= 100000ULL * thd->progress.counter / thd->progress.max_counter; |
| 737 | int3store(pos, progress); // Between 0 & 100000 |
| 738 | pos+= 3; |
| 739 | pos= net_store_data(pos, (const uchar*) proc_info, |
| 740 | MY_MIN(length, sizeof(buff)-7)); |
| 741 | net_write_command(&thd->net, (uchar) 255, progress_header, |
| 742 | sizeof(progress_header), (uchar*) buff, |
| 743 | (uint) (pos - buff)); |
| 744 | DBUG_VOID_RETURN; |
| 745 | } |
| 746 | |
| 747 | |
| 748 | /**************************************************************************** |
no test coverage detected