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