List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:March 8 2011 1:00pm
Subject:bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3223)
View as plain text  
#At file:///C:/mysql/5.5-cluster/ based on revid:magnus.blaudd@stripped

 3223 Magnus Blåudd	2011-03-08
      ndb
       - move functions for working with THD into ndb_thd.h and ndb_thd.cc

    added:
      sql/ndb_thd.cc
      sql/ndb_thd.h
    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_binlog.h
      storage/ndb/CMakeLists.txt
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-03-08 10:29:13 +0000
+++ b/sql/ha_ndbcluster.cc	2011-03-08 12:59:56 +0000
@@ -43,6 +43,7 @@
 #include "ha_ndbcluster_binlog.h"
 #include "ha_ndbcluster_tables.h"
 #include "ha_ndbcluster_connection.h"
+#include "ndb_thd.h"
 
 #include <mysql/plugin.h>
 #include <ndb_version.h>
@@ -9837,7 +9838,7 @@ Ndb* check_ndb_in_thd(THD* thd, bool val
   {
     if (!(thd_ndb= Thd_ndb::seize()))
       return NULL;
-    set_thd_ndb(thd, thd_ndb);
+    thd_set_thd_ndb(thd, thd_ndb);
   }
 
   else if (validate_ndb && !thd_ndb->valid_ndb())
@@ -9873,7 +9874,7 @@ static int ndbcluster_close_connection(h
   if (thd_ndb)
   {
     Thd_ndb::release(thd_ndb);
-    set_thd_ndb(thd, NULL); // not strictly required but does not hurt either
+    thd_set_thd_ndb(thd, NULL);
   }
   DBUG_RETURN(0);
 }
@@ -12939,7 +12940,7 @@ pthread_handler_t ndb_util_thread_func(v
     pthread_mutex_lock(&LOCK_ndb_util_thread);
     goto ndb_util_thread_end;
   }
-  set_thd_ndb(thd, thd_ndb);
+  thd_set_thd_ndb(thd, thd_ndb);
   thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP;
 
   if (opt_ndb_extra_logging && ndb_binlog_running)
@@ -13118,7 +13119,7 @@ ndb_util_thread_fail:
   if (thd_ndb)
   {
     Thd_ndb::release(thd_ndb);
-    set_thd_ndb(thd, NULL);
+    thd_set_thd_ndb(thd, NULL);
   }
   thd->cleanup();
   delete thd;

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-03-08 10:29:13 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-03-08 12:59:56 +0000
@@ -22,6 +22,7 @@
 #include "ha_ndbcluster.h"
 #include "ha_ndbcluster_connection.h"
 #include "ndb_local_connection.h"
+#include "ndb_thd.h"
 
 #include "rpl_injector.h"
 #include "rpl_filter.h"
@@ -1929,7 +1930,7 @@ int ndbcluster_log_schema_op(THD *thd,
       sql_print_error("Could not allocate Thd_ndb object");
       DBUG_RETURN(1);
     }
-    set_thd_ndb(thd, thd_ndb);
+    thd_set_thd_ndb(thd, thd_ndb);
   }
 
   DBUG_PRINT("enter",
@@ -6031,7 +6032,7 @@ restart_cluster_failure:
     pthread_mutex_unlock(&injector_mutex);
 
     DBUG_ASSERT(ndbcluster_hton->slot != ~(uint)0);
-    set_thd_ndb(thd, thd_ndb);
+    thd_set_thd_ndb(thd, thd_ndb);
     thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP;
     thd->query_id= 0; // to keep valgrind quiet
   }
@@ -6734,7 +6735,7 @@ restart_cluster_failure:
   if (thd_ndb)
   {
     Thd_ndb::release(thd_ndb);
-    set_thd_ndb(thd, NULL);
+    thd_set_thd_ndb(thd, NULL);
     thd_ndb= NULL;
   }
 

=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h	2011-03-04 10:26:41 +0000
+++ b/sql/ha_ndbcluster_binlog.h	2011-03-08 12:59:56 +0000
@@ -322,18 +322,6 @@ ndbcluster_check_if_local_table(const ch
 bool
 ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname);
 
