service_progress_report.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef MYSQL_SERVICE_PROGRESS_REPORT_INCLUDED
  2. /* Copyright (C) 2011 Monty Program Ab
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  13. /**
  14. @file
  15. This service allows plugins to report progress of long running operations
  16. to the server. The progress report is visible in SHOW PROCESSLIST,
  17. INFORMATION_SCHEMA.PROCESSLIST, and is sent to the client
  18. if requested.
  19. The functions are documented at
  20. https://mariadb.com/kb/en/progress-reporting/#how-to-add-support-for-progress-reporting-to-a-storage-engine
  21. */
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, \
  26. __func__, __FILE__, __LINE__)
  27. extern struct progress_report_service_st {
  28. void (*thd_progress_init_func)(MYSQL_THD thd, unsigned int max_stage);
  29. void (*thd_progress_report_func)(MYSQL_THD thd,
  30. unsigned long long progress,
  31. unsigned long long max_progress);
  32. void (*thd_progress_next_stage_func)(MYSQL_THD thd);
  33. void (*thd_progress_end_func)(MYSQL_THD thd);
  34. const char *(*set_thd_proc_info_func)(MYSQL_THD, const char *info,
  35. const char *func,
  36. const char *file,
  37. unsigned int line);
  38. } *progress_report_service;
  39. #ifdef MYSQL_DYNAMIC_PLUGIN
  40. #define thd_progress_init(thd,max_stage) (progress_report_service->thd_progress_init_func((thd),(max_stage)))
  41. #define thd_progress_report(thd, progress, max_progress) (progress_report_service->thd_progress_report_func((thd), (progress), (max_progress)))
  42. #define thd_progress_next_stage(thd) (progress_report_service->thd_progress_next_stage_func(thd))
  43. #define thd_progress_end(thd) (progress_report_service->thd_progress_end_func(thd))
  44. #define set_thd_proc_info(thd,info,func,file,line) (progress_report_service->set_thd_proc_info_func((thd),(info),(func),(file),(line)))
  45. #else
  46. /**
  47. Report progress for long running operations
  48. @param thd User thread connection handle
  49. @param progress Where we are now
  50. @param max_progress Progress will continue up to this
  51. */
  52. void thd_progress_init(MYSQL_THD thd, unsigned int max_stage);
  53. void thd_progress_report(MYSQL_THD thd,
  54. unsigned long long progress,
  55. unsigned long long max_progress);
  56. void thd_progress_next_stage(MYSQL_THD thd);
  57. void thd_progress_end(MYSQL_THD thd);
  58. const char *set_thd_proc_info(MYSQL_THD, const char * info, const char *func,
  59. const char *file, unsigned int line);
  60. #endif
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #define MYSQL_SERVICE_PROGRESS_REPORT_INCLUDED
  65. #endif