MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:tomas Date:April 20 2006 12:11am
Subject:bk commit into 5.1 tree (tomas:1.2366)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2366 06/04/20 02:10:50 tomas@stripped +2 -0
  ndb: further simplified the handling of uncommitted rows

  sql/ha_ndbcluster.h
    1.133 06/04/20 02:10:43 tomas@stripped +5 -6
    ndb: further simplified the handling of uncommitted rows

  sql/ha_ndbcluster.cc
    1.302 06/04/20 02:10:43 tomas@stripped +10 -59
    ndb: further simplified the handling of uncommitted rows

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-new

--- 1.301/sql/ha_ndbcluster.cc	2006-04-19 23:49:43 +02:00
+++ 1.302/sql/ha_ndbcluster.cc	2006-04-20 02:10:43 +02:00
@@ -327,10 +327,8 @@
 {
   ndb= new Ndb(g_ndb_cluster_connection, "");
   lock_count= 0;
-  count= 0;
   all= NULL;
   stmt= NULL;
-  error= 0;
   options= 0;
   (void) hash_init(&open_tables, &my_charset_bin, 5, 0, 0,
                    (hash_get_key)thd_ndb_share_get_key, 0, 0);
@@ -374,12 +372,14 @@
   THD_NDB_SHARE *thd_ndb_share=
     (THD_NDB_SHARE*)hash_first(&open_tables, (byte *)key, sizeof(key), &state);
   while (thd_ndb_share && thd_ndb_share->key != key)
-    thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (byte *)key, sizeof(key), &state);
+    thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (byte *)key,
+                                             sizeof(key), &state);
   if (thd_ndb_share == 0)
   {
     thd_ndb_share= (THD_NDB_SHARE *) alloc_root(&thd->transaction.mem_root,
                                                 sizeof(THD_NDB_SHARE));
     thd_ndb_share->key= key;
+    thd_ndb_share->stat.reset();
     my_hash_insert(&open_tables, (byte *)thd_ndb_share);
   }
   DBUG_PRINT("exit", ("thd_ndb_share: 0x%x  key: 0x%x", thd_ndb_share, key));
@@ -426,43 +426,10 @@
       info->records= stat.row_count;
     }
   }
-  {
-    THD *thd= current_thd;
-    if (get_thd_ndb(thd)->error)
-      info->no_uncommitted_rows_count= 0;
-  }
   records= info->records+ info->no_uncommitted_rows_count;
   DBUG_VOID_RETURN;
 }
 
-void ha_ndbcluster::no_uncommitted_rows_execute_failure()
-{
-  if (m_ha_not_exact_count)
-    return;
-  DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_execute_failure");
-  get_thd_ndb(current_thd)->error= 1;
-  DBUG_VOID_RETURN;
-}
-
-void ha_ndbcluster::no_uncommitted_rows_init(THD *thd)
-{
-  if (m_ha_not_exact_count)
-    return;
-  DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_init");
-  struct Ndb_local_table_statistics *info= m_table_info;
-  Thd_ndb *thd_ndb= get_thd_ndb(thd);
-  if (info->last_count != thd_ndb->count)
-  {
-    info->last_count= thd_ndb->count;
-    info->no_uncommitted_rows_count= 0;
-    info->records= ~(ha_rows)0;
-    DBUG_PRINT("info", ("id=%d, no_uncommitted_rows_count=%d",
-                        ((const NDBTAB *)m_table)->getTableId(),
-                        info->no_uncommitted_rows_count));
-  }
-  DBUG_VOID_RETURN;
-}
-
 void ha_ndbcluster::no_uncommitted_rows_update(int c)
 {
   if (m_ha_not_exact_count)
@@ -476,17 +443,6 @@
   DBUG_VOID_RETURN;
 }
 
