=== modified file 'configure.in'
--- a/configure.in	2008-08-08 12:32:37 +0000
+++ b/configure.in	2008-08-24 13:36:25 +0000
@@ -10,12 +10,12 @@
 #
 # When changing major version number please also check switch statement
 # in mysqlbinlog::check_master_version().
-AM_INIT_AUTOMAKE(mysql, 5.1.27-ndb-6.3.16)
+AM_INIT_AUTOMAKE(mysql, 5.1.27-ndb-6.3.17)
 AM_CONFIG_HEADER([include/config.h:config.h.in])
 
 NDB_VERSION_MAJOR=6
 NDB_VERSION_MINOR=3
-NDB_VERSION_BUILD=16
+NDB_VERSION_BUILD=17
 NDB_VERSION_STATUS="-RC"
 
 PROTOCOL_VERSION=10

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2008-08-08 12:32:37 +0000
+++ b/mysql-test/mysql-test-run.pl	2008-08-26 10:05:18 +0000
@@ -796,11 +796,11 @@
 				       "$glob_basedir/bin");
 
   # Look for language files and charsetsdir, use same share
-  $path_share=      mtr_path_exists("$glob_basedir/share/mysql",
-                                    "$glob_basedir/sql/share",
-                                    "$glob_basedir/share");
+  $path_language=   mtr_path_exists("$glob_basedir/share/mysql/english",
+                                    "$glob_basedir/sql/share/english",
+                                    "$glob_basedir/share/english");
 
-  $path_language=      mtr_path_exists("$path_share/english");
+  $path_share= dirname($path_language);
   $path_charsetsdir=   mtr_path_exists("$path_share/charsets");
 
 

=== modified file 'storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp'
--- a/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp	2008-08-16 13:51:16 +0000
+++ b/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp	2008-08-26 10:07:22 +0000
@@ -245,6 +245,7 @@
   /* Structure used to collect information about an IndexBound
    * as it is provided by the old Api setBound() calls
    */
+public:
   struct OldApiBoundInfo
   {
     Uint32 highestKey;
@@ -253,6 +254,7 @@
     char* key;
   };
 
+private:
   struct OldApiScanRangeDefinition
   {
     /* OldApiBoundInfo used during definition

=== modified file 'storage/ndb/src/common/transporter/TCP_Transporter.cpp'
--- a/storage/ndb/src/common/transporter/TCP_Transporter.cpp	2008-08-26 14:12:34 +0000
+++ b/storage/ndb/src/common/transporter/TCP_Transporter.cpp	2008-08-26 16:15:12 +0000
@@ -167,7 +167,7 @@
 	int val)
 {
   int actual = 0, defval = 0;
-  socklen_t len = sizeof(actual);
+  SOCKET_SIZE_TYPE len = sizeof(actual);
 
   getsockopt(fd, level, optval, (char*)&defval, &len);
   

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-08-11 11:24:12 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2008-08-21 22:14:40 +0000
@@ -7127,7 +7127,7 @@
 /* ------------------------------------------------------------------------- */
     ndbrequire(regTcPtr->abortState == TcConnectionrec::NEW_FROM_TC);
     sendLqhTransconf(signal, LqhTransConf::Prepared);
-    break;
+    return;
   case TcConnectionrec::WAIT_TUPKEYINFO:
   case TcConnectionrec::WAIT_ATTR:
     jam();

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2008-08-11 11:24:12 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2008-08-21 22:14:40 +0000
@@ -4736,10 +4736,7 @@
 
     SET_ERROR_INSERT_VALUE(8056);
 
-    Ptr<ApiConnectRecord> copyPtr;
-    copyPtr.i = regApiPtr.p->apiCopyRecord;
-    ptrCheckGuard(copyPtr, capiConnectFilesize, apiConnectRecord);
-    return copyPtr;
+    goto err8055;
   }
 
   if (regApiPtr.p->returnsignal == RS_TCKEYCONF)
@@ -4786,6 +4783,8 @@
     TCKEY_abort(signal, 37);
     return regApiPtr;
   }//if
+
+err8055:
   Ptr<ApiConnectRecord> copyPtr;
   UintR TapiConnectFilesize = capiConnectFilesize;
   UintR TcommitCount = c_counters.ccommitCount;

=== modified file 'storage/ndb/src/kernel/blocks/restore.cpp'
--- a/storage/ndb/src/kernel/blocks/restore.cpp	2008-03-18 07:12:39 +0000
+++ b/storage/ndb/src/kernel/blocks/restore.cpp	2008-08-21 22:14:40 +0000
@@ -1136,12 +1136,12 @@
       src += sz;
       break;
     case NDB_ARRAYTYPE_SHORT_VAR:
-      sz = (1 + ((char*)var)[0] + 3) >> 2;
+      sz = (1 + ((Uint8*)var)[0] + 3) >> 2;
       memcpy(dst, var, 4 * sz);
       var += sz;
       break;
     case NDB_ARRAYTYPE_MEDIUM_VAR:
-      sz = (2 + ((char*)var)[0] +  256*((char*)var)[1] + 3) >> 2;
+      sz = (2 + ((Uint8*)var)[0] +  256*((Uint8*)var)[1] + 3) >> 2;
       memcpy(dst, var, 4 * sz);
       var += sz;
       break;

=== modified file 'storage/ndb/src/mgmapi/mgmapi.cpp'
--- a/storage/ndb/src/mgmapi/mgmapi.cpp	2008-03-13 14:09:32 +0000
+++ b/storage/ndb/src/mgmapi/mgmapi.cpp	2008-08-21 22:14:40 +0000
@@ -125,7 +125,6 @@
 
 #define CHECK_HANDLE(handle, ret) \
   if(handle == 0) { \
-    SET_ERROR(handle, NDB_MGM_ILLEGAL_SERVER_HANDLE, ""); \
     return ret; \
   } 
 

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2008-07-29 09:41:01 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2008-08-21 22:14:40 +0000
@@ -1162,7 +1162,7 @@
 	CAST_CONSTPTR(NodeFailRep, signal->getDataPtr());
       NdbNodeBitmask mask;
       mask.assign(NdbNodeBitmask::Size, rep->theNodes);
-      mask.bitAND(notstarted);
+      mask.bitANDC(notstarted);
       nodes.bitANDC(mask);
       
       if (singleUserNodeId == 0)

=== modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2008-08-16 13:51:16 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2008-08-22 13:10:38 +0000
@@ -3492,7 +3492,7 @@
   DBUG_ENTER("end_of_bound");
   DBUG_PRINT("info", ("Range number %u", no));
 
-  if (! (m_savedScanFlagsOldApi & SF_MultiRange))
+  if (! (m_savedScanFlagsOldApi & SF_MultiRange || no == 0))
   {
     setErrorCodeAbort(4509);
     /* Non SF_MultiRange scan cannot have more than one bound */

=== modified file 'storage/ndb/test/ndbapi/testIndex.cpp'
--- a/storage/ndb/test/ndbapi/testIndex.cpp	2008-03-25 14:17:03 +0000
+++ b/storage/ndb/test/ndbapi/testIndex.cpp	2008-08-21 22:05:42 +0000
@@ -169,6 +169,29 @@
     ndbout << pTab->getColumn(attrNo)->getName()<<" ";
   }
   
+  if (!orderedIndex)
+  {
+    /**
+     * For unique indexes we must add PK, otherwise it's not guaranteed
+     *  to be unique
+     */
+    for (int i = 0; i<pTab->getNoOfColumns(); i++)
+    {
+      if (pTab->getColumn(i)->getPrimaryKey())
+      {
+        for (int j = 0; j<attr->numAttribs; j++)
+        {
+          if (attr->attribs[j] == i)
+            goto next;
+        }
+        pIdx.addIndexColumn(pTab->getColumn(i)->getName());
+        ndbout << pTab->getColumn(i)->getName() << " ";
+      }
+  next:
+      (void)i;
+    }
+  }
+
   pIdx.setStoredIndex(logged);
   ndbout << ") ";
   if (pNdb->getDictionary()->createIndex(pIdx) != 0){

=== modified file 'storage/ndb/test/ndbapi/testNodeRestart.cpp'
--- a/storage/ndb/test/ndbapi/testNodeRestart.cpp	2008-04-25 07:20:39 +0000
+++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp	2008-08-21 22:14:40 +0000
@@ -2466,21 +2466,33 @@
       break;
     }
 
-    int rows = 10;
+    int rows = 25;
+    if (rows > records)
+      rows = records;
+
     int batch = 1;
     int row = (records - rows) ? rand() % (records - rows) : 0;
-
-    if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
-      goto err;
-
-    for (int l = 1; l<5; l++)
+    if (row + rows > records)
+      row = records - row;
+
+    /**
+     * We should really somehow check that one of the 25 rows
+     *   resides in the node we're targeting
+     */
+    for (int r = row; r < row + rows; r++)
     {
-      if (hugoOps.execute_NoCommit(pNdb) != 0)
-        goto err;
-
-      if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
-        goto err;
-    }
+      if(hugoOps.pkUpdateRecord(pNdb, r, batch, rand()) != 0)
+        goto err;
+      
+      for (int l = 1; l<5; l++)
+      {
+        if (hugoOps.execute_NoCommit(pNdb) != 0)
+          goto err;
+        
+        if(hugoOps.pkUpdateRecord(pNdb, r, batch, rand()) != 0)
+          goto err;
+      }
+    }      
 
     hugoOps.execute_Commit(pNdb);
     hugoOps.closeTransaction(pNdb);

