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