List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:November 8 2011 9:54pm
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3644 to 3645)
View as plain text  
 3645 magnus.blaudd@stripped	2011-11-08
      ndb schema dist
       - first step towards determing at NDB_SHARE create time if it should subscribe
        to events from the table or not
       - move as much as possible for initializing share into 'NDB_SHARE::create'

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ndb_share.h
 3644 magnus.blaudd@stripped	2011-11-08
      ndb schema dist
       - factor out the code which creates a NDB_SHARE into 'NDB_SHARE::create'

    modified:
      sql/ha_ndbcluster.cc
      sql/ndb_share.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-11-08 21:07:35 +0000
+++ b/sql/ha_ndbcluster.cc	2011-11-08 21:54:05 +0000
@@ -13709,6 +13709,49 @@ NDB_SHARE *ndbcluster_get_share(NDB_SHAR
 }
 
 
+static bool
+check_need_events(const char* db_name,
+                  const char* table_name,
+                  bool default_on)
+{
+  DBUG_ENTER("check_need_events");
+  DBUG_PRINT("enter", ("db: %s, table_name: %s",
+                        db_name, table_name));
+
+  if (default_on)
+  {
+    // Turn off event for dist priv tables
+    if (Ndb_dist_priv_util::is_distributed_priv_table(db_name,
+                                                      table_name))
+    {
+      DBUG_PRINT("exit", ("turning OFF events for dist priv table"));
+      DBUG_RETURN(false);
+    }
+
+    DBUG_PRINT("exit", ("turning ON events(the default for this mysqld)"));
+    DBUG_RETURN(true);
+  }
+
+  if (strcmp(db_name, NDB_REP_DB) == 0)
+  {
+    // Special case for tables in "mysql" database
+    if (strcmp(table_name, NDB_SCHEMA_TABLE) == 0)
+    {
+      DBUG_PRINT("exit", ("turning ON events for " NDB_SCHEMA_TABLE));
+      DBUG_RETURN(true);
+    }
+
+    if (strcmp(table_name, NDB_APPLY_TABLE) == 0)
+    {
+      DBUG_PRINT("exit", ("turning ON events for " NDB_APPLY_TABLE));
+      DBUG_RETURN(true);
+    }
+  }
+
+  DBUG_PRINT("exit", ("turning off events(the default for this mysqld)"));
+  DBUG_RETURN(false);
+}
+
 
 NDB_SHARE*
 NDB_SHARE::create(const char* key, size_t key_length,
@@ -13740,6 +13783,33 @@ NDB_SHARE::create(const char* key, size_
   share->commit_count= 0;
   share->commit_count_lock= 0;
 
+  share->m_need_events = check_need_events(db_name,
+                                           table_name,
+                                           ndb_binlog_running);
+
+#ifdef HAVE_NDB_BINLOG
+  share->m_cfn_share= NULL;
+#endif
+
+  share->op= 0;
+  share->new_op= 0;
+  share->event_data= 0;
+
+  {
+    // Create array of bitmap for keeping track of subscribed nodes
+    // NOTE! Only the NDB_SHARE for ndb_schema really needs this
+    int no_nodes= g_ndb_cluster_connection->no_db_nodes();
+    share->subscriber_bitmap= (MY_BITMAP*)
+      alloc_root(&share->mem_root, no_nodes * sizeof(MY_BITMAP));
+    for (int i= 0; i < no_nodes; i++)
+    {
+      bitmap_init(&share->subscriber_bitmap[i],
+                  (Uint32*)alloc_root(&share->mem_root, max_ndb_nodes/8),
+                  max_ndb_nodes, FALSE);
+      bitmap_clear_all(&share->subscriber_bitmap[i]);
+    }
+  }
+
   if (ndbcluster_binlog_init_share(current_thd, share, table))
   {
     DBUG_PRINT("error", ("get_share: %s could not init share", key));

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-11-08 10:34:21 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-11-08 21:54:05 +0000
@@ -362,48 +362,9 @@ ndb_binlog_open_shadow_table(THD *thd, N
 */
 int ndbcluster_binlog_init_share(THD *thd, NDB_SHARE *share, TABLE *_table)
 {
-  MEM_ROOT *mem_root= &share->mem_root;
-  int do_event_op= ndb_binlog_running;
-  int error= 0;
   DBUG_ENTER("ndbcluster_binlog_init_share");
 
-#ifdef HAVE_NDB_BINLOG
-  share->m_cfn_share= NULL;
-#endif
-
-  share->op= 0;
-  share->new_op= 0;
-  share->event_data= 0;
-
-  if (!ndb_schema_share &&
-      strcmp(share->db, NDB_REP_DB) == 0 &&
-      strcmp(share->table_name, NDB_SCHEMA_TABLE) == 0)
-    do_event_op= 1;
-  else if (!ndb_apply_status_share &&
-           strcmp(share->db, NDB_REP_DB) == 0 &&
-           strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
-    do_event_op= 1;
-
-  if (Ndb_dist_priv_util::is_distributed_priv_table(share->db,
-                                                    share->table_name))
-  {
-    do_event_op= 0;
-  }
-
-  {
-    int i, no_nodes= g_ndb_cluster_connection->no_db_nodes();
-    share->subscriber_bitmap= (MY_BITMAP*)
-      alloc_root(mem_root, no_nodes * sizeof(MY_BITMAP));
-    for (i= 0; i < no_nodes; i++)
-    {
-      bitmap_init(&share->subscriber_bitmap[i],
-                  (Uint32*)alloc_root(mem_root, max_ndb_nodes/8),
-                  max_ndb_nodes, FALSE);
-      bitmap_clear_all(&share->subscriber_bitmap[i]);
-    }
-  }
-
-  if (!do_event_op)
+  if (!share->need_events())
   {
     if (_table)
     {
@@ -416,7 +377,7 @@ int ndbcluster_binlog_init_share(THD *th
     {
       share->flags|= NSF_NO_BINLOG;
     }
-    DBUG_RETURN(error);
+    DBUG_RETURN(0);
   }
 
   DBUG_RETURN(ndb_binlog_open_shadow_table(thd, share));

=== modified file 'sql/ndb_share.h'
--- a/sql/ndb_share.h	2011-11-08 21:07:35 +0000
+++ b/sql/ndb_share.h	2011-11-08 21:54:05 +0000
@@ -192,6 +192,20 @@ struct NDB_SHARE {
                          struct TABLE* table, const char* db_name,
                          const char* table_name);
   static void destroy(NDB_SHARE* share);
+
+  /*
+    Returns true if this share need to subscribe to
+    events from the table.
+    NOTE! The value is determined when the NDB_SHARE is
+    created and should not change
+  */
+  bool need_events(void) const
+  {
+    return m_need_events;
+  }
+
+private:
+  bool m_need_events;
 };
 
 

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