List:Internals« Previous MessageNext Message »
From:Martin Skold Date:April 7 2005 5:44pm
Subject:bk commit into 4.1 tree (mskold:1.2171) BUG#9675
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.2171 05/04/07 17:44:09 mskold@stripped +4 -0
  Fix for Bug #9675 Auto-increment not working with INSERT..SELECT and NDB storage

  sql/ha_ndbcluster.cc
    1.137 05/04/07 17:43:51 mskold@stripped +6 -1
    Fix for Bug #9675 Auto-increment not working with INSERT..SELECT and NDB storage

  ndb/src/ndbapi/Ndb.cpp
    1.40 05/04/07 17:43:51 mskold@stripped +22 -14
    Fix for Bug #9675 Auto-increment not working with INSERT..SELECT and NDB storage

  mysql-test/t/ndb_basic.test
    1.23 05/04/07 17:43:51 mskold@stripped +25 -0
    Fix for Bug #9675 Auto-increment not working with INSERT..SELECT and NDB storage

  mysql-test/r/ndb_basic.result
    1.23 05/04/07 17:43:51 mskold@stripped +30 -0
    Fix for Bug #9675 Auto-increment not working with INSERT..SELECT and NDB storage

# 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

--- 1.22/mysql-test/r/ndb_basic.result	Fri Feb  4 14:25:04 2005
+++ 1.23/mysql-test/r/ndb_basic.result	Thu Apr  7 17:43:51 2005
@@ -607,3 +607,33 @@
 engine=ndb
 max_rows=1;
 drop table t1;
+create table t1
+(counter int(64) NOT NULL auto_increment,
+datavalue char(40) default 'XXXX',
+primary key (counter)
+) ENGINE=ndbcluster;
+insert into t1 (datavalue) values ('newval');
+insert into t1 (datavalue) values ('newval');
+select * from t1 order by counter;
+counter	datavalue
+1	newval
+2	newval
+insert into t1 (datavalue) select datavalue from t1 where counter < 100;
+select * from t1 order by counter;
+counter	datavalue
+1	newval
+2	newval
+3	newval
+4	newval
+insert into t1 (datavalue) select datavalue from t1 where counter < 100;
+select * from t1 order by counter;
+counter	datavalue
+1	newval
+2	newval
+3	newval
+4	newval
+35	newval
+36	newval
+37	newval
+38	newval
+drop table t1;

--- 1.22/mysql-test/t/ndb_basic.test	Fri Feb  4 14:25:04 2005
+++ 1.23/mysql-test/t/ndb_basic.test	Thu Apr  7 17:43:51 2005
@@ -577,3 +577,28 @@
   engine=ndb
   max_rows=1;
 drop table t1;
+
+#
+# Test auto_increment
+#
+
+connect (con1,localhost,,,test);
+connect (con2,localhost,,,test);
+
+create table t1
+	(counter int(64) NOT NULL auto_increment,
+	 datavalue char(40) default 'XXXX',
+	 primary key (counter)
+	) ENGINE=ndbcluster;
+
+connection con1;
+insert into t1 (datavalue) values ('newval');
+insert into t1 (datavalue) values ('newval');
+select * from t1 order by counter;
+insert into t1 (datavalue) select datavalue from t1 where counter < 100;
+select * from t1 order by counter;
+connection con2;
+insert into t1 (datavalue) select datavalue from t1 where counter < 100;
+select * from t1 order by counter;
+
+drop table t1;

--- 1.39/ndb/src/ndbapi/Ndb.cpp	Tue Dec 21 10:37:08 2004
+++ 1.40/ndb/src/ndbapi/Ndb.cpp	Thu Apr  7 17:43:51 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(~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(~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 
@@ -756,39 +758,45 @@
 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(~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(~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

--- 1.136/sql/ha_ndbcluster.cc	Fri Apr  1 17:59:28 2005
+++ 1.137/sql/ha_ndbcluster.cc	Thu Apr  7 17:43:51 2005
@@ -2920,7 +2920,11 @@
   DBUG_PRINT("enter", ("rows: %d", (int)rows));
   
   m_rows_inserted= 0;
-  m_rows_to_insert= rows; 
+  if (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
@@ -3929,6 +3933,7 @@
   DBUG_ENTER("get_auto_increment");
   DBUG_PRINT("enter", ("m_tabname: %s", m_tabname));
   Ndb *ndb= get_ndb();
+
   int cache_size= 
     (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ?
     m_rows_to_insert - m_rows_inserted 
Thread
bk commit into 4.1 tree (mskold:1.2171) BUG#9675Martin Skold7 Apr