MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ha_ndbcluster_glue.h
1 /*
2  Copyright (c) 2010, 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 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 St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef HA_NDBCLUSTER_GLUE_H
19 #define HA_NDBCLUSTER_GLUE_H
20 
21 #include <mysql_version.h>
22 
23 #ifndef MYSQL_SERVER
24 #define MYSQL_SERVER
25 #endif
26 
27 #if MYSQL_VERSION_ID >= 50501
28 /* Include files for sql/ was split in 5.5, and ha_ndb* uses a few.. */
29 #include "sql_priv.h"
30 #include "unireg.h" // REQUIRED: for other includes
31 #include "sql_table.h" // build_table_filename,
32  // tablename_to_filename,
33  // filename_to_tablename
34 #include "sql_partition.h" // HA_CAN_*, partition_info, part_id_range
35 #include "sql_base.h" // close_cached_tables
36 #include "discover.h" // readfrm
37 #include "sql_acl.h" // wild_case_compare
38 #include "transaction.h"
39 #include "sql_test.h" // print_where
40 #include "key.h" // key_restore
41 #else
42 #include "mysql_priv.h"
43 #endif
44 
45 #include "sql_show.h" // init_fill_schema_files_row,
46  // schema_table_store_record
47 
48 
49 #if MYSQL_VERSION_ID >= 50501
50 
51 /* my_free has lost last argument */
52 static inline
53 void my_free(void* ptr, myf MyFlags)
54 {
55  my_free(ptr);
56 }
57 
58 
59 /* close_cached_tables has new signature, emulate old */
60 static inline
61 bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
62  bool wait_for_refresh, bool wait_for_placeholders)
63 {
64  return close_cached_tables(thd, tables, wait_for_refresh, LONG_TIMEOUT);
65 }
66 
67 /* thd has no version field anymore */
68 #define NDB_THD_HAS_NO_VERSION
69 
70 /* thd->binlog_query has new parameter "direct" */
71 #define NDB_THD_BINLOG_QUERY_HAS_DIRECT
72 
73 /* No mysql_rm_table_part2 anymore in 5.5.8 */
74 #define NDB_NO_MYSQL_RM_TABLE_PART2
75 
76 #endif
77 
78 extern ulong opt_server_id_mask;
79 
80 static inline
81 uint32 thd_unmasked_server_id(const THD* thd)
82 {
83 #ifndef NDB_WITHOUT_SERVER_ID_BITS
84  const uint32 unmasked_server_id = thd->unmasked_server_id;
85  assert(thd->server_id == (thd->unmasked_server_id & opt_server_id_mask));
86  return unmasked_server_id;
87 #else
88  return thd->server_id;
89 #endif
90 }
91 
92 
93 /* extract the bitmask of options from THD */
94 static inline
95 ulonglong thd_options(const THD * thd)
96 {
97 #if MYSQL_VERSION_ID < 50500
98  return thd->options;
99 #else
100  /* "options" has moved to "variables.option_bits" */
101  return thd->variables.option_bits;
102 #endif
103 }
104 
105 /* set the "command" member of thd */
106 static inline
107 void thd_set_command(THD* thd, enum enum_server_command command)
108 {
109 #if MYSQL_VERSION_ID < 50600
110  thd->command = command;
111 #else
112  /* "command" renamed to "m_command", use accessor function */
113  thd->set_command(command);
114 #endif
115 }
116 
117 /* get pointer to diagnostic area for statement from THD */
118 static inline
119 Diagnostics_area* thd_stmt_da(THD* thd)
120 {
121 #if MYSQL_VERSION_ID < 50500
122  return &(thd->main_da);
123 #else
124 #if MYSQL_VERSION_ID < 50603
125  /* "main_da" has been made private and one should use "stmt_da*" */
126  return thd->stmt_da;
127 #else
128  /* "stmt_da*" has been made private and one should use 'get_stmt_da()' */
129  return thd->get_stmt_da();
130 #endif
131 #endif
132 }
133 
134 #if MYSQL_VERSION_ID < 50500
135 
136 /*
137  MySQL Server has got its own mutex type in 5.5, add backwards
138  compatibility support allowing to write code in 7.0 that works
139  in future MySQL Server
140 */
141 
142 typedef pthread_mutex_t mysql_mutex_t;
143 
144 static inline
145 int mysql_mutex_lock(mysql_mutex_t* mutex)
146 {
147  return pthread_mutex_lock(mutex);
148 }
149 
150 static inline
151 int mysql_mutex_unlock(mysql_mutex_t* mutex)
152 {
153  return pthread_mutex_unlock(mutex);
154 }
155 
156 static inline
157 void mysql_mutex_assert_owner(mysql_mutex_t* mutex)
158 {
159  return safe_mutex_assert_owner(mutex);
160 }
161 
162 typedef pthread_cond_t mysql_cond_t;
163 
164 static inline
165 int mysql_cond_wait(mysql_cond_t* cond, mysql_mutex_t* mutex)
166 {
167  return pthread_cond_wait(cond, mutex);
168 }
169 
170 static inline
171 int mysql_cond_timedwait(mysql_cond_t* cond, mysql_mutex_t* mutex,
172  struct timespec* abstime)
173 {
174  return pthread_cond_timedwait(cond, mutex, abstime);
175 }
176 
177 #endif
178 
179 static inline
180 uint partition_info_num_full_part_fields(const partition_info* part_info)
181 {
182 #if MYSQL_VERSION_ID < 50500
183  return part_info->no_full_part_fields;
184 #else
185  /* renamed to 'num_full_part_fields' and no accessor function*/
186  return part_info->num_full_part_fields;
187 #endif
188 }
189 
190 static inline
191 uint partition_info_num_parts(const partition_info* part_info)
192 {
193 #if MYSQL_VERSION_ID < 50500
194  return part_info->no_parts;
195 #else
196  /* renamed to 'num_parts' and no accessor function */
197  return part_info->num_parts;
198 #endif
199 }
200 
201 static inline
202 uint partition_info_num_list_values(const partition_info* part_info)
203 {
204 #if MYSQL_VERSION_ID < 50500
205  return part_info->no_list_values;
206 #else
207  /* renamed to 'num_list_values' and no accessor function */
208  return part_info->num_list_values;
209 #endif
210 }
211 
212 static inline
213 bool partition_info_use_default_num_partitions(const partition_info* part_info)
214 {
215 #if MYSQL_VERSION_ID < 50500
216  return part_info->use_default_no_partitions;
217 #else
218  /* renamed to 'use_default_num_partitions' and no accessor function */
219  return part_info->use_default_num_partitions;
220 #endif
221 }
222 
223 static inline
224 uint partition_info_num_subparts(const partition_info* part_info)
225 {
226 #if MYSQL_VERSION_ID < 50500
227  return part_info->no_subparts;
228 #else
229  /* renamed to 'num_subparts' and no accessor function */
230  return part_info->num_subparts;
231 #endif
232 }
233 
234 #if MYSQL_VERSION_ID >= 50600
235 
236 /* New multi range read interface replaced original mrr */
237 #define NDB_WITH_NEW_MRR_INTERFACE
238 
239 #endif
240 
241 #endif