List:Internals« Previous MessageNext Message »
From:Martin Skold Date:April 13 2005 10:42am
Subject:bk commit into 4.1 tree (mskold:1.2169) BUG#9813
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of marty. When marty 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.2169 05/04/13 12:42:23 mskold@stripped +3 -0
  Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit

  sql/mysqld.cc
    1.568 05/04/13 12:42:07 mskold@stripped +1 -1
    Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit

  sql/ha_ndbcluster.cc
    1.137 05/04/13 12:42:07 mskold@stripped +22 -12
    Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit

  ndb/src/ndbapi/Ndb.cpp
    1.40 05/04/13 12:42:07 mskold@stripped +25 -17
    Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit

# 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:	mskold
# Host:	blowfish.ndb.mysql.com
# Root:	/usr/local/home/marty/MySQL/mysql-4.1-build

--- 1.567/sql/mysqld.cc	Tue Apr  5 09:06:55 2005
+++ 1.568/sql/mysqld.cc	Wed Apr 13 12:42:07 2005
@@ -4548,7 +4548,7 @@
    "Specify number of autoincrement values that are prefetched.",
    (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
    (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz,
-   0, GET_INT, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
+   0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0},
   {"ndb-force-send", OPT_NDB_FORCE_SEND,
    "Force send of buffers to ndb immediately without waiting for "
    "other threads.",

--- 1.39/ndb/src/ndbapi/Ndb.cpp	Tue Dec 21 10:37:08 2004
+++ 1.40/ndb/src/ndbapi/Ndb.cpp	Wed Apr 13 12:42:07 2005
@@ -722,26 +722,28 @@
 Uint64
 Ndb::getAutoIncrementValue(const char* aTableName, Uint32 cacheSize)
 {
-  DEBUG_TRACE("getAutoIncrementValue");
+  DBUG_ENTER("getAutoIncrementValue");
   const char * internalTableName = internalizeTableName(aTableName);
   Ndb_local_table_info *info=
     theDictionary->get_local_table_info(internalTableName, false);
   if (info == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl *table= info->m_table_impl;
   Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
 Ndb::getAutoIncrementValue(const NdbDictionary::Table * aTable, Uint32 cacheSize)
 {
-  DEBUG_TRACE("getAutoIncrementValue");
+  DBUG_ENTER("getAutoIncrementValue");
   if (aTable == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   Uint64 tupleId = getTupleIdFromNdb(table->m_tableId, cacheSize);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64 
@@ -749,46 +751,52 @@
 {
   const NdbTableImpl* table = theDictionary->getTable(aTableName);
   if (table == 0)
-    return ~0;
+    return ~(Uint64)0;
   return getTupleIdFromNdb(table->m_tableId, cacheSize);
 }
 
 Uint64
 Ndb::getTupleIdFromNdb(Uint32 aTableId, Uint32 cacheSize)
 {
+  DBUG_ENTER("getTupleIdFromNdb");
   if ( theFirstTupleId[aTableId] != theLastTupleId[aTableId] )
   {
     theFirstTupleId[aTableId]++;
-    return theFirstTupleId[aTableId];
+    DBUG_PRINT("info", ("next cached value %u", theFirstTupleId[aTableId]));
+    DBUG_RETURN(theFirstTupleId[aTableId]);
   }
   else // theFirstTupleId == theLastTupleId
   {
-    return opTupleIdOnNdb(aTableId, cacheSize, 0);
+    DBUG_PRINT("info",("reading %u values from database", 
+                       (cacheSize == 0) ? 1 : cacheSize));
+    DBUG_RETURN(opTupleIdOnNdb(aTableId, (cacheSize == 0) ? 1 : cacheSize, 0));
   }
 }
 
 Uint64
 Ndb::readAutoIncrementValue(const char* aTableName)
 {
-  DEBUG_TRACE("readtAutoIncrementValue");
+  DBUG_ENTER("readtAutoIncrementValue");
   const NdbTableImpl* table = theDictionary->getTable(aTableName);
   if (table == 0) {
     theError= theDictionary->getNdbError();
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   }
   Uint64 tupleId = readTupleIdFromNdb(table->m_tableId);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
 Ndb::readAutoIncrementValue(const NdbDictionary::Table * aTable)
 {
-  DEBUG_TRACE("readtAutoIncrementValue");
+  DBUG_ENTER("readtAutoIncrementValue");
   if (aTable == 0)
-    return ~0;
+    DBUG_RETURN(~(Uint64)0);
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   Uint64 tupleId = readTupleIdFromNdb(table->m_tableId);
-  return tupleId;
+  DBUG_PRINT("info", ("value %u", tupleId));
+  DBUG_RETURN(tupleId);
 }
 
 Uint64
@@ -821,7 +829,7 @@
 {
   DEBUG_TRACE("setAutoIncrementValue " << val);
   if (aTable == 0)
-    return ~0;
+    return ~(Uint64)0;
   const NdbTableImpl* table = & NdbTableImpl::getImpl(*aTable);
   return setTupleIdInNdb(table->m_tableId, val, increase);
 }
@@ -971,7 +979,7 @@
     setDatabaseName(currentDb.c_str());
     setDatabaseSchemaName(currentSchema.c_str());
 
-  return ~0;
+  return ~(Uint64)0;
 }
 
 Uint32

--- 1.136/sql/ha_ndbcluster.cc	Fri Apr  1 17:59:28 2005
+++ 1.137/sql/ha_ndbcluster.cc	Wed Apr 13 12:42:07 2005
@@ -1854,7 +1854,7 @@
   m_rows_inserted++;
   no_uncommitted_rows_update(1);
   m_bulk_insert_not_flushed= TRUE;
-  if ((m_rows_to_insert == 1) || 
+  if ((m_rows_to_insert == (ha_rows) 1) || 
       ((m_rows_inserted % m_bulk_insert_rows) == 0) ||
       set_blob_value)
   {
@@ -2919,8 +2919,12 @@
   DBUG_ENTER("start_bulk_insert");
   DBUG_PRINT("enter", ("rows: %d", (int)rows));
   
-  m_rows_inserted= 0;
-  m_rows_to_insert= rows; 
+  m_rows_inserted= (ha_rows) 0;
+  if (rows == (ha_rows) 0)
+    /* We don't know how many will be inserted, guess */
+    m_rows_to_insert= m_autoincrement_prefetch;
+  else
+    m_rows_to_insert= rows; 
 
   /* 
     Calculate how many rows that should be inserted
@@ -2954,7 +2958,7 @@
     // Send rows to NDB
     DBUG_PRINT("info", ("Sending inserts to NDB, "\
                         "rows_inserted:%d, bulk_insert_rows: %d", 
-                        m_rows_inserted, m_bulk_insert_rows)); 
+                        (int) m_rows_inserted, (int) m_bulk_insert_rows)); 
     m_bulk_insert_not_flushed= FALSE;
     if (execute_no_commit(this,trans) != 0) {
       no_uncommitted_rows_execute_failure();
@@ -2962,8 +2966,8 @@
     }
   }
 
-  m_rows_inserted= 0;
-  m_rows_to_insert= 1;
+  m_rows_inserted= (ha_rows) 0;
+  m_rows_to_insert= (ha_rows) 1;
   DBUG_RETURN(error);
 }
 
@@ -3152,7 +3156,8 @@
     // store thread specific data first to set the right context
     m_force_send=          thd->variables.ndb_force_send;
     m_ha_not_exact_count= !thd->variables.ndb_use_exact_count;
-    m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz;
+    m_autoincrement_prefetch= 
+      (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz;
     if (!thd->transaction.on)
       m_transaction_on= FALSE;
     else
@@ -3566,7 +3571,7 @@
 
 static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length)
 {
-  if (form->max_rows == 0) /* default setting, don't set fragmentation */
+  if (form->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */
     return;
   /**
    * get the number of fragments right
@@ -3929,7 +3934,12 @@
   DBUG_ENTER("get_auto_increment");
   DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
   Ndb *ndb= get_ndb();
+  
+  if (m_rows_inserted > m_rows_to_insert)
+    /* We guessed too low */
+    m_rows_to_insert+= m_autoincrement_prefetch;
   int cache_size= 
+    (int)
     (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ?
     m_rows_to_insert - m_rows_inserted 
     : (m_rows_to_insert > m_autoincrement_prefetch) ? 
@@ -3964,9 +3974,9 @@
   m_primary_key_update(FALSE),
   m_retrieve_all_fields(FALSE),
   m_retrieve_primary_key(FALSE),
-  m_rows_to_insert(1),
-  m_rows_inserted(0),
-  m_bulk_insert_rows(1024),
+  m_rows_to_insert((ha_rows) 1),
+  m_rows_inserted((ha_rows) 0),
+  m_bulk_insert_rows((ha_rows) 1024),
   m_bulk_insert_not_flushed(FALSE),
   m_ops_pending(0),
   m_skip_auto_increment(TRUE),
@@ -3976,7 +3986,7 @@
   m_dupkey((uint) -1),
   m_ha_not_exact_count(FALSE),
   m_force_send(TRUE),
-  m_autoincrement_prefetch(32),
+  m_autoincrement_prefetch((ha_rows) 32),
   m_transaction_on(TRUE),
   m_use_local_query_cache(FALSE)
 { 
Thread
bk commit into 4.1 tree (mskold:1.2169) BUG#9813Martin Skold13 Apr