List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:November 10 2011 8:25am
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3648 to 3649)
View as plain text  
 3649 magnus.blaudd@stripped	2011-11-10
      ndb schema dist
       - move print function for share to NDB_SHARE
       - improve printout
       - split out the part which prints Ndb_event_data
       - add acessor function to get Ndb_event_data* from share

    modified:
      sql/ha_ndbcluster.cc
      sql/ndb_event_data.cc
      sql/ndb_event_data.h
      sql/ndb_share.cc
      sql/ndb_share.h
 3648 magnus.blaudd@stripped	2011-11-09
      ndb schema dist
       - remove unnecessary setting of NO_NO_LOCK_SCHEMA_OP(i.e no global schema lock) before calling
        ndb_create_table_from_engine

    modified:
      sql/ha_ndbcluster_binlog.cc
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-11-09 07:31:37 +0000
+++ b/sql/ha_ndbcluster.cc	2011-11-10 08:21:36 +0000
@@ -13414,38 +13414,15 @@ static uchar *ndbcluster_get_key(NDB_SHA
 
 #ifndef DBUG_OFF
 
-static void print_share(const char* where, NDB_SHARE* share)
-{
-  fprintf(DBUG_FILE,
-          "%s %s.%s: use_count: %u, commit_count: %lu\n",
-          where, share->db, share->table_name, share->use_count,
-          (ulong) share->commit_count);
-  fprintf(DBUG_FILE,
-          "  - key: %s, key_length: %d\n",
-          share->key, share->key_length);
-
-  Ndb_event_data *event_data= 0;
-  if (share->event_data)
-    event_data= share->event_data;
-  else if (share->op)
-    event_data= (Ndb_event_data *) share->op->getCustomData();
-  if (event_data)
-  {
-    fprintf(DBUG_FILE,
-            "  - event_data->shadow_table: %p %s.%s\n",
-            event_data->shadow_table, event_data->shadow_table->s->db.str,
-            event_data->shadow_table->s->table_name.str);
-  }
-}
-
-
 static void print_ndbcluster_open_tables()
 {
   DBUG_LOCK_FILE;
   fprintf(DBUG_FILE, ">ndbcluster_open_tables\n");
   for (uint i= 0; i < ndbcluster_open_tables.records; i++)
-    print_share("",
-                (NDB_SHARE*)my_hash_element(&ndbcluster_open_tables, i));
+  {
+    NDB_SHARE* share= (NDB_SHARE*)my_hash_element(&ndbcluster_open_tables, i);
+    share->print("", DBUG_FILE);
+  }
   fprintf(DBUG_FILE, "<ndbcluster_open_tables\n");
   DBUG_UNLOCK_FILE;
 }
@@ -13460,7 +13437,7 @@ static void print_ndbcluster_open_tables
 #define dbug_print_share(t, s)                  \
   DBUG_LOCK_FILE;                               \
   DBUG_EXECUTE("info",                          \
-               print_share((t), (s)););         \
+               (s)->print((t), DBUG_FILE););    \
   DBUG_UNLOCK_FILE;
 
 
@@ -13656,11 +13633,7 @@ int ndbcluster_rename_share(THD *thd, ND
   ha_ndbcluster::set_tabname(share->new_key, share->table_name);
 
   dbug_print_share("ndbcluster_rename_share:", share);
-  Ndb_event_data *event_data= 0;
-  if (share->event_data)
-    event_data= share->event_data;
-  else if (share->op)
-    event_data= (Ndb_event_data *) share->op->getCustomData();
+  Ndb_event_data *event_data= share->get_event_data_ptr();
   if (event_data && event_data->shadow_table)
   {
     if (!IS_TMP_PREFIX(share->table_name))

=== modified file 'sql/ndb_event_data.cc'
--- a/sql/ndb_event_data.cc	2011-10-29 09:02:21 +0000
+++ b/sql/ndb_event_data.cc	2011-11-10 08:21:36 +0000
@@ -42,3 +42,13 @@ Ndb_event_data::~Ndb_event_data()
   */
   my_free(ndb_value[0]);
 }
+
+
+void Ndb_event_data::print(const char* where, FILE* file) const
+{
+  fprintf(file,
+          "%s shadow_table: %p '%s.%s'\n",
+          where,
+          shadow_table, shadow_table->s->db.str,
+          shadow_table->s->table_name.str);
+}

=== modified file 'sql/ndb_event_data.h'
--- a/sql/ndb_event_data.h	2011-10-29 09:02:21 +0000
+++ b/sql/ndb_event_data.h	2011-11-10 08:21:36 +0000
@@ -34,6 +34,8 @@ public:
   struct TABLE *shadow_table;
   struct NDB_SHARE *share;
   union NdbValue *ndb_value[2];
+
+  void print(const char* where, FILE* file) const;
 };
 
 #endif

=== modified file 'sql/ndb_share.cc'
--- a/sql/ndb_share.cc	2011-11-09 06:31:45 +0000
+++ b/sql/ndb_share.cc	2011-11-10 08:21:36 +0000
@@ -20,6 +20,8 @@
 #include "ndb_dist_priv_util.h"
 #include "ha_ndbcluster_tables.h"
 
+#include <ndbapi/NdbEventOperation.hpp>
+
 #include <my_sys.h>
 
 extern Ndb* g_ndb;
@@ -39,10 +41,11 @@ NDB_SHARE::destroy(NDB_SHARE* share)
   }
 #endif
   share->new_op= 0;
-  if (share->event_data)
+  Ndb_event_data* event_data = share->event_data;
+  if (event_data)
   {
-    delete share->event_data;
-    share->event_data= 0;
+    delete event_data;
+    event_data= 0;
   }
   free_root(&share->mem_root, MYF(0));
   my_free(share);
@@ -95,3 +98,52 @@ NDB_SHARE::need_events(bool default_on)
   DBUG_PRINT("exit", ("no events(the default for this mysqld)"));
   DBUG_RETURN(false);
 }
+
+
+Ndb_event_data* NDB_SHARE::get_event_data_ptr() const
+{
+  if (event_data)
+  {
+    // The event_data pointer is only used before
+    // creating the NdbEventoperation -> check no op yet
+    assert(!op);
+
+    return event_data;
+  }
+
+  if (op)
+  {
+    // The event_data should now be empty since it's been moved to
+    // op's custom data
+    assert(!event_data);
+
+    // Check that op has custom data
+    assert(op->getCustomData());
+
+    return (Ndb_event_data*)op->getCustomData();
+  }
+
+  return NULL;
+}
+
+
+void NDB_SHARE::print(const char* where, FILE* file) const
+{
+  fprintf(file, "%s %s.%s: use_count: %u\n",
+          where, db, table_name, use_count);
+  fprintf(file, "  - key: '%s', key_length: %d\n", key, key_length);
+  fprintf(file, "  - commit_count: %llu\n", commit_count);
+  if (new_key)
+    fprintf(file, "  - new_key: %p, '%s'\n",
+            new_key, new_key);
+  if (event_data)
+    fprintf(file, "  - event_data: %p\n", event_data);
+  if (op)
+    fprintf(file, "  - op: %p\n", op);
+  if (new_op)
+    fprintf(file, "  - new_op: %p\n", new_op);
+
+  Ndb_event_data *event_data_ptr= get_event_data_ptr();
+  if (event_data_ptr)
+    event_data_ptr->print("  -", file);
+}

=== modified file 'sql/ndb_share.h'
--- a/sql/ndb_share.h	2011-11-09 06:31:45 +0000
+++ b/sql/ndb_share.h	2011-11-10 08:21:36 +0000
@@ -193,6 +193,10 @@ struct NDB_SHARE {
                          const char* table_name);
   static void destroy(NDB_SHARE* share);
 
+  class Ndb_event_data* get_event_data_ptr() const;
+
+  void print(const char* where, FILE* file = stderr) const;
+
   /*
     Returns true if this share need to subscribe to
     events from the table.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (magnus.blaudd:3648 to 3649) magnus.blaudd11 Nov