-inline
-Thd_ndb *
-get_thd_ndb(THD *thd)
-{ return (Thd_ndb *) thd_get_ha_data(thd, ndbcluster_hton); }
-
-inline
-void
-set_thd_ndb(THD *thd, Thd_ndb *thd_ndb)
-{ thd_set_ha_data(thd, ndbcluster_hton, thd_ndb); }
-
-Ndb* check_ndb_in_thd(THD* thd, bool validate_ndb= false);
-
 bool ndbcluster_has_global_schema_lock(Thd_ndb *thd_ndb);
 int ndbcluster_no_global_schema_lock_abort(THD *thd, const char *msg);
 

=== added file 'sql/ndb_thd.cc'
--- a/sql/ndb_thd.cc	1970-01-01 00:00:00 +0000
+++ b/sql/ndb_thd.cc	2011-03-08 12:59:56 +0000
@@ -0,0 +1,45 @@
+/*
+   Copyright (c) 2011, 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
+*/
+
+#include "ndb_thd.h"
+#include "ndb_thd_ndb.h"
+
+
+/*
+  Make sure THD has a Thd_ndb struct allocated and associated
+
+  - validate_ndb, check if the Ndb object need to be recycled
+*/
+
+Ndb* check_ndb_in_thd(THD* thd, bool validate_ndb)
+{
+  Thd_ndb *thd_ndb= get_thd_ndb(thd);
+  if (!thd_ndb)
+  {
+    if (!(thd_ndb= Thd_ndb::seize()))
+      return NULL;
+    thd_set_thd_ndb(thd, thd_ndb);
+  }
+
+  else if (validate_ndb && !thd_ndb->valid_ndb())
+  {
+    if (!thd_ndb->recycle_ndb(thd))
+      return NULL;
+  }
+
+  return thd_ndb->ndb;
+}

=== added file 'sql/ndb_thd.h'
--- a/sql/ndb_thd.h	1970-01-01 00:00:00 +0000
+++ b/sql/ndb_thd.h	2011-03-08 12:59:56 +0000
@@ -0,0 +1,54 @@
+/*
+   Copyright (c) 2011, 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 NDB_THD_H
+#define NDB_THD_H
+
+#include <mysql/plugin.h>
+
+extern handlerton* ndbcluster_hton;
+
+/* Get Thd_ndb pointer from THD */
+static inline
+class Thd_ndb*
+thd_get_thd_ndb(THD* thd)
+{
+  return (class Thd_ndb *) thd_get_ha_data(thd, ndbcluster_hton);
+}
+  
+/* Backward compatibility alias for 'thd_get_thd_ndb'  */
+static inline
+class Thd_ndb*
+get_thd_ndb(THD* thd)
+{
+  return thd_get_thd_ndb(thd);
+}
+
+
+/* Set Thd_ndb pointer for THD */
+static inline
+void
+thd_set_thd_ndb(THD *thd, class Thd_ndb *thd_ndb)
+{
+  thd_set_ha_data(thd, ndbcluster_hton, thd_ndb);
+}
+
+
+/* Make sure THD has a Thd_ndb struct assigned */
+class Ndb* check_ndb_in_thd(THD* thd, bool validate_ndb= false);
+
+#endif

=== modified file 'storage/ndb/CMakeLists.txt'
--- a/storage/ndb/CMakeLists.txt	2011-03-08 10:29:13 +0000
+++ b/storage/ndb/CMakeLists.txt	2011-03-08 12:59:56 +0000
@@ -104,6 +104,7 @@ SET(NDBCLUSTER_SOURCES
   ../../sql/ha_ndbinfo.cc
   ../../sql/ndb_local_connection.cc
   ../../sql/ndb_share.cc
+  ../../sql/ndb_thd.cc
   ../../sql/ndb_thd_ndb.cc
 )
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/ndb/include)

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20110308125956-rfcwcezzbl7p93o0.bundle
Thread
bzr commit into mysql-5.5-cluster branch (magnus.blaudd:3223) Magnus Blåudd8 Mar