=== modified file 'storage/ndb/test/ndbapi/testSystemRestart.cpp'
--- a/storage/ndb/test/ndbapi/testSystemRestart.cpp	2008-06-18 21:25:50 +0000
+++ b/storage/ndb/test/ndbapi/testSystemRestart.cpp	2008-08-22 22:09:50 +0000
@@ -1551,6 +1551,7 @@
   Uint32 i = 0;
   while(i<=loops && result != NDBT_FAILED)
   {
+    ndbout_c("loop %u", i);
     for (Uint32 j = 0; j<10 && result != NDBT_FAILED; j++)
       CHECK(hugoTrans.scanUpdateRecords(pNdb, rows) == 0);
     

=== modified file 'storage/ndb/test/run-test/Makefile.am'
--- a/storage/ndb/test/run-test/Makefile.am	2008-06-25 10:17:27 +0000
+++ b/storage/ndb/test/run-test/Makefile.am	2008-08-23 20:31:15 +0000
@@ -27,7 +27,7 @@
 #          conf-dl145a.cnf test-tests.txt conf-test.cnf db.sql
 
 test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \
-          atrt-clear-result.sh autotest-run.sh
+          atrt-clear-result.sh autotest-run.sh atrt-backtrace.sh
 
 atrt_SOURCES = main.cpp setup.cpp files.cpp db.cpp command.cpp
 

=== modified file 'storage/ndb/test/run-test/atrt-analyze-result.sh'
--- a/storage/ndb/test/run-test/atrt-analyze-result.sh	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/atrt-analyze-result.sh	2008-08-24 18:38:25 +0000
@@ -1,5 +1,14 @@
 #!/bin/sh
 
+cores=`find result -name 'core*'`
+if [ "$cores" ]
+then
+    for i in "$cores"
+    do
+	atrt-backtrace.sh $i
+    done
+fi
+
 f=`find result -name 'log.out' | xargs grep "NDBT_ProgramExit: " | grep -c "Failed"`
 o=`find result -name 'log.out' | xargs grep "NDBT_ProgramExit: " | grep -c "OK"`
 

=== added file 'storage/ndb/test/run-test/atrt-backtrace.sh'
--- a/storage/ndb/test/run-test/atrt-backtrace.sh	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/test/run-test/atrt-backtrace.sh	2008-08-25 07:57:58 +0000
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+core=$1
+out=$2
+
+if [ ! -f "$core" ]
+then
+    exit
+fi
+
+#
+# gdb command file
+#
+bt=`dirname $core`/bt.gdb
+echo "thread apply all bt" > $bt
+echo "quit" >> $bt
+
+#
+# Fix output
+#
+if [ -z "$out" ]
+then
+    out=`dirname $core`/bt.txt
+fi
+outarg=">> $out 2>&1"
+if [ "$out" = "-" ]
+then
+    outarg=""
+fi
+
+#
+# get binary
+#
+tmp=`echo ${core}.tmp`
+gdb -c $core -x $bt -q 2>&1 | grep "Core was generated" | awk '{ print $5;}' | sed 's!`!!' | sed `echo "s/'\.//"` > $tmp
+exe=`cat $tmp`
+rm -f $tmp
+
+if [ -x $exe ]
+then
+    echo "*** $exe - $core" >> $out
+    eval "gdb -q -batch -x bt.gdb -c $core $exe $outarg"
+elif [ -x "`which $exe 2> /dev/null`" ]
+then
+    exe=`which $exe`
+    echo "*** $exe - $core" >> $out
+    eval "gdb -q -batch -x bt.gdb -c $core $exe $outarg"
+else
+    eval "echo \"*** $core : cant find exe: $exe\" $outarg"
+fi
+rm -f $bt

=== modified file 'storage/ndb/test/run-test/files.cpp'
--- a/storage/ndb/test/run-test/files.cpp	2007-04-02 06:39:58 +0000
+++ b/storage/ndb/test/run-test/files.cpp	2008-08-23 20:29:50 +0000
@@ -270,21 +270,23 @@
       }
       free(env);
       
-      tmp.assfmt("%s/ssh-login.sh", proc.m_proc.m_cwd.c_str());
-      FILE* fenv = fopen(tmp.c_str(), "w+");
-      if (fenv == 0)
       {
-	g_logger.error("Failed to open %s for writing", tmp.c_str());
-	return false;
+        tmp.assfmt("%s/ssh-login.sh", proc.m_proc.m_cwd.c_str());
+        FILE* fenv = fopen(tmp.c_str(), "w+");
+        if (fenv == 0)
+        {
+          g_logger.error("Failed to open %s for writing", tmp.c_str());
+          return false;
+        }
+        fprintf(fenv, "#!/bin/sh\n");
+        fprintf(fenv, "cd %s\n", proc.m_proc.m_cwd.c_str());
+        fprintf(fenv, "[ -f /etc/profile ] && . /etc/profile\n");
+        fprintf(fenv, ". env.sh\n");
+        fprintf(fenv, "ulimit -Sc unlimited\n");
+        fprintf(fenv, "bash -i");
+        fflush(fenv);
+        fclose(fenv);
       }
-      fprintf(fenv, "#!/bin/sh\n");
-      fprintf(fenv, "cd %s\n", proc.m_proc.m_cwd.c_str());
-      fprintf(fenv, "[ -f /etc/profile ] && . /etc/profile\n");
-      fprintf(fenv, ". env.sh\n");
-      fprintf(fenv, "ulimit -Sc unlimited\n");
-      fprintf(fenv, "bash -i");
-      fflush(fenv);
-      fclose(fenv);
     }
   }
   