-void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd)
-{
-  if (m_ha_not_exact_count)
-    return;
-  DBUG_ENTER("ha_ndbcluster::no_uncommitted_rows_reset");
-  Thd_ndb *thd_ndb= get_thd_ndb(thd);
-  thd_ndb->count++;
-  thd_ndb->error= 0;
-  DBUG_VOID_RETURN;
-}
-
 /*
   Take care of the error that occured in NDB
 
@@ -579,6 +535,8 @@
   NdbError err= trans->getNdbError();
   DBUG_ENTER("ndb_err");
   
+  m_table_info->reset();
+
   ERR_PRINT(err);
   switch (err.classification) {
   case NdbError::SchemaError:
@@ -2100,6 +2058,7 @@
         }
         else
         {
+          m_table_info->reset();
           if  (execute_commit(this,trans) != 0)
             DBUG_RETURN(-1);
           if (trans->restart() != 0)
@@ -2648,7 +2607,6 @@
       if (execute_no_commit(this,trans) != 0)
       {
         m_skip_auto_increment= TRUE;
-        no_uncommitted_rows_execute_failure();
         DBUG_RETURN(ndb_err(trans));
       }
     }
@@ -2657,9 +2615,9 @@
       if (execute_commit(this,trans) != 0)
       {
         m_skip_auto_increment= TRUE;
-        no_uncommitted_rows_execute_failure();
         DBUG_RETURN(ndb_err(trans));
       }
+      m_table_info->reset();
       if (trans->restart() != 0)
       {
         DBUG_ASSERT(0);
@@ -2874,7 +2832,6 @@
   }
   // Execute update operation
   if (!cursor && execute_no_commit(this,trans) != 0) {
-    no_uncommitted_rows_execute_failure();
     DBUG_RETURN(ndb_err(trans));
   }
   
@@ -2960,7 +2917,6 @@
 
   // Execute delete operation
   if (execute_no_commit(this,trans) != 0) {
-    no_uncommitted_rows_execute_failure();
     DBUG_RETURN(ndb_err(trans));
   }
   DBUG_RETURN(0);
@@ -3412,7 +3368,6 @@
     */
     DBUG_PRINT("info", ("ops_pending: %d", m_ops_pending));    
     if (execute_no_commit(this,trans) != 0) {
-      no_uncommitted_rows_execute_failure();
       DBUG_RETURN(ndb_err(trans));
     }
     m_ops_pending= 0;
@@ -3775,7 +3730,6 @@
     {
       if (execute_no_commit(this, trans) != 0)
       {
-        no_uncommitted_rows_execute_failure();
         my_errno= error= ndb_err(trans);
       }
     }
@@ -3783,13 +3737,13 @@
     {
       if (execute_commit(this, trans) != 0)
       {
-        no_uncommitted_rows_execute_failure();
         my_errno= error= ndb_err(trans);
       }
       else
       {
         int res= trans->restart();
-        DBUG_ASSERT(res == 0);
+        DBUG_ASSERT(res == 0); 
+        m_table_info->reset();
       }
     }
   }
@@ -3946,7 +3900,6 @@
         if (trans == NULL)
           ERR_RETURN(ndb->getNdbError());
         thd_ndb->init_open_tables();
-        no_uncommitted_rows_reset(thd);
         thd_ndb->stmt= trans;
         trans_register_ha(thd, FALSE, &ndbcluster_hton);
       } 
@@ -3962,7 +3915,6 @@
           if (trans == NULL)
             ERR_RETURN(ndb->getNdbError());
           thd_ndb->init_open_tables();
-          no_uncommitted_rows_reset(thd);
           thd_ndb->all= trans; 
           trans_register_ha(thd, TRUE, &ndbcluster_hton);
 
@@ -4041,7 +3993,6 @@
     }
     m_thd_ndb_share= thd_ndb->get_open_table(thd, m_table);
     m_table_info= &m_thd_ndb_share->stat;
-    no_uncommitted_rows_init(thd);
   }
   else
   {
@@ -4133,7 +4084,7 @@
     trans= ndb->startTransaction();
     if (trans == NULL)
       ERR_RETURN(ndb->getNdbError());
-    no_uncommitted_rows_reset(thd);
+    thd_ndb->init_open_tables();
     thd_ndb->stmt= trans;
     trans_register_ha(thd, FALSE, &ndbcluster_hton);
   }

--- 1.132/sql/ha_ndbcluster.h	2006-04-19 18:29:18 +02:00
+++ 1.133/sql/ha_ndbcluster.h	2006-04-20 02:10:43 +02:00
@@ -524,8 +524,12 @@
 };
 
 struct Ndb_local_table_statistics {
+  void reset()
+  {
+    no_uncommitted_rows_count= 0;
+    records= ~(ha_rows)0;
+  }
   int no_uncommitted_rows_count;
-  ulong last_count;
   ha_rows records;
 };
 
@@ -544,11 +548,9 @@
   THD_NDB_SHARE *get_open_table(THD *thd, const void *key);
 
   Ndb *ndb;
-  ulong count;
   uint lock_count;
   NdbTransaction *all;
   NdbTransaction *stmt;
-  int error;
   uint32 options;
   List<NDB_SHARE> changed_tables;
   HASH open_tables;
@@ -807,10 +809,7 @@
 
   void set_rec_per_key();
   void records_update();
-  void no_uncommitted_rows_execute_failure();
   void no_uncommitted_rows_update(int);
-  void no_uncommitted_rows_init(THD *);
-  void no_uncommitted_rows_reset(THD *);
 
   /*
     Condition pushdown
Thread
bk commit into 5.1 tree (tomas:1.2366)tomas21 Apr