service_kill_statement.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 2013, Monty Program Ab.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. #ifndef MYSQL_SERVICE_KILL_STATEMENT_INCLUDED
  13. #define MYSQL_SERVICE_KILL_STATEMENT_INCLUDED
  14. /**
  15. @file
  16. This service provides functions that allow plugins to support
  17. the KILL statement.
  18. In MySQL support for the KILL statement is cooperative. The KILL
  19. statement only sets a "killed" flag. This function returns the value
  20. of that flag. A thread should check it often, especially inside
  21. time-consuming loops, and gracefully abort the operation if it is
  22. non-zero.
  23. thd_is_killed(thd)
  24. @return 0 - no KILL statement was issued, continue normally
  25. @return 1 - there was a KILL statement, abort the execution.
  26. thd_kill_level(thd)
  27. @return thd_kill_levels_enum values
  28. */
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. enum thd_kill_levels {
  33. THD_IS_NOT_KILLED=0,
  34. THD_ABORT_SOFTLY=50, /**< abort when possible, don't leave tables corrupted */
  35. THD_ABORT_ASAP=100, /**< abort asap */
  36. };
  37. extern struct kill_statement_service_st {
  38. enum thd_kill_levels (*thd_kill_level_func)(const MYSQL_THD);
  39. } *thd_kill_statement_service;
  40. /* backward compatibility helper */
  41. #define thd_killed(THD) (thd_kill_level(THD) == THD_ABORT_ASAP)
  42. #ifdef MYSQL_DYNAMIC_PLUGIN
  43. #define thd_kill_level(THD) \
  44. thd_kill_statement_service->thd_kill_level_func(THD)
  45. #else
  46. enum thd_kill_levels thd_kill_level(const MYSQL_THD);
  47. #endif
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif