#At file:///home/msvensson/mysql/7.0/ based on revid:magnus.blaudd@stripped
3894 Magnus Blåudd 2010-10-22
ndb
- add compatibility functions allowing same source to work with
different MySQL Server versions.
- Fix the following incompatibilities
- thd->options moved to thd->variables.option_bits
- PARTITION_INFO - >PARTITION_STATS
- mysql_priv.h split into multiplke include files
- my_free() has lost an argument, suprised to see that the flags
are still there(ooh, should keep quiet..)
- close_cached_tables() has changed signature
added:
sql/ha_ndbcluster_glue.h
modified:
sql/Makefile.am
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_cond.cc
=== modified file 'sql/Makefile.am'
--- a/sql/Makefile.am 2009-12-18 06:43:04 +0000
+++ b/sql/Makefile.am 2010-10-22 12:35:05 +0000
@@ -62,6 +62,7 @@ noinst_HEADERS = item.h item_func.h item
ha_ndbcluster_binlog.h ha_ndbcluster_tables.h \
ha_ndbcluster_connection.h ha_ndbcluster_connection.h \
ha_ndbcluster_lock_ext.h ha_ndbinfo.h \
+ ha_ndbcluster_glue.h \
ha_partition.h rpl_constants.h \
debug_sync.h \
opt_range.h protocol.h rpl_tblmap.h rpl_utility.h \
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2010-10-22 11:38:03 +0000
+++ b/sql/ha_ndbcluster.cc 2010-10-22 12:35:05 +0000
@@ -28,7 +28,8 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
+#include "ha_ndbcluster_glue.h"
+
#include "rpl_mi.h"
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
@@ -3655,7 +3656,7 @@ thd_allow_batch(const THD* thd)
#ifndef OPTION_ALLOW_BATCH
return false;
#else
- return (thd->options & OPTION_ALLOW_BATCH);
+ return (thd_options(thd) & OPTION_ALLOW_BATCH);
#endif
}
@@ -5748,7 +5749,7 @@ int ha_ndbcluster::info(uint flag)
}
-void ha_ndbcluster::get_dynamic_partition_info(PARTITION_INFO *stat_info,
+void ha_ndbcluster::get_dynamic_partition_info(PARTITION_STATS *stat_info,
uint part_id)
{
/*
@@ -5756,7 +5757,7 @@ void ha_ndbcluster::get_dynamic_partitio
implement ndb function which retrives the statistics
about ndb partitions.
*/
- bzero((char*) stat_info, sizeof(PARTITION_INFO));
+ bzero((char*) stat_info, sizeof(PARTITION_STATS));
return;
}
@@ -6191,7 +6192,7 @@ int ha_ndbcluster::start_statement(THD *
if (table_count == 0)
{
trans_register_ha(thd, FALSE, ndbcluster_hton);
- if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
+ if (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
{
if (!trans)
trans_register_ha(thd, TRUE, ndbcluster_hton);
@@ -6231,7 +6232,7 @@ int ha_ndbcluster::start_statement(THD *
thd_ndb->init_open_tables();
thd_ndb->query_state&= NDB_QUERY_NORMAL;
thd_ndb->m_slow_path= FALSE;
- if (!(thd->options & OPTION_BIN_LOG) ||
+ if (!(thd_options(thd) & OPTION_BIN_LOG) ||
thd->variables.binlog_format == BINLOG_FORMAT_STMT)
{
thd_ndb->trans_options|= TNTO_NO_LOGGING;
@@ -6246,7 +6247,7 @@ int ha_ndbcluster::start_statement(THD *
Check if it should be read or write lock
*/
- if (thd->options & (OPTION_TABLE_LOCK))
+ if (thd_options(thd) & (OPTION_TABLE_LOCK))
{
/* This is currently dead code in wait for implementation in NDB */
/* lockThisTable(); */
@@ -6293,7 +6294,7 @@ int ha_ndbcluster::init_handler_for_stat
}
#endif
- if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
+ if (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
{
const void *key= m_table;
HASH_SEARCH_STATE state;
@@ -6393,7 +6394,7 @@ int ha_ndbcluster::external_lock(THD *th
DBUG_PRINT("info", ("Rows has changed"));
if (thd_ndb->trans &&
- thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
+ thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
{
DBUG_PRINT("info", ("Add share to list of changed tables, %p",
m_share));
@@ -6416,7 +6417,7 @@ int ha_ndbcluster::external_lock(THD *th
{
DBUG_PRINT("trans", ("Last external_lock"));
- if ((!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) &&
+ if ((!(thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) &&
thd_ndb->trans)
{
if (thd_ndb->trans)
@@ -6646,7 +6647,7 @@ int ndbcluster_commit(handlerton *hton,
DBUG_PRINT("info", ("trans == NULL"));
DBUG_RETURN(0);
}
- if (!all && (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+ if (!all && (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
{
/*
An odditity in the handler interface is that commit on handlerton
@@ -6789,7 +6790,7 @@ static int ndbcluster_rollback(handlerto
DBUG_PRINT("info", ("trans == NULL"));
DBUG_RETURN(0);
}
- if (!all && (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
+ if (!all && (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
(thd_ndb->save_point_count > 0))
{
/*
@@ -10683,7 +10684,7 @@ ndbcluster_cache_retrieval_allowed(THD *
DBUG_PRINT("enter", ("dbname: %s, tabname: %s",
dbname, tabname));
- if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
+ if (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
{
/* Don't allow qc to be used if table has been previously
modified in transaction */
@@ -10769,7 +10770,7 @@ ha_ndbcluster::register_query_cache_tabl
DBUG_PRINT("enter",("dbname: %s, tabname: %s",
m_dbname, m_tabname));
- if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
+ if (thd_options(thd) & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
{
/* Don't allow qc to be used if table has been previously
modified in transaction */
=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h 2010-10-01 13:34:24 +0000
+++ b/sql/ha_ndbcluster.h 2010-10-22 12:35:05 +0000
@@ -429,7 +429,10 @@ class ha_ndbcluster: public handler
ha_rows estimate_rows_upper_bound()
{ return HA_POS_ERROR; }
int info(uint);
- void get_dynamic_partition_info(PARTITION_INFO *stat_info, uint part_id);
+#if MYSQL_VERSION_ID < 50501
+ typedef PARTITION_INFO PARTITION_STATS;
+#endif
+ void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id);
uint32 calculate_key_hash_value(Field **field_array);
bool read_before_write_removal_possible(List<Item> *fields,
List<Item> *values);
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2010-10-15 13:02:59 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2010-10-22 12:35:05 +0000
@@ -16,8 +16,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "mysql_priv.h"
-#include "sql_show.h"
+#include "ha_ndbcluster_glue.h"
+
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
#include "ha_ndbcluster.h"
#include "ha_ndbcluster_connection.h"
@@ -252,7 +252,7 @@ static void run_query(THD *thd, char *bu
struct system_status_var save_thd_status_var= thd->status_var;
THD_TRANS save_thd_transaction_all= thd->transaction.all;
THD_TRANS save_thd_transaction_stmt= thd->transaction.stmt;
- ulonglong save_thd_options= thd->options;
+ ulonglong save_thd_options= thd_options(thd);
DBUG_ASSERT(sizeof(save_thd_options) == sizeof(thd->options));
NET save_thd_net= thd->net;
const char* found_semicolon= NULL;
@@ -2174,7 +2174,7 @@ int ndbcluster_log_schema_op(THD *thd,
/* Schema change originating from this MySQLD, check SQL_LOG_BIN
* variable and pass 'setting' to all logging MySQLDs via AnyValue
*/
- if (thd->options & OPTION_BIN_LOG) /* e.g. SQL_LOG_BIN == on */
+ if (thd_options(thd) & OPTION_BIN_LOG) /* e.g. SQL_LOG_BIN == on */
{
DBUG_PRINT("info", ("Schema event for binlogging"));
ndbcluster_anyvalue_set_normal(anyValue);
@@ -3401,7 +3401,7 @@ ndb_add_ndb_binlog_index(THD *thd, ndb_b
Turn of binlogging to prevent the table changes to be written to
the binary log.
*/
- ulonglong saved_options= thd->options;
+ ulonglong saved_options= thd_options(thd);
thd->options&= ~(OPTION_BIN_LOG);
=== modified file 'sql/ha_ndbcluster_cond.cc'
--- a/sql/ha_ndbcluster_cond.cc 2009-12-15 14:44:50 +0000
+++ b/sql/ha_ndbcluster_cond.cc 2010-10-22 12:35:05 +0000
@@ -24,7 +24,7 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
+#include "ha_ndbcluster_glue.h"
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
#include <ndbapi/NdbApi.hpp>
=== added file 'sql/ha_ndbcluster_glue.h'
--- a/sql/ha_ndbcluster_glue.h 1970-01-01 00:00:00 +0000
+++ b/sql/ha_ndbcluster_glue.h 2010-10-22 12:35:05 +0000
@@ -0,0 +1,81 @@
+/*
+ Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef HA_NDBCLUSTER_GLUE_H
+#define HA_NDBCLUSTER_GLUE_H
+
+#include <mysql_version.h>
+
+#ifndef MYSQL_SERVER
+#define MYSQL_SERVER
+#endif
+
+#if MYSQL_VERSION_ID >= 50501
+/* Include files for sql/ was split in 5.5, and ha_ndb* uses a few.. */
+#include "sql_priv.h"
+#include "unireg.h" // REQUIRED: for other includes
+#include "sql_table.h" // build_table_filename,
+ // tablename_to_filename,
+ // filename_to_tablename
+#include "sql_partition.h" // HA_CAN_*, partition_info, part_id_range
+#include "sql_base.h" // close_cached_tables
+#include "discover.h" // readfrm
+#include "sql_acl.h" // wild_case_compare
+#include "transaction.h"
+#include "sql_test.h" // print_where
+#else
+#include "mysql_priv.h"
+#endif
+
+#include "sql_show.h" // init_fill_schema_files_row,
+ // schema_table_store_record
+
+
+#if MYSQL_VERSION_ID >= 50501
+
+/* my_free has lost last argument */
+static inline
+void my_free(void* ptr, myf MyFlags)
+{
+ my_free(ptr);
+}
+
+
+/* close_cached_tables has new signature, emulate old */
+static inline
+bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock,
+ bool wait_for_refresh, bool wait_for_placeholders)
+{
+ return close_cached_tables(thd, tables, wait_for_refresh, LONG_TIMEOUT);
+}
+
+#endif
+
+
+/* extract the bitmask of options from THD */
+static inline
+ulonglong thd_options(const THD * thd)
+{
+#if MYSQL_VERSION_ID < 50500
+ return thd->options;
+#else
+ /* "options" has moved to "variables.option_bits" */
+ return thd->variables.option_bits;
+#endif
+}
+
+#endif
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20101022123505-52pa6dtzc9agrlzt.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3894) | Magnus Blåudd | 22 Oct |