MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Martin Skold Date:September 3 2009 7:35am
Subject:bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2975) Bug#46712
View as plain text  
#At file:///home/marty/MySQL/mysql-5.1-telco-6.2_main/

 2975 Martin Skold	2009-09-03
      Bug #46712 Auto_increment work incorrectly when using triggers and NDB Cluster, defining m_rows_to_insert=1 as default, even when start_bulk_insert is nor called, simplified code in get_auto_increment.
      modified:
        sql/ha_ndbcluster.cc

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2009-08-25 19:44:04 +0000
+++ b/sql/ha_ndbcluster.cc	2009-09-03 07:35:29 +0000
@@ -4230,6 +4230,8 @@ int ha_ndbcluster::reset()
   m_ignore_dup_key= FALSE;
   m_use_write= FALSE;
   m_ignore_no_key= FALSE;
+  m_rows_inserted= (ha_rows) 0;
+  m_rows_to_insert= (ha_rows) 1;
   m_delete_cannot_batch= FALSE;
   m_update_cannot_batch= FALSE;
 
@@ -4299,10 +4301,18 @@ void ha_ndbcluster::start_bulk_insert(ha
   if (rows == (ha_rows) 0)
   {
     /* We don't know how many will be inserted, guess */
-    m_rows_to_insert= m_autoincrement_prefetch;
+    m_rows_to_insert=
+      (m_autoincrement_prefetch > NDB_DEFAULT_AUTO_PREFETCH)
+      ? m_autoincrement_prefetch
+      : NDB_DEFAULT_AUTO_PREFETCH;
+    m_autoincrement_prefetch= m_rows_to_insert;
   }
   else
-    m_rows_to_insert= rows; 
+  {
+    m_rows_to_insert= rows;
+    if (m_autoincrement_prefetch < m_rows_to_insert)
+      m_autoincrement_prefetch= m_rows_to_insert;
+  }
 
   DBUG_VOID_RETURN;
 }
@@ -4580,11 +4590,7 @@ int ha_ndbcluster::init_handler_for_stat
   DBUG_ENTER("ha_ndbcluster::init_handler_for_statement");
   // store thread specific data first to set the right context
   m_force_send=          thd->variables.ndb_force_send;
-  m_autoincrement_prefetch=
-    (thd->variables.ndb_autoincrement_prefetch_sz > 
-     NDB_DEFAULT_AUTO_PREFETCH) ?
-    (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz
-    : (ha_rows) NDB_DEFAULT_AUTO_PREFETCH;
+  m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz;
   m_thd_ndb= thd_ndb;
   DBUG_ASSERT(m_thd_ndb->trans);
   // Start of transaction
@@ -6529,26 +6535,11 @@ void ha_ndbcluster::get_auto_increment(u
                                        ulonglong *first_value,
                                        ulonglong *nb_reserved_values)
 {
-  uint cache_size;
   Uint64 auto_value;
   THD *thd= current_thd;
   DBUG_ENTER("get_auto_increment");
   DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
   Ndb *ndb= get_ndb(table->in_use);
-   
-  if (m_rows_inserted > m_rows_to_insert)
-  {
-    /* We guessed too low */
-    m_rows_to_insert+= m_autoincrement_prefetch;
-  }
-  uint remaining= m_rows_to_insert - m_rows_inserted;
-  uint min_prefetch= 
-    (remaining < thd->variables.ndb_autoincrement_prefetch_sz) ?
-    thd->variables.ndb_autoincrement_prefetch_sz
-    : remaining;
-  cache_size= ((remaining < m_autoincrement_prefetch) ?
-	       min_prefetch
-	       : remaining);
   uint retries= NDB_AUTO_INCREMENT_RETRIES;
   int retry_sleep= 30; /* 30 milliseconds, transaction */
   for (;;)
@@ -6556,7 +6547,7 @@ void ha_ndbcluster::get_auto_increment(u
     Ndb_tuple_id_range_guard g(m_share);
     if (m_skip_auto_increment &&
         ndb->readAutoIncrementValue(m_table, g.range, auto_value) ||
-        ndb->getAutoIncrementValue(m_table, g.range, auto_value, cache_size, increment, offset))
+        ndb->getAutoIncrementValue(m_table, g.range, auto_value, m_autoincrement_prefetch, increment, offset))
     {
       if (--retries && !thd->killed &&
           ndb->getNdbError().status == NdbError::TemporaryError)

Thread
bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2975) Bug#46712Martin Skold3 Sep