From 19a2eced822fa5467651e6ce50b06b2160f36439 Mon Sep 17 00:00:00 2001
From: "mskold@mysql.com" <>
Date: Tue, 7 Sep 2004 16:21:29 +0200
Subject: [PATCH 1/3] Removed unnecessary condition

---
 sql/handler.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sql/handler.cc b/sql/handler.cc
index 15f30b25eb8..b412060f501 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1433,9 +1433,9 @@ int handler::read_range_first(const key_range *start_key,
 		       start_key->length,
 		       start_key->flag);
   if (result)
-    DBUG_RETURN((result == HA_ERR_KEY_NOT_FOUND ||
-		 result == HA_ERR_END_OF_FILE) ? HA_ERR_END_OF_FILE :
-		result);
+    DBUG_RETURN((result == HA_ERR_KEY_NOT_FOUND) 
+		? HA_ERR_END_OF_FILE
+		: result);
 
   DBUG_RETURN (compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
 }

From 5827b829b0cc1368a5fb0c97d25a0a15b3471cf0 Mon Sep 17 00:00:00 2001
From: "mskold@mysql.com" <>
Date: Tue, 7 Sep 2004 16:22:42 +0200
Subject: [PATCH 2/3] Added use of buffer argument in index_read

---
 sql/ha_ndbcluster.cc | 25 ++++++++++++++++++++-----
 sql/ha_ndbcluster.h  |  4 ++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 815aed13ce3..9629a358fc3 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -1907,8 +1907,8 @@ int ha_ndbcluster::index_end()
 
 
 int ha_ndbcluster::index_read(byte *buf,
-			  const byte *key, uint key_len, 
-			  enum ha_rkey_function find_flag)
+			      const byte *key, uint key_len, 
+			      enum ha_rkey_function find_flag)
 {
   DBUG_ENTER("index_read");
   DBUG_PRINT("enter", ("active_index: %u, key_len: %u, find_flag: %d", 
@@ -1918,7 +1918,7 @@ int ha_ndbcluster::index_read(byte *buf,
   start_key.key=    key;
   start_key.length= key_len;
   start_key.flag=   find_flag;
-  DBUG_RETURN(read_range_first(&start_key, NULL, false, true));
+  DBUG_RETURN(read_range_first_to_buf(&start_key, NULL, false, true, buf));
 }
 
 
@@ -1972,10 +1972,25 @@ int ha_ndbcluster::read_range_first(const key_range *start_key,
 				    const key_range *end_key,
 				    bool eq_range, bool sorted)
 {
-  KEY* key_info;
-  int error= 1; 
   byte* buf= table->record[0];
   DBUG_ENTER("ha_ndbcluster::read_range_first");
+  
+  DBUG_RETURN(read_range_first_to_buf(start_key,
+				      end_key,
+				      eq_range, 
+				      sorted,
+				      buf));
+}
+
+inline
+int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key,
+					   const key_range *end_key,
+					   bool eq_range, bool sorted,
+					   byte* buf)
+{
+  KEY* key_info;
+  int error= 1; 
+  DBUG_ENTER("ha_ndbcluster::read_range_first_to_buf");
   DBUG_PRINT("info", ("eq_range: %d, sorted: %d", eq_range, sorted));
 
   if (m_active_cursor)
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index c49a6078e7a..d71db9268bb 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -93,6 +93,10 @@ class ha_ndbcluster: public handler
   int read_range_first(const key_range *start_key,
 		       const key_range *end_key,
 		       bool eq_range, bool sorted);
+  int read_range_first_to_buf(const key_range *start_key,
+			      const key_range *end_key,
+			      bool eq_range, bool sorted,
+			      byte* buf);
   int read_range_next();
 
   bool get_error_message(int error, String *buf);

From d555950b9d61f3df68d4de891a6e3f563c7ce6a1 Mon Sep 17 00:00:00 2001
From: "mskold@mysql.com" <>
Date: Sat, 11 Sep 2004 20:53:57 +0200
Subject: [PATCH 3/3] Reomeved compiler warnings

---
 ndb/include/mgmcommon/ConfigRetriever.hpp      |  2 +-
 ndb/src/common/debugger/signaldata/ScanTab.cpp |  2 +-
 ndb/src/common/mgmcommon/ConfigRetriever.cpp   |  4 ++--
 ndb/src/common/mgmcommon/LocalConfig.cpp       |  2 +-
 ndb/src/ndbapi/Ndb.cpp                         |  4 ++--
 ndb/src/ndbapi/NdbDictionary.cpp               |  3 ++-
 ndb/src/ndbapi/NdbDictionaryImpl.cpp           |  8 ++++----
 ndb/src/ndbapi/Ndbif.cpp                       | 12 +++++++-----
 ndb/src/ndbapi/Ndbinit.cpp                     |  2 +-
 9 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp
index 396ce24308c..270dd370360 100644
--- a/ndb/include/mgmcommon/ConfigRetriever.hpp
+++ b/ndb/include/mgmcommon/ConfigRetriever.hpp
@@ -90,7 +90,7 @@ private:
   
   BaseString            _localConfigFileName;
   struct LocalConfig    _localConfig;
-  int                   _ownNodeId;
+  Uint32                _ownNodeId;
   
   BaseString            m_connectString;
   
diff --git a/ndb/src/common/debugger/signaldata/ScanTab.cpp b/ndb/src/common/debugger/signaldata/ScanTab.cpp
index 4b057171963..dfecd86829d 100644
--- a/ndb/src/common/debugger/signaldata/ScanTab.cpp
+++ b/ndb/src/common/debugger/signaldata/ScanTab.cpp
@@ -82,7 +82,7 @@ printSCANTABCONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 recei
     fprintf(output, " Operation(s) [api tc rows len]:\n");
     ScanTabConf::OpData * op = (ScanTabConf::OpData*)
       (theData + ScanTabConf::SignalLength);
-    for(int i = 0; i<op_count; i++){
+    for(size_t i = 0; i<op_count; i++){
       if(op->info != ScanTabConf::EndOfData)
 	fprintf(output, " [0x%x 0x%x %d %d]",
 		op->apiPtrI, op->tcPtrI,
diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
index 2e809907058..de71c9353da 100644
--- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp
+++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp
@@ -94,7 +94,7 @@ ConfigRetriever::do_connect(){
   while(retry < retry_max){
     Uint32 type = CR_ERROR;
     BaseString tmp;
-    for (int i = 0; i<_localConfig.ids.size(); i++){
+    for (unsigned int i = 0; i<_localConfig.ids.size(); i++){
       MgmtSrvrId * m = &_localConfig.ids[i];
       switch(m->type){
       case MgmId_TCP:
@@ -138,7 +138,7 @@ ConfigRetriever::getConfig() {
   if(m_handle != 0){
     p = getConfig(m_handle);
   } else {
-    for (int i = 0; i<_localConfig.ids.size(); i++){
+    for (unsigned int i = 0; i<_localConfig.ids.size(); i++){
       MgmtSrvrId * m = &_localConfig.ids[i];
       switch(m->type){
       case MgmId_File:
diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/common/mgmcommon/LocalConfig.cpp
index 0440ce84dba..7f29afd4971 100644
--- a/ndb/src/common/mgmcommon/LocalConfig.cpp
+++ b/ndb/src/common/mgmcommon/LocalConfig.cpp
@@ -241,7 +241,7 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
     return false;
   }
 
-  int sz = 1024;
+  unsigned int sz = 1024;
   char* theString = (char*)malloc(sz);
   theString[0] = 0;
 
diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp
index f09a7481d2d..ce31fd3354f 100644
--- a/ndb/src/ndbapi/Ndb.cpp
+++ b/ndb/src/ndbapi/Ndb.cpp
@@ -1108,7 +1108,7 @@ void Ndb::setCatalogName(const char * a_catalog_name)
     int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
                        theDataBase, table_name_separator,
                        theDataBaseSchema, table_name_separator);
-    prefixEnd = prefixName + (len < sizeof(prefixName) ? len : 
+    prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len : 
                               sizeof(prefixName) - 1);
   }
 }
@@ -1127,7 +1127,7 @@ void Ndb::setSchemaName(const char * a_schema_name)
     int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
                        theDataBase, table_name_separator,
                        theDataBaseSchema, table_name_separator);
-    prefixEnd = prefixName + (len < sizeof(prefixName) ? len : 
+    prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len : 
                               sizeof(prefixName) - 1);
   }
 }
diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp
index 4b30f41b51d..420d34f33d8 100644
--- a/ndb/src/ndbapi/NdbDictionary.cpp
+++ b/ndb/src/ndbapi/NdbDictionary.cpp
@@ -229,7 +229,8 @@ NdbDictionary::Table::Table(const char * name)
 }
 
 NdbDictionary::Table::Table(const NdbDictionary::Table & org)
-  : m_impl(* new NdbTableImpl(* this))
+  : NdbDictionary::Object(),
+    m_impl(* new NdbTableImpl(* this))
 {
   m_impl.assign(org.m_impl);
 }
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index cb5e3b3c821..10844bd4415 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -385,7 +385,7 @@ void
 NdbTableImpl::buildColumnHash(){
   const Uint32 size = m_columns.size();
 
-  size_t i;
+  int i;
   for(i = 31; i >= 0; i--){
     if(((1 << i) & size) != 0){
       m_columnHashMask = (1 << (i + 1)) - 1;
@@ -395,7 +395,7 @@ NdbTableImpl::buildColumnHash(){
 
   Vector<Uint32> hashValues;
   Vector<Vector<Uint32> > chains; chains.fill(size, hashValues);
-  for(i = 0; i<size; i++){
+  for(i = 0; i< (int) size; i++){
     Uint32 hv = Hash(m_columns[i]->getName()) & 0xFFFE;
     Uint32 bucket = hv & m_columnHashMask;
     bucket = (bucket < size ? bucket : bucket - size);
@@ -409,7 +409,7 @@ NdbTableImpl::buildColumnHash(){
   m_columnHash.fill((unsigned)size-1, tmp);   // Default no chaining
 
   Uint32 pos = 0; // In overflow vector
-  for(i = 0; i<size; i++){
+  for(i = 0; i< (int) size; i++){
     Uint32 sz = chains[i].size();
     if(sz == 1){
       Uint32 col = chains[i][0];
@@ -1368,7 +1368,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
 	   internalName);
 
   bool haveAutoIncrement = false;
-  Uint64 autoIncrementValue;
+  Uint64 autoIncrementValue = 0;
   for(i = 0; i<sz; i++){
     const NdbColumnImpl * col = impl.m_columns[i];
     if(col == 0)
diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp
index 7ad37401b9a..7e11d58912d 100644
--- a/ndb/src/ndbapi/Ndbif.cpp
+++ b/ndb/src/ndbapi/Ndbif.cpp
@@ -375,7 +375,8 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
 	  break;
 	case NdbReceiver::NDB_SCANRECEIVER:
 	  tCon->theScanningOp->receiver_delivered(tRec);
-	  theWaiter.m_state = (tWaitState == WAIT_SCAN ? NO_WAIT : tWaitState);
+	  theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? 
+			       (Uint32) NO_WAIT : tWaitState);
 	  break;
 	default:
 	  goto InvalidSignal;
@@ -747,7 +748,8 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
       switch(com){
       case 1:
 	tCon->theScanningOp->receiver_delivered(tRec);
-	theWaiter.m_state = (tWaitState == WAIT_SCAN ? NO_WAIT : tWaitState);
+	theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? 
+			      (Uint32) NO_WAIT : tWaitState);
 	break;
       case 0:
 	break;
@@ -871,8 +873,8 @@ Ndb::completedTransaction(NdbConnection* aCon)
       return;
     }//if
   } else {
-    ndbout << "theNoOfSentTransactions = " << theNoOfSentTransactions;
-    ndbout << " theListState = " << aCon->theListState;
+    ndbout << "theNoOfSentTransactions = " << (int) theNoOfSentTransactions;
+    ndbout << " theListState = " << (int) aCon->theListState;
     ndbout << " theTransArrayIndex = " << aCon->theTransArrayIndex;
     ndbout << endl << flush;
 #ifdef VM_TRACE
@@ -923,7 +925,7 @@ Ndb::pollCompleted(NdbConnection** aCopyArray)
       aCopyArray[i] = theCompletedTransactionsArray[i];
       if (aCopyArray[i]->theListState != NdbConnection::InCompletedList) {
         ndbout << "pollCompleted error ";
-        ndbout << aCopyArray[i]->theListState << endl;
+        ndbout << (int) aCopyArray[i]->theListState << endl;
 	abort();
       }//if
       theCompletedTransactionsArray[i] = NULL;
diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp
index be168ddffbe..ec04ea3e7ad 100644
--- a/ndb/src/ndbapi/Ndbinit.cpp
+++ b/ndb/src/ndbapi/Ndbinit.cpp
@@ -130,7 +130,7 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) :
   int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
                      theDataBase, table_name_separator,
                      theDataBaseSchema, table_name_separator);
-  prefixEnd = prefixName + (len < sizeof(prefixName) ? len : 
+  prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len : 
                             sizeof(prefixName) - 1);
 
   NdbMutex_Lock(&createNdbMutex);