My Project
ha_ndbcluster_glue.h
00001 /*
00002    Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; version 2 of the License.
00007 
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; if not, write to the Free Software
00015    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
00016 */
00017 
00018 #ifndef HA_NDBCLUSTER_GLUE_H
00019 #define HA_NDBCLUSTER_GLUE_H
00020 
00021 #include <mysql_version.h>
00022 
00023 #ifndef MYSQL_SERVER
00024 #define MYSQL_SERVER
00025 #endif
00026 
00027 #if MYSQL_VERSION_ID >= 50501
00028 /* Include files for sql/ was split in 5.5, and ha_ndb*  uses a few.. */
00029 #include "sql_priv.h"
00030 #include "unireg.h"         // REQUIRED: for other includes
00031 #include "sql_table.h"      // build_table_filename,
00032                             // tablename_to_filename,
00033                             // filename_to_tablename
00034 #include "sql_partition.h"  // HA_CAN_*, partition_info, part_id_range
00035 #include "sql_base.h"       // close_cached_tables
00036 #include "discover.h"       // readfrm
00037 #include "sql_acl.h"        // wild_case_compare
00038 #include "transaction.h"
00039 #include "sql_test.h"       // print_where
00040 #include "key.h"            // key_restore
00041 #else
00042 #include "mysql_priv.h"
00043 #endif
00044 
00045 #include "sql_show.h"       // init_fill_schema_files_row,
00046                             // schema_table_store_record
00047 
00048 
00049 #if MYSQL_VERSION_ID >= 50501
00050 
00051 /* my_free has lost last argument */
00052 static inline
00053 void my_free(void* ptr, myf MyFlags)
00054 {
00055   my_free(ptr);
00056 }
00057 
00058 
00059 /* close_cached_tables has new signature, emulate old */
00060 static inline
00061 bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
00062                          bool wait_for_refresh, bool wait_for_placeholders)
00063 {
00064   return close_cached_tables(thd, tables, wait_for_refresh, LONG_TIMEOUT);
00065 }
00066 
00067 /* thd has no version field anymore */
00068 #define NDB_THD_HAS_NO_VERSION
00069 
00070 /* thd->binlog_query has new parameter "direct" */
00071 #define NDB_THD_BINLOG_QUERY_HAS_DIRECT
00072 
00073 /* No mysql_rm_table_part2 anymore in 5.5.8 */
00074 #define NDB_NO_MYSQL_RM_TABLE_PART2
00075 
00076 #endif
00077 
00078 extern ulong opt_server_id_mask;
00079 
00080 static inline
00081 uint32 thd_unmasked_server_id(const THD* thd)
00082 {
00083 #ifndef NDB_WITHOUT_SERVER_ID_BITS
00084   const uint32 unmasked_server_id = thd->unmasked_server_id;
00085   assert(thd->server_id == (thd->unmasked_server_id & opt_server_id_mask));
00086   return unmasked_server_id;
00087 #else
00088   return thd->server_id;
00089 #endif
00090 }
00091 
00092 
00093 /* extract the bitmask of options from THD */
00094 static inline
00095 ulonglong thd_options(const THD * thd)
00096 {
00097 #if MYSQL_VERSION_ID < 50500
00098   return thd->options;
00099 #else
00100   /* "options" has moved to "variables.option_bits" */
00101   return thd->variables.option_bits;
00102 #endif
00103 }
00104 
00105 /* set the "command" member of thd */
00106 static inline
00107 void thd_set_command(THD* thd, enum enum_server_command command)
00108 {
00109 #if MYSQL_VERSION_ID < 50600
00110   thd->command = command;
00111 #else
00112   /* "command" renamed to "m_command", use accessor function */
00113   thd->set_command(command);
00114 #endif
00115 }
00116 
00117 /* get pointer to diagnostic area for statement from THD */
00118 static inline
00119 Diagnostics_area* thd_stmt_da(THD* thd)
00120 {
00121 #if MYSQL_VERSION_ID < 50500
00122   return &(thd->main_da);
00123 #else
00124 #if MYSQL_VERSION_ID < 50603
00125   /* "main_da" has been made private and one should use "stmt_da*" */
00126   return thd->stmt_da;
00127 #else
00128   /* "stmt_da*" has been made private and one should use 'get_stmt_da()' */
00129   return thd->get_stmt_da();
00130 #endif
00131 #endif
00132 }
00133 
00134 #if MYSQL_VERSION_ID < 50500
00135 
00136 /*
00137   MySQL Server has got its own mutex type in 5.5, add backwards
00138   compatibility support allowing to write code in 7.0 that works
00139   in future MySQL Server
00140 */
00141 
00142 typedef pthread_mutex_t mysql_mutex_t;
00143 
00144 static inline
00145 int mysql_mutex_lock(mysql_mutex_t* mutex)
00146 {
00147   return pthread_mutex_lock(mutex);
00148 }
00149 
00150 static inline
00151 int mysql_mutex_unlock(mysql_mutex_t* mutex)
00152 {
00153   return pthread_mutex_unlock(mutex);
00154 }
00155 
00156 static inline
00157 void mysql_mutex_assert_owner(mysql_mutex_t* mutex)
00158 {
00159   return safe_mutex_assert_owner(mutex);
00160 }
00161 
00162 typedef pthread_cond_t mysql_cond_t;
00163 
00164 static inline
00165 int mysql_cond_wait(mysql_cond_t* cond, mysql_mutex_t* mutex)
00166 {
00167   return pthread_cond_wait(cond, mutex);
00168 }
00169 
00170 static inline
00171 int mysql_cond_timedwait(mysql_cond_t* cond, mysql_mutex_t* mutex,
00172                          struct timespec* abstime)
00173 {
00174   return pthread_cond_timedwait(cond, mutex, abstime);
00175 }
00176 
00177 #endif
00178 
00179 static inline
00180 uint partition_info_num_full_part_fields(const partition_info* part_info)
00181 {
00182 #if MYSQL_VERSION_ID < 50500
00183   return part_info->no_full_part_fields;
00184 #else
00185   /* renamed to 'num_full_part_fields' and no accessor function*/
00186   return part_info->num_full_part_fields;
00187 #endif
00188 }
00189 
00190 static inline
00191 uint partition_info_num_parts(const partition_info* part_info)
00192 {
00193 #if MYSQL_VERSION_ID < 50500
00194   return part_info->no_parts;
00195 #else
00196   /* renamed to 'num_parts' and no accessor function */
00197   return part_info->num_parts;
00198 #endif
00199 }
00200 
00201 static inline
00202 uint partition_info_num_list_values(const partition_info* part_info)
00203 {
00204 #if MYSQL_VERSION_ID < 50500
00205   return part_info->no_list_values;
00206 #else
00207   /* renamed to 'num_list_values' and no accessor function */
00208   return part_info->num_list_values;
00209 #endif
00210 }
00211 
00212 static inline
00213 bool partition_info_use_default_num_partitions(const partition_info* part_info)
00214 {
00215 #if MYSQL_VERSION_ID < 50500
00216   return part_info->use_default_no_partitions;
00217 #else
00218   /* renamed to 'use_default_num_partitions' and no accessor function */
00219   return part_info->use_default_num_partitions;
00220 #endif
00221 }
00222 
00223 static inline
00224 uint partition_info_num_subparts(const partition_info* part_info)
00225 {
00226 #if MYSQL_VERSION_ID < 50500
00227   return part_info->no_subparts;
00228 #else
00229   /* renamed to 'num_subparts' and no accessor function */
00230   return part_info->num_subparts;
00231 #endif
00232 }
00233 
00234 #if MYSQL_VERSION_ID >= 50600
00235 
00236 /* New multi range read interface replaced original mrr */
00237 #define NDB_WITH_NEW_MRR_INTERFACE
00238 
00239 #endif
00240 
00241 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines