List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:November 7 2011 10:45pm
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3643 to 3645)
View as plain text  
 3645 Magnus Blåudd	2011-11-07
      ndbcluster
       - move 'cmpfrm' to ndb_ndbapi_util.h

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.h
      sql/ndb_ndbapi_util.cc
      sql/ndb_ndbapi_util.h
 3644 Magnus Blåudd	2011-11-07
      ndb schema dist
       - add m_is_post_epoch flag for checking that functions are called at the correct time

    modified:
      sql/ha_ndbcluster_binlog.cc
 3643 Magnus Blåudd	2011-11-07
      ndb schema dist
       - move the three  rather long cases for alter table handling into their own functions

    modified:
      sql/ha_ndbcluster_binlog.cc
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-11-07 21:32:26 +0000
+++ b/sql/ha_ndbcluster.cc	2011-11-07 22:45:08 +0000
@@ -1915,30 +1915,6 @@ void ha_ndbcluster::release_blobs_buffer
   DBUG_VOID_RETURN;
 }
 
-/**
-  Get metadata for this table from NDB.
-
-  Check that frm-file on disk is equal to frm-file
-  of table accessed in NDB.
-
-  @retval
-    0    ok
-  @retval
-    -2   Meta data has changed; Re-read data and try again
-*/
-
-int cmp_frm(const NDBTAB *ndbtab, const void *pack_data,
-            size_t pack_length)
-{
-  DBUG_ENTER("cmp_frm");
-  /*
-    Compare FrmData in NDB with frm file from disk.
-  */
-  if ((pack_length != ndbtab->getFrmLength()) || 
-      (memcmp(pack_data, ndbtab->getFrmData(), pack_length)))
-    DBUG_RETURN(1);
-  DBUG_RETURN(0);
-}
 
 /*
   Does type support a default value?

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-11-07 22:23:38 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-11-07 22:38:30 +0000
@@ -2533,6 +2533,7 @@ class Ndb_schema_event_handler {
   log_after_epoch(Ndb_schema_op* schema)
   {
     DBUG_ENTER("log_after_epoch");
+    assert(!is_post_epoch()); // Only before epoch
     m_post_epoch_log_list.push_back(schema, m_mem_root);
     DBUG_VOID_RETURN;
   }
@@ -2542,6 +2543,7 @@ class Ndb_schema_event_handler {
   unlock_after_epoch(Ndb_schema_op* schema)
   {
     DBUG_ENTER("unlock_after_epoch");
+    assert(!is_post_epoch()); // Only before epoch
     m_post_epoch_unlock_list.push_back(schema, m_mem_root);
     DBUG_VOID_RETURN;
   }
@@ -2627,9 +2629,9 @@ class Ndb_schema_event_handler {
   }
 
 
-  void handle_clear_slock(Ndb_schema_op* schema, bool post_epoch)
+  void handle_clear_slock(Ndb_schema_op* schema)
   {
-    if (!post_epoch)
+    if (!is_post_epoch())
     {
       /*
         handle slock after epoch is completed to ensure that
@@ -2703,6 +2705,8 @@ class Ndb_schema_event_handler {
   void
   handle_offline_alter_table_commit(Ndb_schema_op* schema)
   {
+    assert(is_post_epoch()); // Always after epoch
+
     if (schema->node_id == own_nodeid())
       return;
 
@@ -2762,6 +2766,8 @@ class Ndb_schema_event_handler {
   void
   handle_online_alter_table_prepare(Ndb_schema_op* schema)
   {
+    assert(is_post_epoch()); // Always after epoch
+
     ndbapi_invalidate_table(schema->db, schema->name);
     mysqld_close_cached_table(schema->db, schema->name);
 
@@ -2866,6 +2872,8 @@ class Ndb_schema_event_handler {
   void
   handle_online_alter_table_commit(Ndb_schema_op* schema)
   {
+    assert(is_post_epoch()); // Always after epoch
+
     NDB_SHARE *share= get_share(schema);
     if (share)
     {
@@ -2925,7 +2933,7 @@ class Ndb_schema_event_handler {
       switch (schema_type)
       {
       case SOT_CLEAR_SLOCK:
-        handle_clear_slock(schema, false);
+        handle_clear_slock(schema);
         DBUG_RETURN(0);
 
       case SOT_ALTER_TABLE_COMMIT:
@@ -3130,7 +3138,7 @@ class Ndb_schema_event_handler {
       switch (schema_type)
       {
       case SOT_CLEAR_SLOCK:
-        handle_clear_slock(schema, true);
+        handle_clear_slock(schema);
         break;
 
       case SOT_DROP_DB:
@@ -3264,6 +3272,9 @@ class Ndb_schema_event_handler {
   THD* m_thd;
   MEM_ROOT* m_mem_root;
   uint m_own_nodeid;
+  bool m_post_epoch;
+
+  bool is_post_epoch(void) const { return m_post_epoch; };
 
   List<Ndb_schema_op> m_post_epoch_log_list;
   List<Ndb_schema_op> m_post_epoch_unlock_list;
@@ -3273,7 +3284,8 @@ public:
   Ndb_schema_event_handler(const Ndb_schema_event_handler&); // Not implemented
 
   Ndb_schema_event_handler(THD* thd, MEM_ROOT* mem_root, uint own_nodeid):
-    m_thd(thd), m_mem_root(mem_root), m_own_nodeid(own_nodeid)
+    m_thd(thd), m_mem_root(mem_root), m_own_nodeid(own_nodeid),
+    m_post_epoch(false)
   {
   }
 
@@ -3428,6 +3440,9 @@ public:
   {
     if (m_post_epoch_log_list.elements > 0)
     {
+      // Set the flag used to check that functions are called at correct time
+      m_post_epoch= true;
+
       handle_schema_log_post_epoch(&m_post_epoch_log_list);
       // NOTE post_epoch_unlock_list may not be handled!
       handle_schema_unlock_post_epoch(&m_post_epoch_unlock_list);

=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h	2011-11-02 09:28:48 +0000
+++ b/sql/ha_ndbcluster_binlog.h	2011-11-07 22:45:08 +0000
@@ -139,13 +139,6 @@ ndbcluster_show_status_binlog(THD* thd,
                               enum ha_stat_type stat_type);
 
 /*
-  prototypes for ndb handler utility function also needed by
-  the ndb binlog code
-*/
-int cmp_frm(const NDBTAB *ndbtab, const void *pack_data,
-            size_t pack_length);
-
-/*
   Helper functions
 */
 bool

=== modified file 'sql/ndb_ndbapi_util.cc'
--- a/sql/ndb_ndbapi_util.cc	2011-10-27 08:27:44 +0000
+++ b/sql/ndb_ndbapi_util.cc	2011-11-07 22:45:08 +0000
@@ -43,6 +43,21 @@ char *ndb_pack_varchar(const NdbDictiona
 }
 
 
+int
+cmp_frm(const NdbDictionary::Table* ndbtab, const void* pack_data,
+        size_t pack_length)
+{
+  DBUG_ENTER("cmp_frm");
+  /*
+    Compare the NDB tables FrmData with frm file blob in pack_data.
+  */
+  if ((pack_length != ndbtab->getFrmLength()) ||
+      (memcmp(pack_data, ndbtab->getFrmData(), pack_length)))
+    DBUG_RETURN(1);
+  DBUG_RETURN(0);
+}
+
+
 #ifndef MYSQL_SERVER
 #define MYSQL_SERVER
 #endif

=== modified file 'sql/ndb_ndbapi_util.h'
--- a/sql/ndb_ndbapi_util.h	2011-10-27 08:27:44 +0000
+++ b/sql/ndb_ndbapi_util.h	2011-11-07 22:45:08 +0000
@@ -38,4 +38,15 @@ int get_ndb_blobs_value(struct TABLE* ta
 char *ndb_pack_varchar(const NdbDictionary::Column *col,
                        char *buf, const char *str, int sz);
 
+/**
+  Check that frm-file blob in pack_data is equal
+  to frm-file of the NdbDictionary::Table.
+
+  @retval
+    0    ok
+*/
+
+int cmp_frm(const NdbDictionary::Table* ndbtab, const void* pack_data,
+            size_t pack_length);
+
 #endif

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (magnus.blaudd:3643 to 3645) Magnus Blåudd11 Nov