1 /*
2    Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef NDB_THD_H
26 #define NDB_THD_H
27 
28 #include <mysql/plugin.h>
29 
30 extern handlerton* ndbcluster_hton;
31 
32 /* Get Thd_ndb pointer from THD */
33 static inline
34 class Thd_ndb*
thd_get_thd_ndb(THD * thd)35 thd_get_thd_ndb(THD* thd)
36 {
37   return (class Thd_ndb *) thd_get_ha_data(thd, ndbcluster_hton);
38 }
39 
40 /* Backward compatibility alias for 'thd_get_thd_ndb'  */
41 static inline
42 class Thd_ndb*
get_thd_ndb(THD * thd)43 get_thd_ndb(THD* thd)
44 {
45   return thd_get_thd_ndb(thd);
46 }
47 
48 
49 /* Set Thd_ndb pointer for THD */
50 static inline
51 void
thd_set_thd_ndb(THD * thd,class Thd_ndb * thd_ndb)52 thd_set_thd_ndb(THD *thd, class Thd_ndb *thd_ndb)
53 {
54   thd_set_ha_data(thd, ndbcluster_hton, thd_ndb);
55 }
56 
57 
58 /* Make sure THD has a Thd_ndb struct assigned */
59 class Ndb* check_ndb_in_thd(THD* thd, bool validate_ndb= false);
60 
61 
62 /* Print thd's list of warnings to error log */
63 void
64 thd_print_warning_list(THD* thd, const char* prefix);
65 
66 /*
67   Determine if THD is applying binlog. ie. either marked as
68   slave thread or being in "pseudo slave mode"
69 */
70 bool
71 applying_binlog(const THD* thd);
72 
73 #endif
74