List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:April 20 2010 1:00pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3465)
View as plain text  
#At file:///home/msvensson/mysql/7.0-angel/ based on revid:magnus.blaudd@strippedm7f5n4ajsoei39na

 3465 Magnus Blåudd	2010-04-20 [merge]
      Merge

    removed:
      include/my_times.h
      mysys/my_times.c
    added:
      mysql-test/suite/rpl_ndb/r/rpl_ndb_empty_epoch.result
      mysql-test/suite/rpl_ndb/r/rpl_ndb_gap_event.result
      mysql-test/suite/rpl_ndb/t/rpl_ndb_empty_epoch.test
      mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event-master.opt
      mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event.test
      storage/ndb/src/common/logger/EventLogHandler.cpp
      storage/ndb/src/common/logger/EventLogHandler.hpp
      storage/ndb/src/common/logger/MSG00001.bin
      storage/ndb/src/common/logger/message.h
      storage/ndb/src/common/logger/message.mc
      storage/ndb/src/common/logger/message.rc
    modified:
      configure.in
      include/Makefile.am
      mysql-test/include/have_ndb.inc
      mysql-test/lib/My/SafeProcess.pm
      mysql-test/lib/mtr_misc.pl
      mysql-test/lib/mtr_report.pm
      mysql-test/mysql-test-run.pl
      mysql-test/suite/ndb/r/ndb_basic.result
      mysql-test/suite/ndb/r/ndb_cache.result
      mysql-test/suite/ndb/r/ndb_charset.result
      mysql-test/suite/ndb/r/ndb_restore_options.result
      mysql-test/suite/ndb/r/ndbinfo.result
      mysql-test/suite/ndb/t/have_ndbinfo.inc
      mysql-test/suite/ndb/t/ndb_cache.test
      mysql-test/suite/ndb/t/ndb_charset.test
      mysql-test/suite/ndb/t/ndb_config.test
      mysql-test/suite/ndb/t/ndbinfo.test
      mysql-test/suite/rpl_ndb/t/rpl_ndb_extraCol.test
      mysys/CMakeLists.txt
      mysys/Makefile.am
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbinfo.cc
      sql/log.cc
      sql/log_event.h
      sql/mysqld.cc
      sql/set_var.cc
      sql/sql_class.cc
      sql/sql_class.h
      storage/ndb/include/kernel/AttributeList.hpp
      storage/ndb/include/kernel/NodeBitmask.hpp
      storage/ndb/include/kernel/NodeState.hpp
      storage/ndb/include/kernel/signaldata/AlterTable.hpp
      storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp
      storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp
      storage/ndb/include/kernel/signaldata/CreateTable.hpp
      storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp
      storage/ndb/include/kernel/signaldata/ListTables.hpp
      storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp
      storage/ndb/include/logger/Logger.hpp
      storage/ndb/include/portlib/NdbTCP.h
      storage/ndb/include/util/Bitmask.hpp
      storage/ndb/src/common/logger/CMakeLists.txt
      storage/ndb/src/common/logger/Logger.cpp
      storage/ndb/src/common/logger/Makefile.am
      storage/ndb/src/common/util/Bitmask.cpp
      storage/ndb/src/common/util/SocketClient.cpp
      storage/ndb/src/common/util/azio.c
      storage/ndb/src/kernel/blocks/LocalProxy.cpp
      storage/ndb/src/kernel/blocks/LocalProxy.hpp
      storage/ndb/src/kernel/blocks/PgmanProxy.cpp
      storage/ndb/src/kernel/blocks/PgmanProxy.hpp
      storage/ndb/src/kernel/blocks/backup/Backup.cpp
      storage/ndb/src/kernel/blocks/backup/read.cpp
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
      storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.cpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.hpp
      storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.hpp
      storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.cpp
      storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.hpp
      storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp
      storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp
      storage/ndb/src/kernel/vm/WatchDog.cpp
      storage/ndb/src/mgmsrv/CMakeLists.txt
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp
      storage/ndb/src/mgmsrv/MgmtSrvr.hpp
      storage/ndb/src/mgmsrv/Services.cpp
      storage/ndb/src/mgmsrv/main.cpp
      storage/ndb/src/ndbapi/NdbApiSignal.hpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbInfo.cpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/ndberror.c
      storage/ndb/test/include/NdbRestarts.hpp
      storage/ndb/test/ndbapi/CMakeLists.txt
      storage/ndb/test/ndbapi/flexAsynch.cpp
      storage/ndb/test/ndbapi/flexTT.cpp
      storage/ndb/test/ndbapi/testIndex.cpp
      storage/ndb/test/ndbapi/testMgm.cpp
      storage/ndb/test/ndbapi/testNdbApi.cpp
      storage/ndb/test/ndbapi/testNodeRestart.cpp
      storage/ndb/test/ndbapi/testReconnect.cpp
      storage/ndb/test/ndbapi/testSystemRestart.cpp
      storage/ndb/test/ndbapi/testTimeout.cpp
      storage/ndb/test/ndbapi/testUpgrade.cpp
      storage/ndb/test/ndbapi/test_event.cpp
      storage/ndb/test/run-test/CMakeLists.txt
      storage/ndb/test/run-test/atrt-backtrace.sh
      storage/ndb/test/run-test/daily-basic-tests.txt
      storage/ndb/test/run-test/main.cpp
      storage/ndb/test/run-test/setup.cpp
      storage/ndb/test/src/NdbRestarts.cpp
      storage/ndb/tools/waiter.cpp
=== modified file 'configure.in'
--- a/configure.in	2010-03-12 11:56:09 +0000
+++ b/configure.in	2010-03-26 05:41:26 +0000
@@ -7,7 +7,7 @@ AC_PREREQ(2.59)
 # Remember to also update version.c in ndb.
 # When changing major version number please also check switch statement
 # in mysqlbinlog::check_master_version().
-AC_INIT([MySQL Server], [5.1.44-ndb-7.0.14], [], [mysql])
+AC_INIT([MySQL Server], [5.1.44-ndb-7.0.15], [], [mysql])
 AC_CONFIG_SRCDIR([sql/mysqld.cc])
 AC_CANONICAL_SYSTEM
 # USTAR format gives us the possibility to store longer path names in
@@ -26,7 +26,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_R
 
 NDB_VERSION_MAJOR=7
 NDB_VERSION_MINOR=0
-NDB_VERSION_BUILD=14
+NDB_VERSION_BUILD=15
 NDB_VERSION_STATUS=""
 
 PROTOCOL_VERSION=10

=== modified file 'include/Makefile.am'
--- a/include/Makefile.am	2009-05-27 15:21:45 +0000
+++ b/include/Makefile.am	2010-04-01 15:22:57 +0000
@@ -41,8 +41,7 @@ noinst_HEADERS =	config-win.h config-net
 			my_handler.h my_time.h \
 			my_vle.h my_user.h my_atomic.h atomic/nolock.h \
 			atomic/rwlock.h atomic/x86-gcc.h atomic/x86-msvc.h \
-			atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
-			my_times.h
+			atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h
 
 EXTRA_DIST =        mysql.h.pp mysql/plugin.h.pp
 

=== removed file 'include/my_times.h'
--- a/include/my_times.h	2008-08-27 06:41:29 +0000
+++ b/include/my_times.h	1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
-/* Copyright (C) 2008 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-#ifndef _MY_TIMES_H_
-#define _MY_TIMES_H_
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-#ifdef __WIN__
-struct tms {
-  clock_t tms_utime;  /* user time */
-  clock_t tms_stime;  /* system time */
-  clock_t tms_cutime; /* user time of children */
-  clock_t tms_cstime; /* system time of children */
-};
-clock_t times(struct tms *buf);
-
-#else
-#include <sys/times.h>
-#endif
-
-#ifdef __cplusplus
-} // extern C
-#endif
-
-#endif

=== modified file 'mysql-test/include/have_ndb.inc'
--- a/mysql-test/include/have_ndb.inc	2009-10-27 14:29:15 +0000
+++ b/mysql-test/include/have_ndb.inc	2010-03-30 06:42:20 +0000
@@ -21,17 +21,6 @@ if (!`select @have_ndb`){
   skip Need ndb engine;
 }
 
-#
-# cleanup
-#
-
-disable_warnings;
---error 0,1051
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
-flush tables;
-flush status;
-enable_warnings;
-
 enable_query_log;
 enable_result_log;
 

=== modified file 'mysql-test/lib/My/SafeProcess.pm'
--- a/mysql-test/lib/My/SafeProcess.pm	2009-08-25 19:44:04 +0000
+++ b/mysql-test/lib/My/SafeProcess.pm	2010-03-16 09:53:53 +0000
@@ -185,63 +185,6 @@ sub run {
 }
 
 #
-# Start a process that returns after "duration" seconds
-# or when it's parent process does not exist anymore
-#
-sub timer {
-  my $class= shift;
-  my $duration= shift or croak "duration required";
-  my $parent_pid= $$;
-
-  my $pid= My::SafeProcess::Base::_safe_fork();
-  if ($pid){
-    # Parent
-    my $proc= bless
-      ({
-	SAFE_PID  => $pid,
-	SAFE_NAME => "timer",
-	PARENT => $$,
-       }, $class);
-
-    # Put the new process in list of running
-    $running{$pid}= $proc;
-    return $proc;
-  }
-
-  # Child, install signal handlers and sleep for "duration"
-  $SIG{INT}= 'IGNORE';
-
-  $SIG{TERM}= sub {
-    #print STDERR "timer $$: woken up, exiting!\n";
-    exit(0);
-  };
-
-  $0= "safe_timer($duration)";
-
-  if (IS_WIN32PERL){
-    # Just a thread in same process
-    sleep($duration);
-    print STDERR "timer $$: expired after $duration seconds\n";
-    exit(0);
-  }
-
-  my $count_down= $duration;
-  while($count_down--){
-
-    # Check that parent is still alive
-    if (kill(0, $parent_pid) == 0){
-      #print STDERR "timer $$: parent gone, exiting!\n";
-      exit(0);
-    }
-
-    sleep(1);
-  }
-  print STDERR "timer $$: expired after $duration seconds\n";
-  exit(0);
-}
-
-
-#
 # Shutdown process nicely, and wait for shutdown_timeout seconds
 # If processes hasn't shutdown, kill them hard and wait for return
 #
@@ -350,12 +293,12 @@ sub start_kill {
     $ret= system($safe_kill, $winpid) >> 8;
 
     if ($ret == 3){
-      print "Couldn't open the winpid: $winpid ",
+      print "Couldn't open the winpid: $winpid ".
 	"for pid: $pid, try one more time\n";
       sleep(1);
       $winpid= _winpid($pid);
       $ret= system($safe_kill, $winpid) >> 8;
-      print "Couldn't open the winpid: $winpid ",
+      print "Couldn't open the winpid: $winpid ".
 	"for pid: $pid, continue and see what happens...\n";
     }
   }
@@ -550,6 +493,40 @@ sub wait_any {
 
 
 #
+# Wait for any process to exit, or a timeout
+#
+# Returns a reference to the SafeProcess that
+# exited or a pseudo-process with $proc->{timeout} == 1
+#
+
+sub wait_any_timeout {
+  my $class= shift;
+  my $timeout= shift;
+  my $proc;
+  my $millis=10;
+
+  do {
+    ::mtr_milli_sleep($millis);
+    # Slowly increse interval up to max. 1 second
+    $millis++ if $millis < 1000;
+    # Return a "fake" process for timeout
+    if (::has_expired($timeout)) {
+      $proc= bless
+	({
+	  SAFE_PID  => 0,
+	  SAFE_NAME => "timer",
+	  timeout => 1,
+	 }, $class);
+    } else {
+      $proc= check_any();
+    }
+  } while (! $proc);
+
+  return $proc;
+}
+
+
+#
 # Wait for all processes to exit
 #
 sub wait_all {
@@ -606,7 +583,7 @@ sub self2str {
 
 sub _verbose {
   return unless $_verbose;
-  print STDERR " ## ", @_, "\n";
+  print STDERR " ## ". @_. "\n";
 }
 
 

=== modified file 'mysql-test/lib/mtr_misc.pl'
--- a/mysql-test/lib/mtr_misc.pl	2009-05-26 18:53:34 +0000
+++ b/mysql-test/lib/mtr_misc.pl	2010-03-16 09:53:53 +0000
@@ -31,7 +31,9 @@ sub mtr_script_exists(@);
 sub mtr_file_exists(@);
 sub mtr_exe_exists(@);
 sub mtr_exe_maybe_exists(@);
-
+sub mtr_milli_sleep($);
+sub start_timer($);
+sub has_expired($);
 
 ##############################################################################
 #
@@ -168,11 +170,18 @@ sub mtr_exe_exists (@) {
 }
 
 
-sub mtr_milli_sleep {
+sub mtr_milli_sleep ($) {
   die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1;
   my ($millis)= @_;
 
   select(undef, undef, undef, ($millis/1000));
 }
 
+# Simple functions to start and check timers (have to be actively polled)
+# Timer can be "killed" by setting it to 0
+
+sub start_timer ($) { return time + $_[0]; }
+
+sub has_expired ($) { return $_[0] && time gt $_[0]; }
+
 1;

=== modified file 'mysql-test/lib/mtr_report.pm'
--- a/mysql-test/lib/mtr_report.pm	2009-12-17 10:14:52 +0000
+++ b/mysql-test/lib/mtr_report.pm	2010-03-16 09:51:40 +0000
@@ -70,7 +70,7 @@ sub _mtr_report_test_name ($) {
   $tname.= " '$tinfo->{combination}'"
     if defined $tinfo->{combination};
 
-  print _name(), _timestamp();
+  print _name(). _timestamp();
   printf "%-40s ", $tname;
   my $worker = $tinfo->{worker};
   printf "w$worker " if $worker;
@@ -404,13 +404,13 @@ sub mtr_report_stats ($;$) {
 ##############################################################################
 
 sub mtr_print_line () {
-  print '-' x 60, "\n";
+  print '-' x 60 . "\n";
 }
 
 
 sub mtr_print_thick_line {
   my $char= shift || '=';
-  print $char x 78, "\n";
+  print $char x 78 . "\n";
 }
 
 
@@ -468,7 +468,7 @@ sub _timestamp {
 
 # Always print message to screen
 sub mtr_print (@) {
-  print _name(), join(" ", @_), "\n";
+  print _name(). join(" ", @_). "\n";
 }
 
 
@@ -476,22 +476,22 @@ sub mtr_print (@) {
 sub mtr_report (@) {
   if (defined $verbose)
   {
-    print _name(), join(" ", @_), "\n";
+    print _name(). join(" ", @_). "\n";
   }
 }
 
 
 # Print warning to screen
 sub mtr_warning (@) {
-  print STDERR _name(), _timestamp(),
-    "mysql-test-run: WARNING: ", join(" ", @_), "\n";
+  print STDERR _name(). _timestamp().
+    "mysql-test-run: WARNING: ". join(" ", @_). "\n";
 }
 
 
 # Print error to screen and then exit
 sub mtr_error (@) {
-  print STDERR _name(), _timestamp(),
-    "mysql-test-run: *** ERROR: ", join(" ", @_), "\n";
+  print STDERR _name(). _timestamp().
+    "mysql-test-run: *** ERROR: ". join(" ", @_). "\n";
   if (IS_WINDOWS)
   {
     POSIX::_exit(1);
@@ -506,8 +506,8 @@ sub mtr_error (@) {
 sub mtr_debug (@) {
   if ( $verbose > 2 )
   {
-    print STDERR _name(),
-      _timestamp(), "####: ", join(" ", @_), "\n";
+    print STDERR _name().
+      _timestamp(). "####: ". join(" ", @_). "\n";
   }
 }
 
@@ -515,8 +515,8 @@ sub mtr_debug (@) {
 sub mtr_verbose (@) {
   if ( $verbose )
   {
-    print STDERR _name(), _timestamp(),
-      "> ",join(" ", @_),"\n";
+    print STDERR _name(). _timestamp().
+      "> ".join(" ", @_)."\n";
   }
 }
 
@@ -526,8 +526,8 @@ sub mtr_verbose_restart (@) {
   my $proc= $server->{proc};
   if ( $verbose_restart )
   {
-    print STDERR _name(),_timestamp(),
-      "> Restart $proc - ",join(" ", @args),"\n";
+    print STDERR _name()._timestamp().
+      "> Restart $proc - ".join(" ", @args)."\n";
   }
 }
 

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-03-12 11:56:09 +0000
+++ b/mysql-test/mysql-test-run.pl	2010-03-16 10:11:28 +0000
@@ -440,7 +440,7 @@ sub run_test_server ($$$) {
   my $result;
   my $exe_mysqld= find_mysqld($basedir) || ""; # Used as hint to CoreDump
 
-  my $suite_timeout_proc= My::SafeProcess->timer(suite_timeout());
+  my $suite_timeout= start_timer(suite_timeout());
 
   my $s= IO::Select->new();
   $s->add($server);
@@ -461,7 +461,6 @@ sub run_test_server ($$$) {
 	  mtr_verbose("Child closed socket");
 	  $s->remove($sock);
 	  if (--$childs == 0){
-	    $suite_timeout_proc->kill();
 	    return $completed;
 	  }
 	  next;
@@ -530,13 +529,11 @@ sub run_test_server ($$$) {
 
 	    if ( !$opt_force ) {
 	      # Test has failed, force is off
-	      $suite_timeout_proc->kill();
 	      push(@$completed, $result);
 	      return $completed;
 	    }
 	    elsif ($opt_max_test_fail > 0 and
 		   $num_failed_test >= $opt_max_test_fail) {
-	      $suite_timeout_proc->kill();
 	      push(@$completed, $result);
 	      mtr_report_stats($completed, 1);
 	      mtr_report("Too many tests($num_failed_test) failed!",
@@ -668,7 +665,7 @@ sub run_test_server ($$$) {
     # ----------------------------------------------------
     # Check if test suite timer expired
     # ----------------------------------------------------
-    if ( ! $suite_timeout_proc->wait_one(0) )
+    if ( has_expired($suite_timeout) )
     {
       mtr_report_stats($completed, 1);
       mtr_report("Test suite timeout! Terminating...");
@@ -3013,11 +3010,11 @@ sub check_testcase($$)
   # Return immediately if no check proceess was started
   return 0 unless ( keys %started );
 
-  my $timeout_proc= My::SafeProcess->timer(check_timeout());
+  my $timeout= start_timer(check_timeout());
 
   while (1){
     my $result;
-    my $proc= My::SafeProcess->wait_any();
+    my $proc= My::SafeProcess->wait_any_timeout($timeout);
     mtr_report("Got $proc");
 
     if ( delete $started{$proc->pid()} ) {
@@ -3041,9 +3038,6 @@ sub check_testcase($$)
 
 	if ( keys(%started) == 0){
 	  # All checks completed
-
-	  $timeout_proc->kill();
-
 	  return 0;
 	}
 	# Wait for next process to exit
@@ -3084,10 +3078,9 @@ test case was executed:\n";
 
       }
     }
-    elsif ( $proc eq $timeout_proc ) {
-      $tinfo->{comment}.= "Timeout $timeout_proc for ".
-	"'check-testcase' expired after ".check_timeout().
-	  " seconds";
+    elsif ( $proc->{timeout} ) {
+      $tinfo->{comment}.= "Timeout for 'check-testcase' expired after "
+	.check_timeout()." seconds";
       $result= 4;
     }
     else {
@@ -3102,8 +3095,6 @@ test case was executed:\n";
     # Kill any check processes still running
     map($_->kill(), values(%started));
 
-    $timeout_proc->kill();
-
     return $result;
   }
 
@@ -3175,11 +3166,11 @@ sub run_on_all($$)
   # Return immediately if no check proceess was started
   return 0 unless ( keys %started );
 
-  my $timeout_proc= My::SafeProcess->timer(check_timeout());
+  my $timeout= start_timer(check_timeout());
 
   while (1){
     my $result;
-    my $proc= My::SafeProcess->wait_any();
+    my $proc= My::SafeProcess->wait_any_timeout($timeout);
     mtr_report("Got $proc");
 
     if ( delete $started{$proc->pid()} ) {
@@ -3198,17 +3189,15 @@ sub run_on_all($$)
 
       if ( keys(%started) == 0){
 	# All completed
-	$timeout_proc->kill();
 	return 0;
       }
 
       # Wait for next process to exit
       next;
     }
-    elsif ( $proc eq $timeout_proc ) {
-      $tinfo->{comment}.= "Timeout $timeout_proc for '$run' ".
-	"expired after ". check_timeout().
-	  " seconds";
+    elsif ($proc->{timeout}) {
+      $tinfo->{comment}.= "Timeout for '$run' expired after "
+	.check_timeout()." seconds";
     }
     else {
       # Unknown process returned, most likley a crash, abort everything
@@ -3220,8 +3209,6 @@ sub run_on_all($$)
     # Kill any check processes still running
     map($_->kill(), values(%started));
 
-    $timeout_proc->kill();
-
     return 1;
   }
   mtr_error("INTERNAL_ERROR: run_on_all");
@@ -3451,7 +3438,7 @@ sub run_testcase ($) {
     }
   }
 
-  my $test_timeout_proc= My::SafeProcess->timer(testcase_timeout());
+  my $test_timeout= start_timer(testcase_timeout());
 
   do_before_run_mysqltest($tinfo);
 
@@ -3459,9 +3446,6 @@ sub run_testcase ($) {
     # Failed to record state of server or server crashed
     report_failure_and_restart($tinfo);
 
-    # Stop the test case timer
-    $test_timeout_proc->kill();
-
     return 1;
   }
 
@@ -3479,20 +3463,20 @@ sub run_testcase ($) {
       if ($proc)
       {
 	mtr_verbose ("Found exited process $proc");
-	# If that was the timeout, cancel waiting
-	if ( $proc eq $test_timeout_proc )
-	{
-	  $keep_waiting_proc = 0;
-	}
       }
       else
       {
 	$proc = $keep_waiting_proc;
+	# Also check if timer has expired, if so cancel waiting
+	if ( has_expired($test_timeout) )
+	{
+	  $keep_waiting_proc = 0;
+	}
       }
     }
-    else
+    if (! $keep_waiting_proc)
     {
-      $proc= My::SafeProcess->wait_any();
+      $proc= My::SafeProcess->wait_any_timeout($test_timeout);
     }
 
     # Will be restored if we need to keep waiting
@@ -3509,9 +3493,6 @@ sub run_testcase ($) {
     # ----------------------------------------------------
     if ($proc eq $test)
     {
-      # Stop the test case timer
-      $test_timeout_proc->kill();
-
       my $res= $test->exit_status();
 
       if ($res == 0 and $opt_warnings and check_warnings($tinfo) )
@@ -3605,7 +3586,7 @@ sub run_testcase ($) {
     # ----------------------------------------------------
     # Stop the test case timer
     # ----------------------------------------------------
-    $test_timeout_proc->kill();
+    $test_timeout= 0;
 
     # ----------------------------------------------------
     # Check if it was a server that died
@@ -3644,7 +3625,7 @@ sub run_testcase ($) {
     # ----------------------------------------------------
     # Check if testcase timer expired
     # ----------------------------------------------------
-    if ( $proc eq $test_timeout_proc )
+    if ( $proc->{timeout} )
     {
       my $log_file_name= $opt_vardir."/log/".$tinfo->{shortname}.".log";
       $tinfo->{comment}=
@@ -3878,11 +3859,11 @@ sub check_warnings ($) {
   # Return immediately if no check proceess was started
   return 0 unless ( keys %started );
 
-  my $timeout_proc= My::SafeProcess->timer(check_timeout());
+  my $timeout= start_timer(check_timeout());
 
   while (1){
     my $result= 0;
-    my $proc= My::SafeProcess->wait_any();
+    my $proc= My::SafeProcess->wait_any_timeout($timeout);
     mtr_report("Got $proc");
 
     if ( delete $started{$proc->pid()} ) {
@@ -3911,9 +3892,6 @@ sub check_warnings ($) {
 
 	if ( keys(%started) == 0){
 	  # All checks completed
-
-	  $timeout_proc->kill();
-
 	  return $result;
 	}
 	# Wait for next process to exit
@@ -3930,10 +3908,9 @@ sub check_warnings ($) {
 	$result= 2;
       }
     }
-    elsif ( $proc eq $timeout_proc ) {
-      $tinfo->{comment}.= "Timeout $timeout_proc for ".
-	"'check warnings' expired after ".check_timeout().
-	  " seconds";
+    elsif ( $proc->{timeout} ) {
+      $tinfo->{comment}.= "Timeout for 'check warnings' expired after "
+	.check_timeout()." seconds";
       $result= 4;
     }
     else {
@@ -3947,8 +3924,6 @@ sub check_warnings ($) {
     # Kill any check processes still running
     map($_->kill(), values(%started));
 
-    $timeout_proc->kill();
-
     return $result;
   }
 

=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_basic.result	2009-12-15 14:44:50 +0000
+++ b/mysql-test/suite/ndb/r/ndb_basic.result	2010-03-23 08:41:15 +0000
@@ -33,6 +33,7 @@ ndb_index_stat_cache_entries	#
 ndb_index_stat_enable	#
 ndb_index_stat_update_freq	#
 ndb_log_binlog_index	#
+ndb_log_empty_epochs	#
 ndb_log_update_as_write	#
 ndb_log_updated_only	#
 ndb_optimization_delay	#

=== modified file 'mysql-test/suite/ndb/r/ndb_cache.result'
--- a/mysql-test/suite/ndb/r/ndb_cache.result	2008-10-21 22:53:32 +0000
+++ b/mysql-test/suite/ndb/r/ndb_cache.result	2010-04-16 08:12:51 +0000
@@ -367,4 +367,15 @@ drop table t1;
 alter tablespace tbsp drop datafile 'mydatafile.fil' engine ndb;
 drop tablespace tbsp engine ndb;
 drop logfile group lfg engine ndb;
+reset query cache;
+flush status;
+pk	a	b	c
+1	2	3	First row
+pk	a	b	c
+1	2	3	First row
+pk	a	b	c
+1	2	3	First row
+show status like "Qcache_hits";
+Variable_name	Value
+Qcache_hits	1
 SET GLOBAL query_cache_size=0;

=== modified file 'mysql-test/suite/ndb/r/ndb_charset.result'
--- a/mysql-test/suite/ndb/r/ndb_charset.result	2007-12-07 10:05:19 +0000
+++ b/mysql-test/suite/ndb/r/ndb_charset.result	2010-04-16 08:12:51 +0000
@@ -318,3 +318,7 @@ select * from t1;
 a
 aaabb
 drop table t1;
+create table t1(a int) engine = ndbcluster;
+create table T1(a int) engine = ndbcluster;
+drop table T1;
+drop table t1;

=== modified file 'mysql-test/suite/ndb/r/ndb_restore_options.result'
--- a/mysql-test/suite/ndb/r/ndb_restore_options.result	2010-01-19 23:33:05 +0000
+++ b/mysql-test/suite/ndb/r/ndb_restore_options.result	2010-04-16 12:42:12 +0000
@@ -76,8 +76,8 @@ Normal full restore
 use db1;
 show tables;
 Tables_in_db1
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -102,8 +102,8 @@ a	b	c	d
 use db2;
 show tables;
 Tables_in_db2
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -135,8 +135,8 @@ Tables_in_db1
 use db2;
 show tables;
 Tables_in_db2
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -165,8 +165,8 @@ Exclude only db2
 use db1;
 show tables;
 Tables_in_db1
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -347,8 +347,8 @@ Tables_in_db1
 use db2;
 show tables;
 Tables_in_db2
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -422,8 +422,8 @@ db2
 use db1;
 show tables;
 Tables_in_db1
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0
@@ -448,8 +448,8 @@ a	b	c	d
 use db2;
 show tables;
 Tables_in_db2
-tab2
 tab1
+tab2
 select * from tab1 order by a;
 a
 0

=== modified file 'mysql-test/suite/ndb/r/ndbinfo.result'
--- a/mysql-test/suite/ndb/r/ndbinfo.result	2010-01-25 10:04:59 +0000
+++ b/mysql-test/suite/ndb/r/ndbinfo.result	2010-03-18 10:21:02 +0000
@@ -14,6 +14,7 @@ CREATE TEMPORARY TABLE `t1` (
 ERROR HY000: Table storage engine 'ndbinfo' does not support the create option 'TEMPORARY'
 
 
+
 USE ndbinfo;
 
 SHOW CREATE TABLE ndb$tables;

=== modified file 'mysql-test/suite/ndb/t/have_ndbinfo.inc'
--- a/mysql-test/suite/ndb/t/have_ndbinfo.inc	2009-11-08 14:17:04 +0000
+++ b/mysql-test/suite/ndb/t/have_ndbinfo.inc	2010-03-18 10:21:02 +0000
@@ -30,7 +30,7 @@ if ($sql_file) {
 }
 else
 {
-  print $F "skip Could not find ndbinfo.sq;\n";
+  print $F "skip Could not find ndbinfo.sql;\n";
 }
 $F->close();
 

=== modified file 'mysql-test/suite/ndb/t/ndb_cache.test'
--- a/mysql-test/suite/ndb/t/ndb_cache.test	2008-10-21 23:03:34 +0000
+++ b/mysql-test/suite/ndb/t/ndb_cache.test	2010-04-16 08:12:51 +0000
@@ -242,6 +242,42 @@ drop logfile group lfg engine ndb;
 
 # end of tests for bug#39395
 
+# bug#33158
+# bug#33158 NDB table name problem(sensitive/insensitive)
+# Check that tables with same letters, but different case
+# don't conflict in query cache
+reset query cache;
+flush status;
+disable_query_log;
+if (`SELECT @@lower_case_table_names = 0`)
+{
+  CREATE TABLE t1 ( pk int not null primary key,
+  a int, b int not null, c varchar(20)) ENGINE=ndbcluster;
+  insert into t1 value (1, 2, 3, 'First row');
+  select * from t1;
+  CREATE TABLE T1 ( pk int not null primary key,
+  a int, b int not null, c varchar(20)) ENGINE=ndbcluster;
+  insert into T1 value (1, 2, 3, 'First row');
+  select * from T1;
+  select * from T1;
+  drop table t1,T1;
+}
+if (`SELECT @@lower_case_table_names <> 0`)
+{
+  CREATE TABLE t1 ( pk int not null primary key,
+  a int, b int not null, c varchar(20)) ENGINE=ndbcluster;
+  insert into t1 value (1, 2, 3, 'First row');
+  select * from t1;
+  CREATE TABLE tt1 ( pk int not null primary key,
+  a int, b int not null, c varchar(20)) ENGINE=ndbcluster;
+  insert into tt1 value (1, 2, 3, 'First row');
+  select * from tt1;
+  select * from tt1;
+  drop table t1,tt1;
+}
+enable_query_log;
+show status like "Qcache_hits";
+
 SET GLOBAL query_cache_size=0;
 
 

=== modified file 'mysql-test/suite/ndb/t/ndb_charset.test'
--- a/mysql-test/suite/ndb/t/ndb_charset.test	2007-11-29 10:29:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_charset.test	2010-04-16 08:12:51 +0000
@@ -253,4 +253,22 @@ replace into t1 set a = 'aaabb';
 select * from t1;
 drop table t1;
 
+# bug#33158 NDB table name problem(sensitive/insensitive)
+# Check that tables with same letters, but different case
+# don't conflict
+create table t1(a int) engine = ndbcluster;
+
+if (`SELECT @@lower_case_table_names = 0`)
+{
+  create table T1(a int) engine = ndbcluster;
+  drop table T1;
+}
+if (`SELECT @@lower_case_table_names <> 0`)
+{
+  --echo create table T1(a int) engine = ndbcluster;
+  --echo drop table T1;
+}
+drop table t1;
+
+
 # End of 4.1 tests

=== modified file 'mysql-test/suite/ndb/t/ndb_config.test'
--- a/mysql-test/suite/ndb/t/ndb_config.test	2009-12-07 13:10:38 +0000
+++ b/mysql-test/suite/ndb/t/ndb_config.test	2010-04-14 09:28:31 +0000
@@ -38,7 +38,7 @@ echo == 12 ==;
 --exec $NDB_CONFIG --no-defaults --query=nodeid --host=1.2.3.4   --config-file=$MYSQL_TEST_DIR/suite/ndb/ndb_config_config.ini 2> /dev/null
 
 echo == 13 ==;
---exec $NDB_CONFIG --no-defaults --query=nodeid --host=127.0.0.1 --config-file=$MYSQL_TEST_DIR/suite/ndb/ndb_config_config.ini 2> /dev/null
+--exec $NDB_CONFIG --no-defaults --query=nodeid --host=localhost --config-file=$MYSQL_TEST_DIR/suite/ndb/ndb_config_config.ini 2> /dev/null
 
 echo == 14 == ndb_config --configinfo;
 --exec $NDB_CONFIG --configinfo > /dev/null

=== modified file 'mysql-test/suite/ndb/t/ndbinfo.test'
--- a/mysql-test/suite/ndb/t/ndbinfo.test	2010-01-25 10:04:59 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo.test	2010-03-18 10:21:02 +0000
@@ -1,6 +1,5 @@
 --result_format 2
 --source include/have_ndb.inc
---source have_ndbinfo.inc
 
 SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS,PLUGIN_TYPE,
        PLUGIN_LIBRARY,PLUGIN_LIBRARY_VERSION,PLUGIN_AUTHOR,PLUGIN_DESCRIPTION
@@ -14,6 +13,9 @@ CREATE TEMPORARY TABLE `t1` (
 
 if (`select @@ndbinfo_version < ((7<<16) | (1 << 8))`)
 {
+  # Check if ndbinfo.sql exists
+  --source have_ndbinfo.inc
+
   # Run the ndbinfo.sql script that creates ndbinfo database, tables and views
   --disable_warnings
   --disable_query_log

=== added file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_empty_epoch.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_empty_epoch.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_empty_epoch.result	2010-03-22 14:17:13 +0000
@@ -0,0 +1,34 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+c1 VARCHAR(30),
+PRIMARY KEY (id)
+) ENGINE=ndb;
+BEGIN;
+INSERT INTO t1 (c1) VALUES ('aaa'),('bbb'),('ccc');
+DELETE FROM t1 WHERE id IN (1,2,3);
+COMMIT;
+SELECT COUNT(epoch) > 0 FROM mysql.ndb_binlog_index;
+COUNT(epoch) > 0
+0
+CREATE TABLE t2 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+c1 VARCHAR(30),
+PRIMARY KEY (id)
+) ENGINE=ndb;
+set @old_ndb_log_empty_epochs = @@global.ndb_log_empty_epochs;
+set global ndb_log_empty_epochs = on;
+BEGIN;
+INSERT INTO t2 (c1) VALUES ('aaa'),('bbb'),('ccc');
+DELETE FROM t2 WHERE id IN (1,2,3);
+COMMIT;
+SELECT COUNT(epoch) > 0 FROM mysql.ndb_binlog_index;
+COUNT(epoch) > 0
+1
+set global ndb_log_empty_epochs = @old_ndb_log_empty_epochs;
+DROP TABLE IF EXISTS t1,t2;

=== added file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_gap_event.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_gap_event.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_gap_event.result	2010-03-24 16:01:31 +0000
@@ -0,0 +1,16 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1(pk int not null primary key, i int) engine = ndb;
+select count(*) from t1;
+count(*)
+1000
+Restarting mysqld
+show binlog events in 'master-bin.000002'  from <start_pos> limit 0,1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Incident	1	<end_pos>	#1 (LOST_EVENTS)
+drop table if exists t1;
+drop table if exists t1;

=== added file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_empty_epoch.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_empty_epoch.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_empty_epoch.test	2010-03-22 14:17:13 +0000
@@ -0,0 +1,43 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_mixed_or_row.inc
+--source include/ndb_master-slave.inc
+
+CREATE TABLE t1 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ c1 VARCHAR(30),
+ PRIMARY KEY (id)
+ ) ENGINE=ndb;
+
+BEGIN;
+ INSERT INTO t1 (c1) VALUES ('aaa'),('bbb'),('ccc');
+ DELETE FROM t1 WHERE id IN (1,2,3);
+COMMIT;
+
+--sleep 2
+
+SELECT COUNT(epoch) > 0 FROM mysql.ndb_binlog_index;
+
+CREATE TABLE t2 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ c1 VARCHAR(30),
+ PRIMARY KEY (id)
+ ) ENGINE=ndb;
+
+set @old_ndb_log_empty_epochs = @@global.ndb_log_empty_epochs;
+set global ndb_log_empty_epochs = on;
+
+BEGIN;
+ INSERT INTO t2 (c1) VALUES ('aaa'),('bbb'),('ccc');
+ DELETE FROM t2 WHERE id IN (1,2,3);
+COMMIT;
+
+--sleep 2
+
+SELECT COUNT(epoch) > 0 FROM mysql.ndb_binlog_index;
+
+set global ndb_log_empty_epochs = @old_ndb_log_empty_epochs;
+
+--connection master
+DROP TABLE IF EXISTS t1,t2;
+
+-- source include/master-slave-end.inc

=== modified file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_extraCol.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_extraCol.test	2007-07-25 13:40:43 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_extraCol.test	2010-03-26 13:38:52 +0000
@@ -8,6 +8,14 @@
 -- source include/have_ndb.inc
 -- source include/ndb_master-slave.inc
 let $engine_type = 'NDB';
--- source extra/rpl_tests/rpl_extraSlave_Col.test
 
+#
+# This is a disgrace...but slave randomly spits out these warnings
+#   results file match...so i'll just supress them
+#
+-- disable_query_log
+call mtr.add_suppression("Slave: Can't find record in 't9' Error_code: 1032");
+call mtr.add_suppression("Slave: Got error 120 during COMMIT Error_code: 1180");
+-- enable_query_log
 
+-- source extra/rpl_tests/rpl_extraSlave_Col.test

=== added file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event-master.opt'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event-master.opt	2010-03-24 16:01:31 +0000
@@ -0,0 +1 @@
+--binlog-ignore-db=mysql
\ No newline at end of file

=== added file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_gap_event.test	2010-03-24 16:01:31 +0000
@@ -0,0 +1,43 @@
+--source include/have_ndb.inc
+--source include/have_binlog_format_mixed_or_row.inc
+--source include/ndb_master-slave.inc
+
+--connection master
+create table t1(pk int not null primary key, i int) engine = ndb;
+
+#
+# insert more records into tables
+#
+let $1=1000;
+disable_query_log;
+while ($1)
+{
+ eval insert into t1 values($1, $1);
+ dec $1;
+}
+enable_query_log;
+
+--sync_slave_with_master
+# connect to slave and ensure data is there.
+--connection slave
+select count(*) from t1;
+
+--connection master
+
+--echo Restarting mysqld
+let $mysqld_name=mysqld.1.1;
+--source include/restart_mysqld.inc
+#show binlog events in 'master-bin.000002';
+let $log_name=master-bin.000002;
+let $start_pos=107;
+let $end_pos=143;
+let $off_set=0;
+-- source include/show_binlog_using_logname.inc
+
+drop table if exists t1;
+
+--connection slave
+drop table if exists t1;
+
+
+

=== modified file 'mysys/CMakeLists.txt'
--- a/mysys/CMakeLists.txt	2010-03-09 09:18:50 +0000
+++ b/mysys/CMakeLists.txt	2010-04-01 15:22:57 +0000
@@ -42,7 +42,7 @@ SET(MYSYS_SOURCES  array.c charset-def.c
 				my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
 				my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
 				rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
-				thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c my_times.c
+				thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c
                                 my_socket.c)
 
 IF(NOT SOURCE_SUBLIBS)

=== modified file 'mysys/Makefile.am'
--- a/mysys/Makefile.am	2010-03-09 09:18:50 +0000
+++ b/mysys/Makefile.am	2010-04-01 15:22:57 +0000
@@ -82,7 +82,7 @@ if NEED_THREAD
 libmysyslt_la_SOURCES +=   mf_keycache.c
 endif
 
-EXTRA_DIST =		CMakeLists.txt my_times.c
+EXTRA_DIST =		CMakeLists.txt
 
 DEFS =			-DDEFAULT_BASEDIR=\"$(prefix)\" \
 			-DMYSQL_DATADIR="\"$(MYSQLDATAdir)\"" \

=== removed file 'mysys/my_times.c'
--- a/mysys/my_times.c	2008-10-07 05:16:48 +0000
+++ b/mysys/my_times.c	1970-01-01 00:00:00 +0000
@@ -1,61 +0,0 @@
-/* Copyright (C) 2008 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-
-/*
- * NOTE: This file only built on Windows
- */
-#include <my_global.h>
-#include <Windows.h>
-#include <my_times.h>
-
-clock_t times(struct tms *buf)
-{
-  BOOL r;
-  FILETIME create, exit, kernel, user;
-  ULARGE_INTEGER ulint;
-  LARGE_INTEGER ticks;
-
-  if(!buf)
-  {
-    errno= EINVAL;
-    return -1;
-  }
-
-  r= GetProcessTimes(GetCurrentProcess(), &create, &exit, &kernel, &user);
-
-  if(r==0)
-  {
-    errno= GetLastError();
-    return -1;
-  }
-
-  ulint.LowPart= kernel.dwLowDateTime;
-  ulint.HighPart= kernel.dwHighDateTime;
-  buf->tms_stime= (clock_t)ulint.QuadPart;
-  buf->tms_cstime= (clock_t)ulint.QuadPart;
-
-  ulint.LowPart= user.dwLowDateTime;
-  ulint.HighPart= user.dwHighDateTime;
-  buf->tms_utime= (clock_t)ulint.QuadPart;
-  buf->tms_cutime= (clock_t)ulint.QuadPart;
-
-  if(QueryPerformanceCounter(&ticks)==0)
-  {
-    errno= GetLastError();
-    return -1;
-  }
-
-  return (clock_t)ticks.QuadPart;
-}

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2010-03-10 07:43:06 +0000
+++ b/sql/ha_ndbcluster.cc	2010-04-16 08:33:26 +0000
@@ -663,7 +663,7 @@ Thd_ndb::Thd_ndb()
   m_error_code= 0;
   query_state&= NDB_QUERY_NORMAL;
   options= 0;
-  (void) hash_init(&open_tables, &my_charset_bin, 5, 0, 0,
+  (void) hash_init(&open_tables, table_alias_charset, 5, 0, 0,
                    (hash_get_key)thd_ndb_share_get_key, 0, 0);
   m_unsent_bytes= 0;
   m_execute_count= 0;
@@ -8906,9 +8906,9 @@ int ndbcluster_table_exists_in_engine(ha
   for (uint i= 0 ; i < list.count ; i++)
   {
     NdbDictionary::Dictionary::List::Element& elmt= list.elements[i];
-    if (my_strcasecmp(system_charset_info, elmt.database, db))
+    if (my_strcasecmp(table_alias_charset, elmt.database, db))
       continue;
-    if (my_strcasecmp(system_charset_info, elmt.name, name))
+    if (my_strcasecmp(table_alias_charset, elmt.name, name))
       continue;
     DBUG_PRINT("info", ("Found table"));
     DBUG_RETURN(HA_ERR_TABLE_EXIST);
@@ -9190,7 +9190,7 @@ int ndbcluster_find_files(handlerton *ht
                         NdbDictionary::Object::UserTable) != 0)
     ERR_RETURN(dict->getNdbError());
 
-  if (hash_init(&ndb_tables, system_charset_info,list.count,0,0,
+  if (hash_init(&ndb_tables, table_alias_charset,list.count,0,0,
                 (hash_get_key)tables_get_key,0,0))
   {
     DBUG_PRINT("error", ("Failed to init HASH ndb_tables"));
@@ -9536,7 +9536,7 @@ static int ndbcluster_init(void *p)
     goto ndbcluster_init_error;
   }
 
-  (void) hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0,
+  (void) hash_init(&ndbcluster_open_tables,table_alias_charset,32,0,0,
                    (hash_get_key) ndbcluster_get_key,0,0);
   /* start the ndb injector thread */
   if (ndbcluster_binlog_start())

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2010-01-27 09:52:54 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2010-03-24 15:28:16 +0000
@@ -1254,7 +1254,11 @@ static int ndbcluster_find_all_databases
     }
     op= trans->getNdbScanOperation(ndbtab);
     if (op == NULL)
-      abort();
+    {
+      ndb_error= trans->getNdbError();
+      goto error;
+    }
+
     op->readTuples(NdbScanOperation::LM_Read,
                    NdbScanOperation::SF_TupScan, 1);
     
@@ -1264,7 +1268,10 @@ static int ndbcluster_find_all_databases
     r|= query_blob_handle->getValue(query, sizeof(query));
 
     if (r)
-      abort();
+    {
+      ndb_error= op->getNdbError();
+      goto error;
+    }
 
     if (trans->execute(NdbTransaction::NoCommit))
     {
@@ -1283,10 +1290,15 @@ static int ndbcluster_find_all_databases
       if (db_len > 0 && name_len == 0)
       {
         /* database found */
+        db[db_len]= 0;
+
+	/* find query */
         Uint64 query_length= 0;
         if (query_blob_handle->getLength(query_length))
-          abort();
-        db[db_len]= 0;
+        {
+          ndb_error= query_blob_handle->getNdbError();
+          goto error;
+        }
         query[query_length]= 0;
         build_table_filename(name, sizeof(name), db, "", "", 0);
         int database_exists= !my_access(name, F_OK);
@@ -1352,10 +1364,20 @@ static int ndbcluster_find_all_databases
     {
       if (retries--)
       {
+        sql_print_warning("NDB: ndbcluster_find_all_databases retry: %u - %s",
+                          ndb_error.code,
+                          ndb_error.message);
         do_retry_sleep(retry_sleep);
         continue; // retry
       }
     }
+    if (!thd->killed)
+    {
+      sql_print_error("NDB: ndbcluster_find_all_databases fail: %u - %s",
+                      ndb_error.code,
+                      ndb_error.message);
+    }
+
     DBUG_RETURN(1); // not temp error or too many retries
   }
 }
@@ -5924,7 +5946,9 @@ restart_cluster_failure:
         }
       }
     }
-    else if (res > 0)
+    else if (res > 0 ||
+             (opt_ndb_log_empty_epochs &&
+              gci > ndb_latest_handled_binlog_epoch))
     {
       DBUG_PRINT("info", ("pollEvents res: %d", res));
       thd->proc_info= "Processing events";
@@ -5968,9 +5992,29 @@ restart_cluster_failure:
       }
       NdbEventOperation *pOp= i_ndb->nextEvent();
       ndb_binlog_index_row _row;
+      ndb_binlog_index_row *rows= &_row;
+      injector::transaction trans;
+      unsigned trans_row_count= 0;
+      if (!pOp)
+      {
+        /*
+          Must be an empty epoch since the condition
+          (opt_ndb_log_empty_epochs &&
+           gci > ndb_latest_handled_binlog_epoch)
+          must be true we write empty epoch into
+          ndb_binlog_index
+        */
+        DBUG_PRINT("info", ("Writing empty epoch for gci %llu", gci));
+        DBUG_PRINT("info", ("Initializing transaction"));
+        inj->new_trans(thd, &trans);
+        rows= &_row;
+        bzero((char*)&_row, sizeof(_row));
+        thd->variables.character_set_client= &my_charset_latin1;
+        goto commit_to_binlog;
+      }
       while (pOp != NULL)
       {
-        ndb_binlog_index_row *rows= &_row;
+        rows= &_row;
 #ifdef RUN_NDB_BINLOG_TIMER
         Timer gci_timer, write_timer;
         int event_count= 0;
@@ -5993,8 +6037,9 @@ restart_cluster_failure:
 
         bzero((char*)&_row, sizeof(_row));
         thd->variables.character_set_client= &my_charset_latin1;
-        injector::transaction trans;
-        unsigned trans_row_count= 0;
+        DBUG_PRINT("info", ("Initializing transaction"));
+        inj->new_trans(thd, &trans);
+        trans_row_count= 0;
         // pass table map before epoch
         {
           Uint32 iter= 0;
@@ -6198,6 +6243,7 @@ restart_cluster_failure:
             }
             break;
           }
+      commit_to_binlog:
           thd->proc_info= "Committing events to binlog";
           injector::transaction::binlog_pos start= trans.start_pos();
           if (int r= trans.commit())

=== modified file 'sql/ha_ndbinfo.cc'
--- a/sql/ha_ndbinfo.cc	2010-01-25 10:04:59 +0000
+++ b/sql/ha_ndbinfo.cc	2010-04-15 12:55:31 +0000
@@ -121,10 +121,12 @@ struct ha_ndbinfo_impl
   const NdbInfo::Table* m_table;
   NdbInfoScanOperation* m_scan_op;
   Vector<const NdbInfoRecAttr *> m_columns;
+  bool m_first_use;
 
   ha_ndbinfo_impl() :
     m_table(NULL),
-    m_scan_op(NULL)
+    m_scan_op(NULL),
+    m_first_use(true)
   {
   }
 };
@@ -362,13 +364,6 @@ int ha_ndbinfo::open(const char *name, i
     }
   }
 
-  if (table->s->fields < ndb_tab->columns())
-  {
-    // There are more columns available in NDB
-    warn_incompatible(ndb_tab, false,
-                      "there are more columns available");
-  }
-
   /* Increase "ref_length" to allow a whole row to be stored in "ref" */
   ref_length = 0;
   for (uint i = 0; i < table->s->fields; i++)
@@ -411,6 +406,25 @@ int ha_ndbinfo::rnd_init(bool scan)
   assert(is_open());
   assert(m_impl.m_scan_op == NULL); // No scan already ongoing
 
+  if (m_impl.m_first_use)
+  {
+    m_impl.m_first_use = false;
+
+    /*
+      Due to different code paths in MySQL Server
+      for prepared statement protocol, some warnings
+      from 'handler::open' are lost and need to be
+      deffered to first use instead
+    */
+    const NdbInfo::Table* ndb_tab = m_impl.m_table;
+    if (table->s->fields < ndb_tab->columns())
+    {
+      // There are more columns available in NDB
+      warn_incompatible(ndb_tab, false,
+                        "there are more columns available");
+    }
+  }
+
   if (!scan)
   {
     // Just an init to read using 'rnd_pos'

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-03-12 10:36:52 +0000
+++ b/sql/log.cc	2010-03-24 16:01:31 +0000
@@ -4277,8 +4277,9 @@ bool MYSQL_BIN_LOG::write(Log_event *eve
       binlog_[wild_]{do|ignore}_table?" (WL#1049)"
     */
     const char *local_db= event_info->get_db();
-    if ((thd && !(thd->options & OPTION_BIN_LOG)) ||
-	(!binlog_filter->db_ok(local_db)))
+    if ((event_info->flags & LOG_EVENT_NO_DB_CHECK_F) == 0 &&
+        ((thd && !(thd->options & OPTION_BIN_LOG)) ||
+         (!binlog_filter->db_ok(local_db))))
     {
       VOID(pthread_mutex_unlock(&LOCK_log));
       DBUG_RETURN(0);

=== modified file 'sql/log_event.h'
--- a/sql/log_event.h	2010-03-12 10:36:52 +0000
+++ b/sql/log_event.h	2010-03-24 16:01:31 +0000
@@ -492,6 +492,13 @@ struct sql_ex_info
 #define LOG_EVENT_RELAY_LOG_F 0x40
 
 /**
+   Events with this flag are not filtered based on the current
+   database and is always written to the binary log regardless of
+   filters.
+ */
+#define LOG_EVENT_NO_DB_CHECK_F 0x80
+
+/**
   @def OPTIONS_WRITTEN_TO_BIN_LOG
 
   OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
@@ -3894,7 +3901,7 @@ class Incident_log_event : public Log_ev
 public:
 #ifndef MYSQL_CLIENT
   Incident_log_event(THD *thd_arg, Incident incident)
-    : Log_event(thd_arg, 0, FALSE), m_incident(incident)
+    : Log_event(thd_arg, LOG_EVENT_NO_DB_CHECK_F, FALSE), m_incident(incident)
   {
     DBUG_ENTER("Incident_log_event::Incident_log_event");
     DBUG_PRINT("enter", ("m_incident: %d", m_incident));
@@ -3904,7 +3911,7 @@ public:
   }
 
   Incident_log_event(THD *thd_arg, Incident incident, LEX_STRING const msg)
-    : Log_event(thd_arg, 0, FALSE), m_incident(incident)
+    : Log_event(thd_arg, LOG_EVENT_NO_DB_CHECK_F, FALSE), m_incident(incident)
   {
     DBUG_ENTER("Incident_log_event::Incident_log_event");
     DBUG_PRINT("enter", ("m_incident: %d", m_incident));

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-03-12 11:56:09 +0000
+++ b/sql/mysqld.cc	2010-04-08 11:17:03 +0000
@@ -1900,6 +1900,12 @@ void unlink_thd(THD *thd)
   DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
   thd->cleanup();
 
+  /*
+    Optimize common path by doing timeconsuming tear down
+    outside of global lock
+  */
+  thd->teardown();
+
   pthread_mutex_lock(&LOCK_connection_count);
   --connection_count;
   pthread_mutex_unlock(&LOCK_connection_count);

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2010-03-12 11:56:09 +0000
+++ b/sql/set_var.cc	2010-03-23 08:41:15 +0000
@@ -75,6 +75,7 @@ extern ulong ndb_report_thresh_binlog_me
 extern my_bool ndb_log_binlog_index;
 extern my_bool opt_ndb_log_update_as_write;
 extern my_bool opt_ndb_log_updated_only;
+extern my_bool opt_ndb_log_empty_epochs;
 #endif
 
 extern CHARSET_INFO *character_set_filesystem;
@@ -723,6 +724,8 @@ static sys_var_bool_ptr
 sys_ndb_log_update_as_write(&vars, "ndb_log_update_as_write", &opt_ndb_log_update_as_write);
 static sys_var_bool_ptr
 sys_ndb_log_updated_only(&vars, "ndb_log_updated_only", &opt_ndb_log_updated_only);
+static sys_var_bool_ptr
+sys_ndb_log_empty_epochs(&vars, "ndb_log_empty_epochs", &opt_ndb_log_empty_epochs);
 static sys_var_thd_bool
 sys_ndb_use_exact_count(&vars, "ndb_use_exact_count", &SV::ndb_use_exact_count);
 static sys_var_thd_bool

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-03-12 10:36:52 +0000
+++ b/sql/sql_class.cc	2010-04-08 11:17:03 +0000
@@ -614,6 +614,7 @@ THD::THD()
 #if defined(ENABLED_DEBUG_SYNC)
    , debug_sync_control(0)
 #endif /* defined(ENABLED_DEBUG_SYNC) */
+   , teardown_done(false)
 {
   ulong tmp;
 
@@ -978,6 +979,18 @@ void THD::cleanup(void)
 }
 
 
+void THD::teardown(void)
+{
+  DBUG_ENTER("THD::teardown");
+  DBUG_ASSERT(cleanup_done);
+
+  ha_close_connection(this);
+
+  teardown_done= true;
+  DBUG_VOID_RETURN;
+}
+
+
 THD::~THD()
 {
   THD_CHECK_SENTRY(this);
@@ -1000,7 +1013,9 @@ THD::~THD()
   if (!cleanup_done)
     cleanup();
 
-  ha_close_connection(this);
+  if (!teardown_done)
+    teardown();
+
   plugin_thdvar_cleanup(this);
 
   DBUG_PRINT("info", ("freeing security context"));

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-03-12 11:56:09 +0000
+++ b/sql/sql_class.h	2010-04-08 11:17:03 +0000
@@ -1929,6 +1929,9 @@ public:
   THD();
   ~THD();
 
+  bool teardown_done;
+  void teardown(void);
+
   void init(void);
   /*
     Initialize memory roots necessary for query processing and (!)

=== modified file 'storage/ndb/include/kernel/AttributeList.hpp'
--- a/storage/ndb/include/kernel/AttributeList.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/AttributeList.hpp	2010-03-26 07:13:06 +0000
@@ -35,6 +35,6 @@ struct Id_array
   Uint32 id[SZ];
 };
 
-typedef Id_array<MAX_ATTRIBUTES_IN_INDEX> AttributeList;
+typedef Id_array<MAX_ATTRIBUTES_IN_INDEX> IndexAttributeList;
 
 #endif

=== modified file 'storage/ndb/include/kernel/NodeBitmask.hpp'
--- a/storage/ndb/include/kernel/NodeBitmask.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/NodeBitmask.hpp	2010-03-16 14:51:53 +0000
@@ -46,8 +46,10 @@
 #define NODE_ARRAY_SIZE(N, B) (((N)*(B)+31) >> 5)
 
 typedef Bitmask<(unsigned int)_NODE_BITMASK_SIZE> NodeBitmask;
+typedef BitmaskPOD<(unsigned int)_NODE_BITMASK_SIZE> NodeBitmaskPOD;
 
 typedef Bitmask<(unsigned int)_NDB_NODE_BITMASK_SIZE> NdbNodeBitmask;
+typedef BitmaskPOD<(unsigned int)_NDB_NODE_BITMASK_SIZE> NdbNodeBitmaskPOD;
 
 #define __NBM_SZ  ((MAX_NODES >> 5) + ((MAX_NODES & 31) != 0))
 #define __NNBM_SZ ((MAX_NDB_NODES >> 5) + ((MAX_NDB_NODES & 31) != 0))

=== modified file 'storage/ndb/include/kernel/NodeState.hpp'
--- a/storage/ndb/include/kernel/NodeState.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/NodeState.hpp	2010-03-21 12:04:34 +0000
@@ -22,8 +22,8 @@
 #include <NdbOut.hpp>
 #include <NodeBitmask.hpp>
 
-class NodeState {
-public:
+struct NodeStatePOD
+{
   enum StartLevel {
     /**
      * SL_NOTHING 
@@ -107,10 +107,6 @@ public:
   /**
    * Constructor(s)
    */
-  NodeState();
-  NodeState(StartLevel);
-  NodeState(StartLevel, bool systemShutdown);
-  NodeState(StartLevel, Uint32 startPhase, StartType);
   void init();
  
   /**
@@ -184,8 +180,17 @@ public:
    * Is in single user mode
    */
   Uint32 getSingleUserApi() const;
+};
+
+class NodeState : public NodeStatePOD
+{
+public:
+  NodeState();
+  NodeState(StartLevel);
+  NodeState(StartLevel, bool systemShutdown);
+  NodeState(StartLevel, Uint32 startPhase, StartType);
 
-  friend NdbOut & operator<<(NdbOut&, const NodeState&); 
+  NodeState& operator=(const NodeStatePOD&);
 };
 
 inline
@@ -195,7 +200,7 @@ NodeState::NodeState(){
 
 inline
 void
-NodeState::init(){
+NodeStatePOD::init(){
   startLevel = SL_CMVMI;
   nodeGroup = 0xFFFFFFFF;
   dynamicId = 0xFFFFFFFF;
@@ -232,49 +237,49 @@ NodeState::NodeState(StartLevel sl, bool
 }
 
 inline
-void NodeState::setDynamicId(Uint32 dynamic){
+void NodeStatePOD::setDynamicId(Uint32 dynamic){
   dynamicId = dynamic;
 }
   
 inline
-void NodeState::setNodeGroup(Uint32 group){
+void NodeStatePOD::setNodeGroup(Uint32 group){
   nodeGroup = group;
 }
 
 inline 
-void NodeState::setSingleUser(Uint32 s) {
+void NodeStatePOD::setSingleUser(Uint32 s) {
   singleUserMode = s;
 }
 
 inline 
-void NodeState::setSingleUserApi(Uint32 n) {
+void NodeStatePOD::setSingleUserApi(Uint32 n) {
   singleUserApi = n;
 }
 inline 
-bool NodeState::getNodeRestartInProgress() const {
+bool NodeStatePOD::getNodeRestartInProgress() const {
   return startLevel == SL_STARTING && 
     (starting.restartType == ST_NODE_RESTART || 
      starting.restartType == ST_INITIAL_NODE_RESTART);
 }
 
 inline 
-bool NodeState::getSingleUserMode() const {
+bool NodeStatePOD::getSingleUserMode() const {

   return singleUserMode;
 }
 
 inline 
-Uint32 NodeState::getSingleUserApi() const {
+Uint32 NodeStatePOD::getSingleUserApi() const {
   return singleUserApi;
 }
 
 inline 
-bool NodeState::getSystemRestartInProgress() const {
+bool NodeStatePOD::getSystemRestartInProgress() const {
   return startLevel == SL_STARTING && starting.restartType == ST_SYSTEM_RESTART;
 }
 
 inline
 NdbOut &
-operator<<(NdbOut& ndbout, const NodeState & state){
+operator<<(NdbOut& ndbout, const NodeStatePOD & state){
   ndbout << "[NodeState: startLevel: ";
   switch(state.startLevel){
   case NodeState::SL_NOTHING:
@@ -325,4 +330,16 @@ operator<<(NdbOut& ndbout, const NodeSta
   return ndbout;
 }
 
+inline
+NodeState&
+NodeState::operator=(const NodeStatePOD& ns)
+{
+  startLevel = ns.startLevel;
+  nodeGroup  = ns.nodeGroup;
+  dynamicId  = ns.dynamicId;
+  singleUserMode = ns.singleUserMode;
+  singleUserApi  = ns.singleUserApi;
+  m_connected_nodes.assign(ns.m_connected_nodes);
+  return * this;
+}
 #endif

=== modified file 'storage/ndb/include/kernel/signaldata/AlterTable.hpp'
--- a/storage/ndb/include/kernel/signaldata/AlterTable.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/include/kernel/signaldata/AlterTable.hpp	2010-04-01 05:20:25 +0000
@@ -304,7 +304,8 @@ struct AlterTableRef {
     UnsupportedChange = 741,
     BackupInProgress = 762,
     IncompatibleVersions = 763,
-    SingleUser = 299
+    SingleUser = 299,
+    TableDefinitionTooBig = 793
   };
 
   Uint32 senderRef;

=== modified file 'storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp'
--- a/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/signaldata/ApiRegSignalData.hpp	2010-03-21 12:04:34 +0000
@@ -92,7 +92,7 @@ private:
   Uint32 apiHeartbeatFrequency;
   Uint32 mysql_version;
   Uint32 minDbVersion;
-  NodeState nodeState;
+  NodeStatePOD nodeState;
 };
 
 #endif

=== modified file 'storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp'
--- a/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp	2009-06-01 15:58:26 +0000
+++ b/storage/ndb/include/kernel/signaldata/ArbitSignalData.hpp	2010-03-16 15:56:18 +0000
@@ -34,7 +34,6 @@ private:
   Uint32 data[2];
 
 public:
-  ArbitTicket() {}
   STATIC_CONST( DataLength = 2 );
   STATIC_CONST( TextLength = DataLength * 8 );  // hex digits
 
@@ -145,9 +144,8 @@ public:
   Uint32 code;                  // result code or other info
   Uint32 node;                  // arbitrator node id
   ArbitTicket ticket;           // ticket
-  NodeBitmask mask;             // set of nodes
+  NodeBitmaskPOD mask;          // set of nodes
 
-  ArbitSignalData() {}
   STATIC_CONST( SignalLength = 3 + ArbitTicket::DataLength + NodeBitmask::Size );
 
   inline bool match(ArbitSignalData& aData) const {

=== modified file 'storage/ndb/include/kernel/signaldata/CreateTable.hpp'
--- a/storage/ndb/include/kernel/signaldata/CreateTable.hpp	2009-08-05 10:48:56 +0000
+++ b/storage/ndb/include/kernel/signaldata/CreateTable.hpp	2010-04-01 05:20:25 +0000
@@ -75,7 +75,8 @@ struct CreateTableRef {
     InvalidTablespaceVersion = 759,
     OutOfStringBuffer = 773,
     NoLoggingTemporaryTable = 778,
-    InvalidHashMap = 790
+    InvalidHashMap = 790,
+    TableDefinitionTooBig = 793
   };
 
   Uint32 senderRef;

=== modified file 'storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp'
--- a/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/include/kernel/signaldata/EventSubscribeReq.hpp	2010-03-16 10:35:47 +0000
@@ -56,7 +56,7 @@ struct EventSubscribeReq {
   
   Uint32 theData[LogLevel::LOGLEVEL_CATEGORIES];
   
-  EventSubscribeReq& operator= (const LogLevel& ll){
+  EventSubscribeReq& assign (const LogLevel& ll){
     noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
     for(size_t i = 0; i<noOfEntries; i++){
       theData[i] = Uint32(i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);

=== modified file 'storage/ndb/include/kernel/signaldata/ListTables.hpp'
--- a/storage/ndb/include/kernel/signaldata/ListTables.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/signaldata/ListTables.hpp	2010-03-21 12:04:34 +0000
@@ -22,54 +22,62 @@
 #include <Bitmask.hpp>
 #include "SignalData.hpp"
 
-class ListTablesData {
-public:
-  Uint32 getTableId() {
+struct ListTablesData
+{
+  Uint32 requestData;
+  Uint32 tableId;
+  Uint32 tableType;
+
+  void init() {
+    requestData = 0;
+  }
+
+  Uint32 getTableId() const {
     return tableId;
   }
+
   void setTableId(Uint32 val) {
     tableId = val;
   }
-  Uint32 getTableType() {
+
+  Uint32 getTableType() const {
     return tableType;
   }
+
   void setTableType(Uint32 val) {
     tableType = val;
   }
-  Uint32 getTableStore() {
+
+  Uint32 getTableStore() const {
     return BitmaskImpl::getField(1, &requestData, 20, 3);
   }
   void setTableStore(Uint32 val) {
     BitmaskImpl::setField(1, &requestData, 20, 3, val);
   }
-  Uint32 getTableTemp() {
+  Uint32 getTableTemp() const {
     return BitmaskImpl::getField(1, &requestData, 23, 1);
   }
   void setTableTemp(Uint32 val) {
     BitmaskImpl::setField(1, &requestData, 23, 1, val);
   }
-  Uint32 getTableState() {
+  Uint32 getTableState() const {
     return BitmaskImpl::getField(1, &requestData, 24, 4);
   }
   void setTableState(Uint32 val) {
     BitmaskImpl::setField(1, &requestData, 24, 4, val);
   }
-  Uint32 getListNames() {
+  Uint32 getListNames() const {
     return BitmaskImpl::getField(1, &requestData, 28, 1);
   }
   void setListNames(Uint32 val) {
     BitmaskImpl::setField(1, &requestData, 28, 1, val);
   }
-  Uint32 getListIndexes() {
+  Uint32 getListIndexes() const {
     return BitmaskImpl::getField(1, &requestData, 29, 1);
   }
   void setListIndexes(Uint32 val) {
     BitmaskImpl::setField(1, &requestData, 29, 1, val);
   }
-public:
-  Uint32 requestData;
-  Uint32 tableId;
-  Uint32 tableType;
 };
 
 /**
@@ -144,52 +152,50 @@ public:
 public:  
   Uint32 senderData;
   Uint32 senderRef;
-  Uint32 requestData;
-  Uint32 tableId;
-  Uint32 tableType;
+  ListTablesData data;
 
-  Uint32 getTableId() {
-    return tableId;
+  void init(){
+    data.init();
+  }
+
+  Uint32 getTableId() const {
+    return data.getTableId();
   }
   void setTableId(Uint32 val) {
-    tableId = val;
+    data.setTableId(val);
   }
   Uint32 getTableType() const {
-    return tableType;
+    return data.getTableType();
   }
   void setTableType(Uint32 val) {
-    tableType = val;
+    data.setTableType(val);
   }
   Uint32 getListNames() const {
-    ListTablesData* ltd = (ListTablesData *) &requestData;
-    return ltd->getListNames();
+    return data.getListNames();
   }
   void setListNames(Uint32 val) {
-    ListTablesData* ltd = (ListTablesData *) &requestData;
-    ltd->setListNames(val);
+    data.setListNames(val);
   }
   Uint32 getListIndexes() const {
-    ListTablesData* ltd = (ListTablesData *) &requestData;
-    return ltd->getListIndexes();
+    return data.getListIndexes();
   }
   void setListIndexes(Uint32 val) {
-    ListTablesData* ltd = (ListTablesData *) &requestData;
-    ltd->setListIndexes(val);
+    data.setListIndexes(val);
   }
 
 
   /* For backwards compatility */
   Uint32 oldGetTableId() {
-    return OldListTablesData::getTableId(requestData);
+    return OldListTablesData::getTableId(data.requestData);
   }
   void oldSetTableId(Uint32 val) {
-    OldListTablesData::setTableId(requestData, val);
+    OldListTablesData::setTableId(data.requestData, val);
   }
   Uint32 oldGetTableType() const {
-    return OldListTablesData::getTableType(requestData);
+    return OldListTablesData::getTableType(data.requestData);
   }
   void oldSetTableType(Uint32 val) {
-    OldListTablesData::setTableType(requestData, val);
+    OldListTablesData::setTableType(data.requestData, val);
   }
 };
 

=== modified file 'storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp'
--- a/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/kernel/signaldata/SetLogLevelOrd.hpp	2010-03-16 10:34:21 +0000
@@ -54,7 +54,7 @@ private:
    */
   void setLogLevel(LogLevel::EventCategory ec, int level = 7);
   
-  SetLogLevelOrd& operator= (const LogLevel& ll){
+  SetLogLevelOrd& assign (const LogLevel& ll){
     noOfEntries = LogLevel::LOGLEVEL_CATEGORIES;
     for(size_t i = 0; i<noOfEntries; i++){
       theData[i] = (i << 16) | ll.getLogLevel((LogLevel::EventCategory)i);
@@ -62,7 +62,7 @@ private:
     return * this;
   }
 
-  SetLogLevelOrd& operator= (const EventSubscribeReq& ll){
+  SetLogLevelOrd& assign (const EventSubscribeReq& ll){
     noOfEntries = ll.noOfEntries;
     for(size_t i = 0; i<noOfEntries; i++){
       theData[i] = ll.theData[i];

=== modified file 'storage/ndb/include/logger/Logger.hpp'
--- a/storage/ndb/include/logger/Logger.hpp	2009-12-07 12:38:38 +0000
+++ b/storage/ndb/include/logger/Logger.hpp	2010-04-07 09:14:43 +0000
@@ -144,6 +144,16 @@ public:
   void removeConsoleHandler();
 
   /**
+   * Create a default handler that logs to the Windows event log
+   * with source component set to source_name
+   *
+   * NOTE! Can only  be created on Windows.
+   *
+   * @return true if successful.
+   */
+  bool createEventLogHandler(const char* source_name);
+
+  /**
    * Create a default handler that logs to a file called logger.log.
    *
    * @return true if successful.

=== modified file 'storage/ndb/include/portlib/NdbTCP.h'
--- a/storage/ndb/include/portlib/NdbTCP.h	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/include/portlib/NdbTCP.h	2010-04-09 12:39:23 +0000
@@ -26,8 +26,6 @@
 #define NDB_SOCKET_TYPE my_socket
 #define _NDB_CLOSE_SOCKET(x) my_socket_close(x)
 
-#define NDB_SOCKLEN_T SOCKET_SIZE_TYPE
-
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -53,13 +51,6 @@ int NDB_CLOSE_SOCKET(my_socket fd);
 
 int Ndb_check_socket_hup(NDB_SOCKET_TYPE sock);
 
-#ifdef NDB_WIN
-#define NONBLOCKERR(E) (E!=SOCKET_EAGAIN && E!=SOCKET_EWOULDBLOCK)
-#else
-#define NONBLOCKERR(E) (E!=EINPROGRESS)
-#endif
-
-
 #ifdef	__cplusplus
 }
 #endif

=== modified file 'storage/ndb/include/util/Bitmask.hpp'
--- a/storage/ndb/include/util/Bitmask.hpp	2009-10-27 12:08:44 +0000
+++ b/storage/ndb/include/util/Bitmask.hpp	2010-03-29 11:44:12 +0000
@@ -125,6 +125,11 @@ public:
   static void bitXORC(unsigned size, Uint32 data[], const Uint32 data2[]);
 
   /**
+   * bitNOT - Bitwise (~x) into first operand.
+   */
+  static void bitNOT(unsigned size, Uint32 data[]);
+
+  /**
    * contains - Check if all bits set in data2 are set in data
    */
   static bool contains(unsigned size, Uint32 data[], const Uint32 data2[]);
@@ -395,6 +400,14 @@ BitmaskImpl::bitXORC(unsigned size, Uint
   }
 }
 
+inline void
+BitmaskImpl::bitNOT(unsigned size, Uint32 data[])
+{
+  for (unsigned i = 0; i < size; i++) {
+    data[i] = ~data[i];
+  }
+}
+
 inline bool
 BitmaskImpl::contains(unsigned size, Uint32 data[], const Uint32 data2[])
 {
@@ -487,6 +500,8 @@ public:
   STATIC_CONST( NotFound = BitmaskImpl::NotFound );
   STATIC_CONST( TextLength = size * 8 );
 
+  Uint32 getSizeInWords() const { return Size;}
+
   /**
    * assign - Set all bits in <em>dst</em> to corresponding in <em>src/<em>
    */
@@ -611,6 +626,12 @@ public:
   BitmaskPOD<size>& bitXORC(const BitmaskPOD<size>& mask2);
 
   /**
+   * bitNOT - Bitwise (~x) in first operand.
+   */
+  static void bitNOT(Uint32 data[]);
+  BitmaskPOD<size>& bitNOT();
+
+  /**
    * contains - Check if all bits set in data2 (that) are also set in data (this)
    */
   static bool contains(Uint32 data[], const Uint32 data2[]);
@@ -904,6 +925,21 @@ BitmaskPOD<size>::bitXORC(const BitmaskP
 }
 
 template <unsigned size>
+inline void
+BitmaskPOD<size>::bitNOT(Uint32 data[])
+{
+  BitmaskImpl::bitNOT(size,data);
+}
+
+template <unsigned size>
+inline BitmaskPOD<size>&
+BitmaskPOD<size>::bitNOT()
+{
+  BitmaskPOD<size>::bitNOT(rep.data);
+  return *this;
+}
+
+template <unsigned size>
 char *
 BitmaskPOD<size>::getText(const Uint32 data[], char* buf)
 {

=== modified file 'storage/ndb/src/common/logger/CMakeLists.txt'
--- a/storage/ndb/src/common/logger/CMakeLists.txt	2008-08-20 13:22:09 +0000
+++ b/storage/ndb/src/common/logger/CMakeLists.txt	2010-04-07 09:14:43 +0000
@@ -21,4 +21,5 @@ ADD_LIBRARY(ndblogger STATIC
             LogHandlerList.cpp
             LogHandler.cpp
             ConsoleLogHandler.cpp
+            EventLogHandler.cpp
             FileLogHandler.cpp)

=== added file 'storage/ndb/src/common/logger/EventLogHandler.cpp'
--- a/storage/ndb/src/common/logger/EventLogHandler.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/common/logger/EventLogHandler.cpp	2010-04-07 09:14:43 +0000
@@ -0,0 +1,276 @@
+/*
+   Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#ifdef _WIN32
+
+#include "EventLogHandler.hpp"
+#include "message.h"
+
+EventLogHandler::EventLogHandler(const char* source_name)
+ : LogHandler(),
+   m_source_name(source_name),
+   m_event_source(NULL),
+   m_level(Logger::LL_ERROR)
+{
+}
+
+
+EventLogHandler::~EventLogHandler()
+{
+  close();
+}
+
+
+static bool
+check_message_resource(void)
+{
+  // Only do check once per binary
+  static bool check_message_resource_done = false; 
+  if (check_message_resource_done)
+    return true;
+  check_message_resource_done = true;
+
+  // Each program that want to log to Windows event log need to
+  // have a message resource compiled in. Check that it's there
+  // by resolving the message from current module(.exe)
+  char* message_text;
+  if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                    FORMAT_MESSAGE_FROM_HMODULE |
+                    FORMAT_MESSAGE_IGNORE_INSERTS,
+                    NULL, MSG_EVENTLOG, NULL,
+                    (LPTSTR)&message_text, 0, NULL) != 0)
+  {
+    LocalFree(message_text);
+    return true;
+  }
+
+  // Could not get message from own module, extract error
+  // message from system and print it to help debugging
+  DWORD last_err = GetLastError();
+  fprintf(stderr,
+          "This program does not seem to have the message resource "
+          "required for logging to Windows event log, error: %u ", last_err);
+  if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+                    FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                    FORMAT_MESSAGE_IGNORE_INSERTS,
+                    NULL, last_err, 0,
+                    (LPSTR)&message_text, 0, NULL))
+  {
+    fprintf(stderr, "message: '%s'\n", message_text);
+    LocalFree(message_text);
+  }
+  else
+  {
+    fprintf(stderr, "message: <unknown>\n");
+  }
+
+  // The program have not been properly compiled, crash in debug mode 
+  assert(false);
+  return false;
+}
+
+
+static bool
+setup_eventlogging(const char* source_name)
+{
+  // Check that this binary have mesage resource compiled in
+  if (!check_message_resource())
+    return false;
+
+  char sub_key[MAX_PATH];
+  BaseString::snprintf(sub_key, sizeof(sub_key),
+    "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\%s",
+    source_name);
+
+  // Create the event source registry key
+  HKEY key_handle;
+  if (RegCreateKey(HKEY_LOCAL_MACHINE, sub_key, &key_handle) != ERROR_SUCCESS)
+  {
+    // Could neither create or open key
+    fprintf(stderr, "Could neither create or open key '%s', error: %u\n",
+            sub_key, GetLastError());
+    return false;
+  }
+
+  /* Get path of current module and use it as message resource  */
+  char module_path[MAX_PATH];
+  DWORD len = GetModuleFileName(NULL, module_path, sizeof(module_path));
+  if (len == 0 || len == sizeof(module_path))
+  {
+    fprintf(stderr,
+            "Could not extract path of module, module_len: %u, error: %u\n",
+            len, GetLastError());
+    RegCloseKey(key_handle);
+    return false;
+  }
+
+  (void)RegSetValueEx(key_handle, "EventMessageFile", 0, REG_EXPAND_SZ,
+                      (PBYTE)module_path, len + 1 );
+
+  /* Register supported event types */
+  const DWORD event_types= (EVENTLOG_ERROR_TYPE |
+                            EVENTLOG_WARNING_TYPE |
+                            EVENTLOG_INFORMATION_TYPE);
+  (void)RegSetValueEx(key_handle, "TypesSupported", 0, REG_DWORD,
+                      (PBYTE)&event_types, sizeof(event_types));
+
+  RegCloseKey(key_handle);
+  return true;
+}
+
+
+bool
+EventLogHandler::open()
+{
+  if (!setup_eventlogging(m_source_name))
+  {
+    fprintf(stderr, "Failed to setup event logging\n");
+    return false;
+  }
+
+  m_event_source = RegisterEventSource(NULL, m_source_name);
+  if (!m_event_source)
+  {
+    fprintf(stderr, "Failed to register event source, error: %u\n",
+            GetLastError());
+    return false;
+  }
+  return true;
+}
+
+
+bool
+EventLogHandler::close()
+{
+  if (!is_open())
+    return true;
+
+  (void)DeregisterEventSource(m_event_source);
+
+  return true;
+}
+
+
+bool
+EventLogHandler::is_open()
+{
+  return (m_event_source != NULL);
+}
+
+void 
+EventLogHandler::writeHeader(const char* pCategory, Logger::LoggerLevel level)
+{
+  m_level = level;
+}
+
+
+static bool
+write_event_log(HANDLE eventlog_handle, Logger::LoggerLevel level,
+                const char* msg)
+{
+  WORD type;
+  switch(level)
+  {
+  case Logger::LL_DEBUG:
+  case Logger::LL_INFO:
+    type = EVENTLOG_INFORMATION_TYPE;
+    break;
+
+  case Logger::LL_WARNING:
+    type = EVENTLOG_WARNING_TYPE;
+    break;
+
+  case Logger::LL_ERROR:
+  case Logger::LL_ALERT:
+  case Logger::LL_CRITICAL:
+    type = EVENTLOG_ERROR_TYPE;
+    break;
+  }
+
+  if (!ReportEvent(eventlog_handle, type, 0, MSG_EVENTLOG,
+                   NULL, 1, 0, &msg, NULL))
+  {
+    return false;
+  }
+
+  return true;
+}
+
+
+void 
+EventLogHandler::writeMessage(const char* msg)
+{
+  if (!is_open())
+    return;
+
+  if (!write_event_log(m_event_source, m_level, msg))
+  {
+    fprintf(stderr, "Failed to report event to event log, error: %u\n",
+            GetLastError());
+  }
+}
+
+
+void 
+EventLogHandler::writeFooter()
+{
+}
+
+  
+bool
+EventLogHandler::setParam(const BaseString &param, const BaseString &value) {
+  return false;
+}
+
+
+int
+EventLogHandler::printf(Logger::LoggerLevel level, const char* source_name,
+                        const char* msg, ...)
+{
+  if (setup_eventlogging(source_name))
+  {
+    // Failed to setup event logging
+    return -3;
+  }
+
+  char buf[MAX_LOG_MESSAGE_SIZE];
+  va_list ap;
+  va_start(ap, msg);
+  int ret = vsnprintf_s(buf, sizeof(buf), _TRUNCATE, msg, ap);
+  va_end(ap);
+
+  HANDLE eventlog_handle = RegisterEventSource(NULL, source_name);
+  if (!eventlog_handle)
+  {
+    // Failed to open event log 
+    return -2;
+  }
+
+  if (!write_event_log(eventlog_handle, level, buf))
+  {
+    // Failed to log, return error
+    (void)DeregisterEventSource(eventlog_handle);
+    return -1;
+  }
+
+  (void)DeregisterEventSource(eventlog_handle);
+
+  // Ok, return length of the logged message
+  return ret;
+}
+
+#endif
\ No newline at end of file

=== added file 'storage/ndb/src/common/logger/EventLogHandler.hpp'
--- a/storage/ndb/src/common/logger/EventLogHandler.hpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/common/logger/EventLogHandler.hpp	2010-04-07 09:14:43 +0000
@@ -0,0 +1,63 @@
+/*
+   Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#ifndef EVENTLOGHANDLER_H
+#define EVENTLOGHANDLER_H
+
+#include "LogHandler.hpp"
+
+/**
+ * Log messages to the Windows event log
+ *
+ * Example:
+ *  // To make everything written to g_eventLogger also
+ *   // end up in Windows event log
+ *  g_eventLogger->createEventLoghandler("MySQL Cluster Management Server");
+ *
+ * // To log a message(normally an error) before g_eventLogger has been created
+ * EventLogHandler::printf(LL_ERROR, "MySQL Cluster Management Server",
+ *                         "Failed to create shutdown event, error: %d", err); 
+ */
+class EventLogHandler : public LogHandler
+{
+public:
+  EventLogHandler(const char* source_name);
+  virtual ~EventLogHandler();
+
+  virtual bool open();
+  virtual bool close();
+  virtual bool is_open();
+
+  virtual bool setParam(const BaseString &param, const BaseString &value);
+
+  // Write message to event log without an open EventLogHandler
+  static int printf(Logger::LoggerLevel m_level, const char* source_name,
+                    const char* msg, ...) ATTRIBUTE_FORMAT(printf, 3, 4);
+private:
+  virtual void writeHeader(const char* pCategory, Logger::LoggerLevel level);
+  virtual void writeMessage(const char* pMsg);
+  virtual void writeFooter();
+
+  EventLogHandler(const EventLogHandler&); // Not impl.
+  EventLogHandler operator = (const EventLogHandler&); // Not impl.
+  bool operator == (const EventLogHandler&); // Not impl.
+
+  const char* m_source_name;
+  HANDLE m_event_source;
+  Logger::LoggerLevel m_level;
+};
+#endif

=== modified file 'storage/ndb/src/common/logger/Logger.cpp'
--- a/storage/ndb/src/common/logger/Logger.cpp	2009-12-07 12:38:38 +0000
+++ b/storage/ndb/src/common/logger/Logger.cpp	2010-04-07 09:14:43 +0000
@@ -25,7 +25,9 @@
 #include <FileLogHandler.hpp>
 #include "LogHandlerList.hpp"
 
-#if !defined NDB_WIN32
+#ifdef _WIN32
+#include "EventLogHandler.hpp"
+#else
 #include <SysLogHandler.hpp>
 #endif
 
@@ -101,6 +103,27 @@ Logger::removeConsoleHandler()
 }
 
 bool
+Logger::createEventLogHandler(const char* source_name)
+{
+#ifdef _WIN32
+  Guard g(m_handler_mutex);
+
+  LogHandler* log_handler = new EventLogHandler(source_name);
+  if (!log_handler)
+    return false;
+
+  if (!addHandler(log_handler))
+  {
+    delete log_handler;
+    return false;
+  }
+  return true;
+#else
+  return false;
+#endif
+}
+
+bool
 Logger::createFileHandler(char*filename)
 {
   Guard g(m_handler_mutex);
@@ -133,15 +156,14 @@ Logger::removeFileHandler()
 bool
 Logger::createSyslogHandler()
 {
+#ifdef _WIN32
+  return false;
+#else
   Guard g(m_handler_mutex);
   bool rc = true;
   if (m_pSyslogHandler == NULL)
   {
-#if defined NDB_WIN32
-    m_pSyslogHandler = new ConsoleLogHandler(); 
-#else
     m_pSyslogHandler = new SysLogHandler(); 
-#endif
     if (!addHandler(m_pSyslogHandler)) // TODO: check error code
     {
       rc = false;
@@ -151,6 +173,7 @@ Logger::createSyslogHandler()
   }
 
   return rc;
+#endif
 }
 
 void 
@@ -204,7 +227,7 @@ Logger::addHandler(const BaseString &log
 
     LogHandler *handler = NULL;
 
-#ifndef NDB_WIN32
+#ifndef _WIN32
     if(type == "SYSLOG")
     {
       handler = new SysLogHandler();

=== added file 'storage/ndb/src/common/logger/MSG00001.bin'
Binary files a/storage/ndb/src/common/logger/MSG00001.bin	1970-01-01 00:00:00 +0000 and b/storage/ndb/src/common/logger/MSG00001.bin	2010-04-07 09:14:43 +0000 differ

=== modified file 'storage/ndb/src/common/logger/Makefile.am'
--- a/storage/ndb/src/common/logger/Makefile.am	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/common/logger/Makefile.am	2010-04-07 09:14:43 +0000
@@ -14,16 +14,16 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
-EXTRA_DIST = CMakeLists.txt
+EXTRA_DIST = CMakeLists.txt \
+  message.mc message.h message.rc MSG00001.bin
 
 noinst_LTLIBRARIES = liblogger.la
 
-SOURCE_WIN = Logger.cpp LogHandlerList.cpp LogHandler.cpp \
-           ConsoleLogHandler.cpp FileLogHandler.cpp
-liblogger_la_SOURCES = $(SOURCE_WIN) SysLogHandler.cpp
+liblogger_la_SOURCES = Logger.cpp \
+  LogHandlerList.cpp LogHandler.cpp \
+  ConsoleLogHandler.cpp FileLogHandler.cpp \
+  SysLogHandler.cpp EventLogHandler.cpp
 
 include $(top_srcdir)/storage/ndb/config/common.mk.am
 include $(top_srcdir)/storage/ndb/config/type_ndbapi.mk.am
 
-# Don't update the files from bitkeeper
-%::SCCS/s.%

=== added file 'storage/ndb/src/common/logger/message.h'
--- a/storage/ndb/src/common/logger/message.h	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/common/logger/message.h	2010-04-07 09:14:43 +0000
@@ -0,0 +1,56 @@
+/*
+  To change or add messages ndbd or ndb_mgmd writes to the Windows
+  error log, run
+   mc.exe message.mc
+  and checkin generated messages.h, messages.rc and msg000001.bin under the 
+  source control.
+  mc.exe can be installed with Windows SDK, some Visual Studio distributions 
+  do not include it.
+*/
+//
+//  Values are 32 bit values laid out as follows:
+//
+//   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
+//   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+//  +---+-+-+-----------------------+-------------------------------+
+//  |Sev|C|R|     Facility          |               Code            |
+//  +---+-+-+-----------------------+-------------------------------+
+//
+//  where
+//
+//      Sev - is the severity code
+//
+//          00 - Success
+//          01 - Informational
+//          10 - Warning
+//          11 - Error
+//
+//      C - is the Customer code flag
+//
+//      R - is a reserved bit
+//
+//      Facility - is the facility code
+//
+//      Code - is the facility's status code
+//
+//
+// Define the facility codes
+//
+
+
+//
+// Define the severity codes
+//
+
+
+//
+// MessageId: MSG_EVENTLOG
+//
+// MessageText:
+//
+// %1.
+// 
+// 
+//
+#define MSG_EVENTLOG                     0xC0000064L
+

=== added file 'storage/ndb/src/common/logger/message.mc'
--- a/storage/ndb/src/common/logger/message.mc	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/common/logger/message.mc	2010-04-07 09:14:43 +0000
@@ -0,0 +1,17 @@
+;/*
+;  To change or add messages ndbd or ndb_mgmd writes to the Windows
+;  error log, run
+;   mc.exe message.mc
+;  and checkin generated messages.h, messages.rc and msg000001.bin under the 
+;  source control.
+;  mc.exe can be installed with Windows SDK, some Visual Studio distributions 
+;  do not include it.
+;*/
+MessageId    = 100
+Severity     = Error
+Facility     = Application
+SymbolicName = MSG_EVENTLOG
+Language     = English
+%1.
+
+

=== added file 'storage/ndb/src/common/logger/message.rc'
--- a/storage/ndb/src/common/logger/message.rc	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/common/logger/message.rc	2010-04-07 09:14:43 +0000
@@ -0,0 +1,2 @@
+LANGUAGE 0x9,0x1
+1 11 "MSG00001.bin"

=== modified file 'storage/ndb/src/common/util/Bitmask.cpp'
--- a/storage/ndb/src/common/util/Bitmask.cpp	2009-07-14 09:19:43 +0000
+++ b/storage/ndb/src/common/util/Bitmask.cpp	2010-03-29 12:31:44 +0000
@@ -218,10 +218,42 @@ TAPTEST(Bitmask)
         "0,1,4,6,8,9,10,12,14,15,16,18,20,21,22,24,25,26,27,28,30,32,"
         "33,34,35,36,38,39,40,42,44,45,46,47,48,49,50,51,52,53,54,55,"
        "56,57,58,59,60");
+
+    // bitNOT Tests
+    Bitmask<8> c = b;
+    OK(c.equal(b));
+    c.bitNOT();
+    printf("getPrettyTextShort(c 1): %s\n",
+           BaseString::getPrettyTextShort(c).c_str());
+    OK(!c.equal(b));
+    c.bitNOT();
+    OK(c.count() == b.count());
+    OK(c.equal(b));
+    printf("getPrettyTextShort(c 2): %s\n",
+           BaseString::getPrettyTextShort(c).c_str());
+
+    Bitmask<1> d;
+    d.set(1);
+    d.set(3);
+    d.set(4);
+    printf("getPrettyTextShort(d 1): %s\n",
+           BaseString::getPrettyTextShort(d).c_str());
+    OK(d.count() == 3);
+    d.bitNOT();
+    printf("getPrettyTextShort(d 2): %s\n",
+           BaseString::getPrettyTextShort(d).c_str());
+    OK(d.get(2));
+    OK(!d.get(4));
+    OK(d.count() != 3);
+    d.bitNOT();
+    OK(d.count() == 3);
+    printf("getPrettyTextShort(d 3): %s\n",
+           BaseString::getPrettyTextShort(d).c_str());
     return 1; // OK
 }
 
 template struct BitmaskPOD<8>;
+template struct BitmaskPOD<1>;
 
 #endif
 

=== modified file 'storage/ndb/src/common/util/SocketClient.cpp'
--- a/storage/ndb/src/common/util/SocketClient.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/common/util/SocketClient.cpp	2010-04-09 12:39:23 +0000
@@ -103,6 +103,12 @@ SocketClient::bind(const char* bindaddre
   return 0;
 }
 
+#ifdef _WIN32
+#define NONBLOCKERR(E) (E!=SOCKET_EAGAIN && E!=SOCKET_EWOULDBLOCK)
+#else
+#define NONBLOCKERR(E) (E!=EINPROGRESS)
+#endif
+
 NDB_SOCKET_TYPE
 SocketClient::connect(const char *toaddress, unsigned short toport)
 {

=== modified file 'storage/ndb/src/common/util/azio.c'
--- a/storage/ndb/src/common/util/azio.c	2010-03-15 21:27:50 +0000
+++ b/storage/ndb/src/common/util/azio.c	2010-03-16 15:56:18 +0000
@@ -363,7 +363,7 @@ int get_byte(s)
  */
 unsigned char* get_block(azio_stream *s,int blksz)
 {
-  char *r= s->stream.next_in;
+  unsigned char *r= s->stream.next_in;
   if (s->stream.avail_in == 0)
     if(read_buffer(s))
       return NULL;

=== modified file 'storage/ndb/src/kernel/blocks/LocalProxy.cpp'
--- a/storage/ndb/src/kernel/blocks/LocalProxy.cpp	2010-01-15 11:10:29 +0000
+++ b/storage/ndb/src/kernel/blocks/LocalProxy.cpp	2010-03-26 11:52:10 +0000
@@ -101,7 +101,10 @@ LocalProxy::sendREQ(Signal* signal, SsSe
 {
   ss.m_worker = 0;
   ndbrequire(ss.m_sendREQ != 0);
-  (this->*ss.m_sendREQ)(signal, ss.m_ssId);
+  SectionHandle handle(this);
+  restoreHandle(handle, ss);
+  (this->*ss.m_sendREQ)(signal, ss.m_ssId, &handle);
+  saveSections(ss, handle);
 }
 
 void
@@ -114,7 +117,8 @@ LocalProxy::recvCONF(Signal* signal, SsS
   if (ss.m_worker < c_workers) {
     jam();
     ndbrequire(ss.m_sendREQ != 0);
-    (this->*ss.m_sendREQ)(signal, ss.m_ssId);
+    SectionHandle handle(this);
+    (this->*ss.m_sendREQ)(signal, ss.m_ssId, &handle);
     return;
   }
 }
@@ -138,6 +142,26 @@ LocalProxy::skipConf(SsSequential& ss)
 {
 }
 
+void
+LocalProxy::saveSections(SsCommon& ss, SectionHandle & handle)
+{
+  ss.m_sec_cnt = handle.m_cnt;
+  for (Uint32 i = 0; i<ss.m_sec_cnt; i++)
+    ss.m_sec_ptr[i] = handle.m_ptr[i].i;
+  handle.clear();
+}
+
+void
+LocalProxy::restoreHandle(SectionHandle & handle, SsCommon& ss)
+{
+  handle.m_cnt = ss.m_sec_cnt;
+  for (Uint32 i = 0; i<ss.m_sec_cnt; i++)
+    handle.m_ptr[i].i = ss.m_sec_ptr[i];
+
+  getSections(handle.m_cnt, handle.m_ptr);
+  ss.m_sec_cnt = 0;
+}
+
 bool
 LocalProxy::firstReply(const SsSequential& ss)
 {
@@ -158,12 +182,15 @@ LocalProxy::sendREQ(Signal* signal, SsPa
   ss.m_workerMask.clear();
   ss.m_worker = 0;
   const Uint32 count = ss.m_extraLast ? c_lqhWorkers : c_workers;
+  SectionHandle handle(this);
+  restoreHandle(handle, ss);
   while (ss.m_worker < count) {
     jam();
     ss.m_workerMask.set(ss.m_worker);
-    (this->*ss.m_sendREQ)(signal, ss.m_ssId);
+    (this->*ss.m_sendREQ)(signal, ss.m_ssId, &handle);
     ss.m_worker++;
   }
+  releaseSections(handle);
 }
 
 void
@@ -230,11 +257,12 @@ LocalProxy::lastReply(const SsParallel& 
 bool
 LocalProxy::lastExtra(Signal* signal, SsParallel& ss)
 {
+  SectionHandle handle(this);
   if (c_lqhWorkers + ss.m_extraSent < c_workers) {
     jam();
     ss.m_worker = c_lqhWorkers + ss.m_extraSent;
     ss.m_workerMask.set(ss.m_worker);
-    (this->*ss.m_sendREQ)(signal, ss.m_ssId);
+    (this->*ss.m_sendREQ)(signal, ss.m_ssId, &handle);
     ss.m_extraSent++;
     return false;
   }
@@ -311,7 +339,8 @@ LocalProxy::backREAD_CONFIG_REQ(Signal* 
 }
 
 void
-LocalProxy::sendREAD_CONFIG_REQ(Signal* signal, Uint32 ssId)
+LocalProxy::sendREAD_CONFIG_REQ(Signal* signal, Uint32 ssId,
+                                SectionHandle* handle)
 {
   Ss_READ_CONFIG_REQ& ss = ssFind<Ss_READ_CONFIG_REQ>(ssId);
 
@@ -319,8 +348,8 @@ LocalProxy::sendREAD_CONFIG_REQ(Signal* 
   req->senderRef = reference();
   req->senderData = ssId;
   req->noOfParameters = 0;
-  sendSignal(workerRef(ss.m_worker), GSN_READ_CONFIG_REQ,
-             signal, ReadConfigReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_READ_CONFIG_REQ,
+                      signal, ReadConfigReq::SignalLength, JBB, handle);
 }
 
 void
@@ -340,6 +369,10 @@ LocalProxy::sendREAD_CONFIG_CONF(Signal*
   if (!lastReply(ss))
     return;
 
+  SectionHandle handle(this);
+  restoreHandle(handle, ss);
+  releaseSections(handle);
+
   ReadConfigConf* conf = (ReadConfigConf*)signal->getDataPtrSend();
   conf->senderRef = reference();
   conf->senderData = ss.m_req.senderData;
@@ -384,13 +417,13 @@ LocalProxy::backSTTOR(Signal* signal)
 }
 
 void
-LocalProxy::sendSTTOR(Signal* signal, Uint32 ssId)
+LocalProxy::sendSTTOR(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_STTOR& ss = ssFind<Ss_STTOR>(ssId);
 
   memcpy(signal->getDataPtrSend(), ss.m_reqdata, ss.m_reqlength << 2);
-  sendSignal(workerRef(ss.m_worker), GSN_STTOR,
-             signal, ss.m_reqlength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_STTOR,
+                      signal, ss.m_reqlength, JBB, handle);
 }
 
 void
@@ -454,15 +487,15 @@ LocalProxy::backNDB_STTOR(Signal* signal
 }
 
 void
-LocalProxy::sendNDB_STTOR(Signal* signal, Uint32 ssId)
+LocalProxy::sendNDB_STTOR(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_NDB_STTOR& ss = ssFind<Ss_NDB_STTOR>(ssId);
 
   NdbSttor* req = (NdbSttor*)signal->getDataPtrSend();
   *req = ss.m_req;
   req->senderRef = reference();
-  sendSignal(workerRef(ss.m_worker), GSN_NDB_STTOR,
-             signal, ss.m_reqlength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_NDB_STTOR,
+                      signal, ss.m_reqlength, JBB, handle);
 }
 
 void
@@ -563,14 +596,14 @@ LocalProxy::execNODE_FAILREP(Signal* sig
 }
 
 void
-LocalProxy::sendNODE_FAILREP(Signal* signal, Uint32 ssId)
+LocalProxy::sendNODE_FAILREP(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_NODE_FAILREP& ss = ssFind<Ss_NODE_FAILREP>(ssId);
 
   NodeFailRep* req = (NodeFailRep*)signal->getDataPtrSend();
   *req = ss.m_req;
-  sendSignal(workerRef(ss.m_worker), GSN_NODE_FAILREP,
-             signal, NodeFailRep::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_NODE_FAILREP,
+                      signal, NodeFailRep::SignalLength, JBB, handle);
 }
 
 void
@@ -638,7 +671,7 @@ LocalProxy::execINCL_NODEREQ(Signal* sig
 }
 
 void
-LocalProxy::sendINCL_NODEREQ(Signal* signal, Uint32 ssId)
+LocalProxy::sendINCL_NODEREQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_INCL_NODEREQ& ss = ssFind<Ss_INCL_NODEREQ>(ssId);
 
@@ -647,8 +680,8 @@ LocalProxy::sendINCL_NODEREQ(Signal* sig
 
   memcpy(req, &ss.m_req, ss.m_reqlength << 2);
   req->senderRef = reference();
-  sendSignal(workerRef(ss.m_worker), GSN_INCL_NODEREQ,
-             signal, ss.m_reqlength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_INCL_NODEREQ,
+                      signal, ss.m_reqlength, JBB, handle);
 }
 
 void
@@ -689,12 +722,13 @@ LocalProxy::execNODE_STATE_REP(Signal* s
 }
 
 void
-LocalProxy::sendNODE_STATE_REP(Signal* signal, Uint32 ssId)
+LocalProxy::sendNODE_STATE_REP(Signal* signal, Uint32 ssId,
+                               SectionHandle* handle)
 {
   Ss_NODE_STATE_REP& ss = ssFind<Ss_NODE_STATE_REP>(ssId);
 
-  sendSignal(workerRef(ss.m_worker), GSN_NODE_STATE_REP,
-             signal,NodeStateRep::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_NODE_STATE_REP,
+                      signal,NodeStateRep::SignalLength, JBB, handle);
 }
 
 // GSN_CHANGE_NODE_STATE_REQ
@@ -711,15 +745,16 @@ LocalProxy::execCHANGE_NODE_STATE_REQ(Si
 }
 
 void
-LocalProxy::sendCHANGE_NODE_STATE_REQ(Signal* signal, Uint32 ssId)
+LocalProxy::sendCHANGE_NODE_STATE_REQ(Signal* signal, Uint32 ssId,
+                                      SectionHandle* handle)
 {
   Ss_CHANGE_NODE_STATE_REQ& ss = ssFind<Ss_CHANGE_NODE_STATE_REQ>(ssId);
 
   ChangeNodeStateReq * req = (ChangeNodeStateReq*)signal->getDataPtrSend();
   req->senderRef = reference();
 
-  sendSignal(workerRef(ss.m_worker), GSN_CHANGE_NODE_STATE_REQ,
-             signal, ChangeNodeStateReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_CHANGE_NODE_STATE_REQ,
+                      signal, ChangeNodeStateReq::SignalLength, JBB, handle);
 }
 
 void
@@ -763,13 +798,14 @@ LocalProxy::execDUMP_STATE_ORD(Signal* s
 }
 
 void
-LocalProxy::sendDUMP_STATE_ORD(Signal* signal, Uint32 ssId)
+LocalProxy::sendDUMP_STATE_ORD(Signal* signal, Uint32 ssId,
+                               SectionHandle* handle)
 {
   Ss_DUMP_STATE_ORD& ss = ssFind<Ss_DUMP_STATE_ORD>(ssId);
 
   memcpy(signal->getDataPtrSend(), ss.m_reqdata, ss.m_reqlength << 2);
-  sendSignal(workerRef(ss.m_worker), GSN_DUMP_STATE_ORD,
-             signal, ss.m_reqlength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_DUMP_STATE_ORD,
+                      signal, ss.m_reqlength, JBB, handle);
 }
 
 // GSN_NDB_TAMPER
@@ -788,13 +824,13 @@ LocalProxy::execNDB_TAMPER(Signal* signa
 }
 
 void
-LocalProxy::sendNDB_TAMPER(Signal* signal, Uint32 ssId)
+LocalProxy::sendNDB_TAMPER(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_NDB_TAMPER& ss = ssFind<Ss_NDB_TAMPER>(ssId);
 
   signal->theData[0] = ss.m_errorInsert;
-  sendSignal(workerRef(ss.m_worker), GSN_NDB_TAMPER,
-             signal, 1, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_NDB_TAMPER,
+                      signal, 1, JBB, handle);
 }
 
 // GSN_TIME_SIGNAL
@@ -811,12 +847,12 @@ LocalProxy::execTIME_SIGNAL(Signal* sign
 }
 
 void
-LocalProxy::sendTIME_SIGNAL(Signal* signal, Uint32 ssId)
+LocalProxy::sendTIME_SIGNAL(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_TIME_SIGNAL& ss = ssFind<Ss_TIME_SIGNAL>(ssId);
   signal->theData[0] = 0;
-  sendSignal(workerRef(ss.m_worker), GSN_TIME_SIGNAL,
-             signal, 1, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_TIME_SIGNAL,
+                      signal, 1, JBB, handle);
 }
 
 // GSN_CREATE_TRIG_IMPL_REQ
@@ -834,7 +870,8 @@ LocalProxy::execCREATE_TRIG_IMPL_REQ(Sig
 }
 
 void
-LocalProxy::sendCREATE_TRIG_IMPL_REQ(Signal* signal, Uint32 ssId)
+LocalProxy::sendCREATE_TRIG_IMPL_REQ(Signal* signal, Uint32 ssId,
+                                     SectionHandle * handle)
 {
   Ss_CREATE_TRIG_IMPL_REQ& ss = ssFind<Ss_CREATE_TRIG_IMPL_REQ>(ssId);
 
@@ -842,8 +879,9 @@ LocalProxy::sendCREATE_TRIG_IMPL_REQ(Sig
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_CREATE_TRIG_IMPL_REQ,
-             signal, CreateTrigImplReq::SignalLengthLocal, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_CREATE_TRIG_IMPL_REQ,
+                      signal, CreateTrigImplReq::SignalLengthLocal, JBB,
+                      handle);
 }
 
 void
@@ -913,7 +951,8 @@ LocalProxy::execDROP_TRIG_IMPL_REQ(Signa
 }
 
 void
-LocalProxy::sendDROP_TRIG_IMPL_REQ(Signal* signal, Uint32 ssId)
+LocalProxy::sendDROP_TRIG_IMPL_REQ(Signal* signal, Uint32 ssId,
+                                   SectionHandle * handle)
 {
   Ss_DROP_TRIG_IMPL_REQ& ss = ssFind<Ss_DROP_TRIG_IMPL_REQ>(ssId);
 
@@ -921,8 +960,8 @@ LocalProxy::sendDROP_TRIG_IMPL_REQ(Signa
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_DROP_TRIG_IMPL_REQ,
-             signal, DropTrigImplReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_DROP_TRIG_IMPL_REQ,
+                      signal, DropTrigImplReq::SignalLength, JBB, handle);
 }
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/LocalProxy.hpp'
--- a/storage/ndb/src/kernel/blocks/LocalProxy.hpp	2009-11-08 12:52:27 +0000
+++ b/storage/ndb/src/kernel/blocks/LocalProxy.hpp	2010-03-26 11:52:10 +0000
@@ -117,14 +117,17 @@ protected:
 
   // support routines and classes ("Ss" = signal state)
 
-  typedef void (LocalProxy::*SsFUNC)(Signal*, Uint32 ssId);
+  typedef void (LocalProxy::*SsFUNCREQ)(Signal*, Uint32 ssId, SectionHandle*);
+  typedef void (LocalProxy::*SsFUNCREP)(Signal*, Uint32 ssId);
 
   struct SsCommon {
     Uint32 m_ssId;      // unique id in SsPool (below)
-    SsFUNC m_sendREQ;   // from proxy to worker
-    SsFUNC m_sendCONF;  // from proxy to caller
+    SsFUNCREQ m_sendREQ;   // from proxy to worker
+    SsFUNCREP m_sendCONF;  // from proxy to caller
     Uint32 m_worker;    // current worker
     Uint32 m_error;
+    Uint32 m_sec_cnt;
+    Uint32 m_sec_ptr[3];
     static const char* name() { return "UNDEF"; }
     SsCommon() {
       m_ssId = 0;
@@ -132,6 +135,7 @@ protected:
       m_sendCONF = 0;
       m_worker = 0;
       m_error = 0;
+      m_sec_cnt = 0;
     }
   };
 
@@ -149,6 +153,9 @@ protected:
   bool firstReply(const SsSequential& ss);
   bool lastReply(const SsSequential& ss);
 
+  void saveSections(SsCommon&ss, SectionHandle&);
+  void restoreHandle(SectionHandle&, SsCommon&);
+
   // run workers in parallel
   struct SsParallel : SsCommon {
     WorkerMask m_workerMask;
@@ -322,7 +329,7 @@ protected:
   void execREAD_CONFIG_REQ(Signal*);
   virtual void callREAD_CONFIG_REQ(Signal*);
   void backREAD_CONFIG_REQ(Signal*);
-  void sendREAD_CONFIG_REQ(Signal*, Uint32 ssId);
+  void sendREAD_CONFIG_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execREAD_CONFIG_CONF(Signal*);
   void sendREAD_CONFIG_CONF(Signal*, Uint32 ssId);
 
@@ -345,7 +352,7 @@ protected:
   void execSTTOR(Signal*);
   virtual void callSTTOR(Signal*);
   void backSTTOR(Signal*);
-  void sendSTTOR(Signal*, Uint32 ssId);
+  void sendSTTOR(Signal*, Uint32 ssId, SectionHandle*);
   void execSTTORRY(Signal*);
   void sendSTTORRY(Signal*, Uint32 ssId);
 
@@ -366,7 +373,7 @@ protected:
   void execNDB_STTOR(Signal*);
   virtual void callNDB_STTOR(Signal*);
   void backNDB_STTOR(Signal*);
-  void sendNDB_STTOR(Signal*, Uint32 ssId);
+  void sendNDB_STTOR(Signal*, Uint32 ssId, SectionHandle*);
   void execNDB_STTORRY(Signal*);
   void sendNDB_STTORRY(Signal*, Uint32 ssId);
 
@@ -403,7 +410,7 @@ protected:
   };
   SsPool<Ss_NODE_FAILREP> c_ss_NODE_FAILREP;
   void execNODE_FAILREP(Signal*);
-  void sendNODE_FAILREP(Signal*, Uint32 ssId);
+  void sendNODE_FAILREP(Signal*, Uint32 ssId, SectionHandle*);
   void execNF_COMPLETEREP(Signal*);
   void sendNF_COMPLETEREP(Signal*, Uint32 ssId);
 
@@ -432,7 +439,7 @@ protected:
   };
   SsPool<Ss_INCL_NODEREQ> c_ss_INCL_NODEREQ;
   void execINCL_NODEREQ(Signal*);
-  void sendINCL_NODEREQ(Signal*, Uint32 ssId);
+  void sendINCL_NODEREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execINCL_NODECONF(Signal*);
   void sendINCL_NODECONF(Signal*, Uint32 ssId);
 
@@ -449,7 +456,7 @@ protected:
   };
   SsPool<Ss_NODE_STATE_REP> c_ss_NODE_STATE_REP;
   void execNODE_STATE_REP(Signal*);
-  void sendNODE_STATE_REP(Signal*, Uint32 ssId);
+  void sendNODE_STATE_REP(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_CHANGE_NODE_STATE_REQ
   struct Ss_CHANGE_NODE_STATE_REQ : SsParallel {
@@ -465,7 +472,7 @@ protected:
   };
   SsPool<Ss_CHANGE_NODE_STATE_REQ> c_ss_CHANGE_NODE_STATE_REQ;
   void execCHANGE_NODE_STATE_REQ(Signal*);
-  void sendCHANGE_NODE_STATE_REQ(Signal*, Uint32 ssId);
+  void sendCHANGE_NODE_STATE_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execCHANGE_NODE_STATE_CONF(Signal*);
   void sendCHANGE_NODE_STATE_CONF(Signal*, Uint32 ssId);
 
@@ -484,7 +491,7 @@ protected:
   };
   SsPool<Ss_DUMP_STATE_ORD> c_ss_DUMP_STATE_ORD;
   void execDUMP_STATE_ORD(Signal*);
-  void sendDUMP_STATE_ORD(Signal*, Uint32 ssId);
+  void sendDUMP_STATE_ORD(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_NDB_TAMPER
   struct Ss_NDB_TAMPER : SsParallel {
@@ -500,7 +507,7 @@ protected:
   };
   SsPool<Ss_NDB_TAMPER> c_ss_NDB_TAMPER;
   void execNDB_TAMPER(Signal*);
-  void sendNDB_TAMPER(Signal*, Uint32 ssId);
+  void sendNDB_TAMPER(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_TIME_SIGNAL
   struct Ss_TIME_SIGNAL : SsParallel {
@@ -515,7 +522,7 @@ protected:
   };
   SsPool<Ss_TIME_SIGNAL> c_ss_TIME_SIGNAL;
   void execTIME_SIGNAL(Signal*);
-  void sendTIME_SIGNAL(Signal*, Uint32 ssId);
+  void sendTIME_SIGNAL(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_CREATE_TRIG_IMPL_REQ
   struct Ss_CREATE_TRIG_IMPL_REQ : SsParallel {
@@ -531,7 +538,7 @@ protected:
   };
   SsPool<Ss_CREATE_TRIG_IMPL_REQ> c_ss_CREATE_TRIG_IMPL_REQ;
   void execCREATE_TRIG_IMPL_REQ(Signal*);
-  void sendCREATE_TRIG_IMPL_REQ(Signal*, Uint32 ssId);
+  void sendCREATE_TRIG_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execCREATE_TRIG_IMPL_CONF(Signal*);
   void execCREATE_TRIG_IMPL_REF(Signal*);
   void sendCREATE_TRIG_IMPL_CONF(Signal*, Uint32 ssId);
@@ -550,7 +557,7 @@ protected:
   };
   SsPool<Ss_DROP_TRIG_IMPL_REQ> c_ss_DROP_TRIG_IMPL_REQ;
   void execDROP_TRIG_IMPL_REQ(Signal*);
-  void sendDROP_TRIG_IMPL_REQ(Signal*, Uint32 ssId);
+  void sendDROP_TRIG_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execDROP_TRIG_IMPL_CONF(Signal*);
   void execDROP_TRIG_IMPL_REF(Signal*);
   void sendDROP_TRIG_IMPL_CONF(Signal*, Uint32 ssId);

=== modified file 'storage/ndb/src/kernel/blocks/PgmanProxy.cpp'
--- a/storage/ndb/src/kernel/blocks/PgmanProxy.cpp	2008-11-16 15:31:55 +0000
+++ b/storage/ndb/src/kernel/blocks/PgmanProxy.cpp	2010-03-26 11:52:10 +0000
@@ -55,13 +55,13 @@ PgmanProxy::execLCP_FRAG_ORD(Signal* sig
 }
 
 void
-PgmanProxy::sendLCP_FRAG_ORD(Signal* signal, Uint32 ssId)
+PgmanProxy::sendLCP_FRAG_ORD(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_LCP_FRAG_ORD& ss = ssFind<Ss_LCP_FRAG_ORD>(ssId);
   LcpFragOrd* req = (LcpFragOrd*)signal->getDataPtrSend();
   *req = ss.m_req;
-  sendSignal(workerRef(ss.m_worker), GSN_LCP_FRAG_ORD,
-             signal, LcpFragOrd::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_LCP_FRAG_ORD,
+                      signal, LcpFragOrd::SignalLength, JBB, handle);
 }
 
 // GSN_END_LCP_REQ
@@ -105,7 +105,7 @@ PgmanProxy::execRELEASE_PAGES_CONF(Signa
 }
 
 void
-PgmanProxy::sendEND_LCP_REQ(Signal* signal, Uint32 ssId)
+PgmanProxy::sendEND_LCP_REQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_END_LCP_REQ& ss = ssFind<Ss_END_LCP_REQ>(ssId);
 
@@ -113,8 +113,8 @@ PgmanProxy::sendEND_LCP_REQ(Signal* sign
   *req = ss.m_req;
   req->senderData = ssId;
   req->senderRef = reference();
-  sendSignal(workerRef(ss.m_worker), GSN_END_LCP_REQ,
-             signal, EndLcpReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_END_LCP_REQ,
+                      signal, EndLcpReq::SignalLength, JBB, handle);
 }
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/PgmanProxy.hpp'
--- a/storage/ndb/src/kernel/blocks/PgmanProxy.hpp	2008-11-16 15:31:55 +0000
+++ b/storage/ndb/src/kernel/blocks/PgmanProxy.hpp	2010-03-26 11:52:10 +0000
@@ -39,8 +39,8 @@ protected:
     static const char* name() { return "LCP_FRAG_ORD"; }
     LcpFragOrd m_req;
     Ss_LCP_FRAG_ORD() {
-      m_sendREQ = (SsFUNC)&PgmanProxy::sendLCP_FRAG_ORD;
-      m_sendCONF = (SsFUNC)0;
+      m_sendREQ = (SsFUNCREQ)&PgmanProxy::sendLCP_FRAG_ORD;
+      m_sendCONF = (SsFUNCREP)0;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_LCP_FRAG_ORD>& pool(LocalProxy* proxy) {
@@ -52,7 +52,7 @@ protected:
     return SsIdBase | (req->lcpId & 0xFFFF);
   }
   void execLCP_FRAG_ORD(Signal*);
-  void sendLCP_FRAG_ORD(Signal*, Uint32 ssId);
+  void sendLCP_FRAG_ORD(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_END_LCP_REQ
   struct Ss_END_LCP_REQ : SsParallel {
@@ -63,8 +63,8 @@ protected:
     static const char* name() { return "END_LCP_REQ"; }
     EndLcpReq m_req;
     Ss_END_LCP_REQ() {
-      m_sendREQ = (SsFUNC)&PgmanProxy::sendEND_LCP_REQ;
-      m_sendCONF = (SsFUNC)&PgmanProxy::sendEND_LCP_CONF;
+      m_sendREQ = (SsFUNCREQ)&PgmanProxy::sendEND_LCP_REQ;
+      m_sendCONF = (SsFUNCREP)&PgmanProxy::sendEND_LCP_CONF;
       // extra worker (for extent pages) must run after others
       m_extraLast = true;
     }
@@ -84,7 +84,7 @@ protected:
     return conf->senderData;
   }
   void execEND_LCP_REQ(Signal*);
-  void sendEND_LCP_REQ(Signal*, Uint32 ssId);
+  void sendEND_LCP_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execEND_LCP_CONF(Signal*);
   void sendEND_LCP_CONF(Signal*, Uint32 ssId);
   void execRELEASE_PAGES_CONF(Signal*);

=== modified file 'storage/ndb/src/kernel/blocks/backup/Backup.cpp'
--- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2010-03-11 19:47:09 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2010-03-21 19:05:55 +0000
@@ -3145,11 +3145,11 @@ Backup::backupAllData(Signal* signal, Ba
    * Get all tables from dict
    */
   ListTablesReq * req = (ListTablesReq*)signal->getDataPtrSend();
+  req->init();
   req->senderRef = reference();
   req->senderData = ptr.i;
-  req->requestData = 0;
-  req->tableId = 0;
-  req->tableType = 0;
+  req->setTableId(0);
+  req->setTableType(0);
   sendSignal(DBDICT_REF, GSN_LIST_TABLES_REQ, signal, 
 	     ListTablesReq::SignalLength, JBB);
 }

=== modified file 'storage/ndb/src/kernel/blocks/backup/read.cpp'
--- a/storage/ndb/src/kernel/blocks/backup/read.cpp	2010-03-15 20:44:25 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/read.cpp	2010-03-16 14:51:53 +0000
@@ -340,6 +340,7 @@ static union {
   BackupFormat::CtlFile::TableList TableList;
   BackupFormat::CtlFile::GCPEntry GcpEntry;
   BackupFormat::CtlFile::TableDescription TableDescription;
+  BackupFormat::LogFile::LogEntry LogEntry;
 } theData;
 
 Int32

=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-03-16 08:54:58 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2010-04-08 16:40:38 +0000
@@ -1215,13 +1215,13 @@ Dbdict::writeTableFile(Signal* signal, U
     c_writeTableRecord.m_callback = * callback;
 
     c_writeTableRecord.pageId = 0;
-    ndbrequire(pages == 1);
 
     PageRecordPtr pageRecPtr;
     c_pageRecordArray.getPtr(pageRecPtr, c_writeTableRecord.pageId);
 
     Uint32* dst = &pageRecPtr.p->word[ZPAGE_HEADER_SIZE];
-    Uint32 dstSize = ZSIZE_OF_PAGES_IN_WORDS - ZPAGE_HEADER_SIZE;
+    Uint32 dstSize = (ZMAX_PAGES_OF_TABLE_DEFINITION * ZSIZE_OF_PAGES_IN_WORDS)
+      - ZPAGE_HEADER_SIZE;
     bool ok = copyOut(tabInfoSec, dst, dstSize);
     ndbrequire(ok);
 
@@ -5797,6 +5797,17 @@ Dbdict::createTable_parse(Signal* signal
     }
   }
 
+  {
+    SegmentedSectionPtr ptr;
+    handle.getSection(ptr, CreateTabReq::DICT_TAB_INFO);
+    if (ptr.sz > MAX_WORDS_META_FILE)
+    {
+      jam();
+      setError(error, CreateTableRef::TableDefinitionTooBig, __LINE__);
+      return;
+    }
+  }
+
   // save sections to DICT memory
   saveOpSection(op_ptr, handle, CreateTabReq::DICT_TAB_INFO);
   if (op_ptr.p->m_restart == 0)
@@ -8010,6 +8021,17 @@ Dbdict::alterTable_parse(Signal* signal,
    }
 
 
+  {
+    SegmentedSectionPtr ptr;
+    handle.getSection(ptr, AlterTabReq::DICT_TAB_INFO);
+    if (ptr.sz > MAX_WORDS_META_FILE)
+    {
+      jam();
+      setError(error, AlterTableRef::TableDefinitionTooBig, __LINE__);
+      return;
+    }
+  }
+
   // save sections
   saveOpSection(op_ptr, handle, AlterTabReq::DICT_TAB_INFO);
   if (AlterTableReq::getAddFragFlag(impl_req->changeMask))
@@ -10376,7 +10398,7 @@ Dbdict::createIndex_parse(Signal* signal
   CreateIndxImplReq* impl_req = &createIndexPtr.p->m_request;
 
   // save attribute list
-  AttributeList& attrList = createIndexPtr.p->m_attrList;
+  IndexAttributeList& attrList = createIndexPtr.p->m_attrList;
   {
     SegmentedSectionPtr ss_ptr;
     handle.getSection(ss_ptr, CreateIndxReq::ATTRIBUTE_LIST_SECTION);
@@ -10680,7 +10702,7 @@ Dbdict::createIndex_toCreateTable(Signal
 
   // write index key attributes
 
-  //const AttributeList& attrList = createIndexPtr.p->m_attrList;
+  //const IndexAttributeList& attrList = createIndexPtr.p->m_attrList;
   const AttributeMap& attrMap = createIndexPtr.p->m_attrMap;
   Uint32 k;
   for (k = 0; k < createIndexPtr.p->m_attrList.sz; k++) {
@@ -15597,7 +15619,7 @@ Dbdict::execDROP_EVNT_REQ(Signal* signal
     ref->setMasterNode(c_masterNodeId);
     sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
 	       DropEvntRef::SignalLength2, JBB);
-    return;
+    DBUG_VOID_RETURN;
   }
 
   // Seize a Create Event record
@@ -17662,7 +17684,7 @@ Dbdict::getIndexAttr(TableRecordPtr inde
 }
 
 void
-Dbdict::getIndexAttrList(TableRecordPtr indexPtr, AttributeList& list)
+Dbdict::getIndexAttrList(TableRecordPtr indexPtr, IndexAttributeList& list)
 {
   jam();
   list.sz = 0;
@@ -22455,18 +22477,31 @@ Dbdict::findOpInfo(Uint32 gsn)
 bool
 Dbdict::copyIn(OpSection& op_sec, const SegmentedSectionPtr& ss_ptr)
 {
-  const Uint32 size = ZSIZE_OF_PAGES_IN_WORDS;
+  const Uint32 size = 1024;
   Uint32 buf[size];
 
-  if (size < ss_ptr.sz) {
+  SegmentedSectionPtr tmp = ss_ptr;
+  SectionReader reader(tmp, getSectionSegmentPool());
+  Uint32 len = ss_ptr.sz;
+  while (len > size)
+  {
     jam();
-    return false;
+    ndbrequire(reader.getWords(buf, size));
+    if (!copyIn(op_sec, buf, size))
+    {
+      jam();
+      return false;
+    }
+    len -= size;
   }
-  ::copy(buf, ss_ptr);
-  if (!copyIn(op_sec, buf, ss_ptr.sz)) {
+
+  ndbrequire(reader.getWords(buf, len));
+  if (!copyIn(op_sec, buf, len))
+  {
     jam();
     return false;
   }
+
   return true;
 }
 
@@ -22482,24 +22517,67 @@ Dbdict::copyIn(OpSection& op_sec, const 
 }
 
 bool
+Dbdict::copyOut(Dbdict::OpSectionBuffer & buffer,
+                Dbdict::OpSectionBufferConstIterator & iter,
+                Uint32 * dst,
+                Uint32 len)
+{
+  Uint32 n = 0;
+  for(; !iter.isNull() && n < len; buffer.next(iter))
+  {
+    dst[n] = *iter.data;
+    n++;
+  }
+
+  return n == len;
+}
+
+bool

 Dbdict::copyOut(const OpSection& op_sec, SegmentedSectionPtr& ss_ptr)
 {
-  const Uint32 size = ZSIZE_OF_PAGES_IN_WORDS;
+  const Uint32 size = 1024;
   Uint32 buf[size];
 
-  if (!copyOut(op_sec, buf, size)) {
+  Uint32 len = op_sec.getSize();
+  OpSectionBufferHead tmp_head = op_sec.m_head;
+  OpSectionBuffer buffer(c_opSectionBufferPool, tmp_head);
+
+  OpSectionBufferConstIterator iter;
+  buffer.first(iter);
+  Uint32 ptrI = RNIL;
+  while (len > size)
+  {
+    if (!copyOut(buffer, iter, buf, size))
+    {
+      jam();
+      goto fail;
+    }
+    if (!appendToSection(ptrI, buf, size))
+    {
+      jam();
+      goto fail;
+    }
+    len -= size;
+  }
+
+  if (!copyOut(buffer, iter, buf, len))
+  {
     jam();
-    return false;
+    goto fail;
   }
-  Ptr<SectionSegment> ptr;
-  if (!import(ptr, buf, op_sec.getSize())) {
+
+  if (!appendToSection(ptrI, buf, len))
+  {
     jam();
-    return false;
+    goto fail;
   }
-  ss_ptr.i = ptr.i;
-  ss_ptr.p = ptr.p;
-  ss_ptr.sz = op_sec.getSize();
+
+  getSection(ss_ptr, ptrI);
   return true;
+
+fail:
+  releaseSection(ptrI);
+  return false;
 }
 
 bool
@@ -23015,7 +23093,7 @@ Dbdict::execSCHEMA_TRANS_BEGIN_REQ(Signa
     {
       jam();
       setError(error, SchemaTransBeginRef::IncompatibleVersions, __LINE__);
-      return;
+      break;
     }
 
     if (!seizeSchemaTrans(trans_ptr)) {

=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2010-02-09 05:24:15 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2010-04-01 05:20:25 +0000
@@ -123,9 +123,15 @@
 #define ZFS_CONNECT_SIZE 4
 #define ZSIZE_OF_PAGES_IN_WORDS 8192
 #define ZLOG_SIZE_OF_PAGES_IN_WORDS 13
-#define ZMAX_PAGES_OF_TABLE_DEFINITION 8
-#define ZNUMBER_OF_PAGES (ZMAX_PAGES_OF_TABLE_DEFINITION + 1)
-#define ZNO_OF_FRAGRECORD 5
+#define ZMAX_PAGES_OF_TABLE_DEFINITION \
+  ((ZPAGE_HEADER_SIZE + MAX_WORDS_META_FILE + ZSIZE_OF_PAGES_IN_WORDS - 1) / \
+   ZSIZE_OF_PAGES_IN_WORDS)
+
+/**
+ * - one for retreive
+ * - one for read or write
+ */
+#define ZNUMBER_OF_PAGES (2 * ZMAX_PAGES_OF_TABLE_DEFINITION)
 
 /*--------------------------------------------------------------*/
 // Error codes
@@ -1401,6 +1407,8 @@ private:
   bool copyIn(OpSection&, const Uint32* src, Uint32 srcSize);
   bool copyOut(const OpSection&, SegmentedSectionPtr&);
   bool copyOut(const OpSection&, Uint32* dst, Uint32 dstSize);
+  bool copyOut(OpSectionBuffer & buffer, OpSectionBufferConstIterator & iter,
+               Uint32 * dst, Uint32 len);
   void release(OpSection&);
 
   // SchemaOp
@@ -2450,7 +2458,7 @@ private:
   struct CreateIndexRec : public OpRec {
     CreateIndxImplReq m_request;
     char m_indexName[MAX_TAB_NAME_SIZE];
-    AttributeList m_attrList;
+    IndexAttributeList m_attrList;
     AttributeMask m_attrMask;
     AttributeMap m_attrMap;
     Uint32 m_bits;
@@ -2579,7 +2587,7 @@ private:
 
   struct AlterIndexRec : public OpRec {
     AlterIndxImplReq m_request;
-    AttributeList m_attrList;
+    IndexAttributeList m_attrList;
     AttributeMask m_attrMask;
 
     // reflection
@@ -2673,7 +2681,7 @@ private:
 
     BuildIndxImplReq m_request;
 
-    AttributeList m_indexKeyList;
+    IndexAttributeList m_indexKeyList;
     FragAttributeList m_tableKeyList;
     AttributeMask m_attrMask;
 
@@ -3685,7 +3693,7 @@ private:
   void getTableKeyList(TableRecordPtr, 
 		       Id_array<MAX_ATTRIBUTES_IN_INDEX+1>& list);
   void getIndexAttr(TableRecordPtr indexPtr, Uint32 itAttr, Uint32* id);
-  void getIndexAttrList(TableRecordPtr indexPtr, AttributeList& list);
+  void getIndexAttrList(TableRecordPtr indexPtr, IndexAttributeList& list);
   void getIndexAttrMask(TableRecordPtr indexPtr, AttributeMask& mask);
 
   /* ------------------------------------------------------------ */

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2010-02-26 11:17:58 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2010-03-22 12:38:39 +0000
@@ -278,13 +278,21 @@ void Dbdih::sendSTART_RECREQ(Signal* sig
     c_START_RECREQ_Counter.clearWaitingFor(nodeId);
     return;
   }
-  
+
+  Uint32 keepGCI = SYSFILE->keepGCI;
+  Uint32 lastCompletedGCI = SYSFILE->lastCompletedGCI[nodeId];
+  if (keepGCI > lastCompletedGCI)
+  {
+    jam();
+    keepGCI = lastCompletedGCI;
+  }
+
   StartRecReq * const req = (StartRecReq*)&signal->theData[0];
   BlockReference ref = calcLqhBlockRef(nodeId);
   req->receivingNodeId = nodeId;
   req->senderRef = reference();
-  req->keepGci = SYSFILE->keepGCI;
-  req->lastCompletedGci = SYSFILE->lastCompletedGCI[nodeId];
+  req->keepGci = keepGCI;
+  req->lastCompletedGci = lastCompletedGCI;
   req->newestGci = SYSFILE->newestRestorableGCI;
   req->senderData = extra;
   m_sr_nodes.copyto(NdbNodeBitmask::Size, req->sr_nodes);
@@ -292,8 +300,8 @@ void Dbdih::sendSTART_RECREQ(Signal* sig
 
   signal->theData[0] = NDB_LE_StartREDOLog;
   signal->theData[1] = nodeId;
-  signal->theData[2] = SYSFILE->keepGCI;
-  signal->theData[3] = SYSFILE->lastCompletedGCI[nodeId];
+  signal->theData[2] = keepGCI;
+  signal->theData[3] = lastCompletedGCI;
   signal->theData[4] = SYSFILE->newestRestorableGCI;
   sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 5, JBB);
 }//Dbdih::sendSTART_RECREQ()
@@ -3336,6 +3344,13 @@ void Dbdih::execEND_TOREQ(Signal* signal
       nodePtr.p->copyCompleted = 2;
       takeOverPtr.p->toMasterStatus = TakeOverRecord::TO_WAIT_LCP;
 
+      /**
+       * Make sure that node also participatened in 1 GCP
+       *   before running it's first LCP, so that GCI variables
+       *   in LQH are set properly
+       */
+      c_lcpState.lcpStopGcp = c_newest_restorable_gci;
+
       check_force_lcp(takeOverPtr);
       return;
     }
@@ -3496,6 +3511,7 @@ void Dbdih::startTakeOver(Signal* signal
 
   TakeOverRecordPtr takeOverPtr;
   ndbrequire(c_activeTakeOverList.seize(takeOverPtr));
+  takeOverPtr.p->startGci = SYSFILE->lastCompletedGCI[startNode];
   takeOverPtr.p->restorableGci = SYSFILE->lastCompletedGCI[startNode];
   takeOverPtr.p->toStartingNode = startNode;
   takeOverPtr.p->toFailedNode = nodeTakenOver;
@@ -3701,17 +3717,43 @@ done:
     BlockReference ref = numberToRef(DBLQH, takeOverPtr.p->toStartingNode);
     sendSignal(ref, GSN_START_FRAGREQ, signal, 
 	       StartFragReq::SignalLength, JBB);
+
+    if (replicaPtr.p->maxGciCompleted[maxLcpIndex] < takeOverPtr.p->startGci)
+    {
+      jam();
+      takeOverPtr.p->startGci = replicaPtr.p->maxGciCompleted[maxLcpIndex];
+    }
   }
 }
 
 void
 Dbdih::nr_run_redo(Signal* signal, TakeOverRecordPtr takeOverPtr)
 {
+  /**
+   * sendSTART_RECREQ uses m_sr_nodes
+   *   and for TO during SR, we don't want to modify it
+   *   so save/restore it
+   */
+  NdbNodeBitmask save = m_sr_nodes;
+  m_sr_nodes.clear();
   m_sr_nodes.set(takeOverPtr.p->toStartingNode);
+
+  Uint32 save_keepGCI = SYSFILE->keepGCI;
+  if (takeOverPtr.p->startGci < SYSFILE->keepGCI)
+  {
+    jam();
+    SYSFILE->keepGCI = takeOverPtr.p->startGci;
+    ndbout_c("GSN_START_RECREQ keepGci: %u (%u)",
+             takeOverPtr.p->startGci, save_keepGCI);
+  }
+
   takeOverPtr.p->toCurrentTabref = 0;
   takeOverPtr.p->toCurrentFragid = 0;
   takeOverPtr.p->toSlaveStatus = TakeOverRecord::TO_RUN_REDO;
   sendSTART_RECREQ(signal, takeOverPtr.p->toStartingNode, takeOverPtr.i);
+
+  m_sr_nodes = save; // restore
+  SYSFILE->keepGCI = save_keepGCI;
 }
 
 void
@@ -11545,6 +11587,16 @@ void Dbdih::execSTART_RECCONF(Signal* si
     nodePtr.p->copyCompleted = 0;
   }
 
+  if (m_to_nodes.get(getOwnNodeId()))
+  {
+    /**
+     * We (master) needs take-over
+     *   run this directly to avoid strange confusion
+     */
+    jam();
+    c_sr_wait_to = true;
+  }
+
   if (!m_to_nodes.isclear() && c_sr_wait_to)
   {
     jam();
@@ -12994,13 +13046,20 @@ Dbdih::sendLCP_FRAG_ORD(Signal* signal, 
               info.tableId);
     replicaPtr.p->nextLcp = 0;
   }
+
+  Uint32 keepGci = c_lcpState.keepGci;
+  if (keepGci > SYSFILE->lastCompletedGCI[replicaPtr.p->procNode])
+  {
+    jam();
+    keepGci = SYSFILE->lastCompletedGCI[replicaPtr.p->procNode];
+  }
   
   LcpFragOrd * const lcpFragOrd = (LcpFragOrd *)&signal->theData[0];
   lcpFragOrd->tableId    = info.tableId;
   lcpFragOrd->fragmentId = info.fragId;
   lcpFragOrd->lcpId      = SYSFILE->latestLCP_ID;
   lcpFragOrd->lcpNo      = replicaPtr.p->nextLcp;
-  lcpFragOrd->keepGci    = c_lcpState.keepGci;
+  lcpFragOrd->keepGci    = keepGci;
   lcpFragOrd->lastFragmentFlag = false;
   sendSignal(ref, GSN_LCP_FRAG_ORD, signal, LcpFragOrd::SignalLength, JBB);
 }

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2010-03-05 06:29:37 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2010-03-25 14:41:35 +0000
@@ -2441,7 +2441,7 @@ private:
   void srPhase3Start(Signal* signal);
   void checkStartCompletedLab(Signal* signal);
   void continueAbortLab(Signal* signal);
-  void abortContinueAfterBlockedLab(Signal* signal, bool canBlock);
+  void abortContinueAfterBlockedLab(Signal* signal);
   void abortCommonLab(Signal* signal);
   void localCommitLab(Signal* signal);
   void abortErrorLab(Signal* signal);
@@ -3168,6 +3168,7 @@ public:
 #endif
 
   Uint32 get_node_status(Uint32 nodeId) const;
+  bool check_ndb_versions() const;
 };
 
 inline

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2010-03-05 06:34:36 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2010-03-25 14:41:35 +0000
@@ -193,7 +193,7 @@ static int TRACENR_FLAG = 0;
 static NdbOut * traceopout = 0;
 #define TRACE_OP(regTcPtr, place) do { if (TRACE_OP_CHECK(regTcPtr)) TRACE_OP_DUMP(regTcPtr, place); } while(0)
 #else
-#define TRACE_OP(x, y) {}
+#define TRACE_OP(x, y) { (void)x;}
 #endif
 
 struct LogPosition
@@ -2931,6 +2931,7 @@ void Dblqh::execLQHKEYREF(Signal* signal
 {
   jamEntry();
   tcConnectptr.i = signal->theData[0];
+  Uint32 tcOprec  = signal->theData[1];
   terrorCode = signal->theData[2];
   Uint32 transid1 = signal->theData[3];
   Uint32 transid2 = signal->theData[4];
@@ -2938,20 +2939,38 @@ void Dblqh::execLQHKEYREF(Signal* signal
     errorReport(signal, 3);
     return;
   }//if
-/*------------------------------------------------------------------*/
-/*       WE HAVE TO CHECK THAT THE SIGNAL DO NOT BELONG TO SOMETHING*/
-/*       REMOVED DUE TO A TIME-OUT.                                 */
-/*------------------------------------------------------------------*/
+
   ptrAss(tcConnectptr, tcConnectionrec);
   TcConnectionrec * const regTcPtr = tcConnectptr.p;
+
+  if (likely(! ((regTcPtr->connectState == TcConnectionrec::LOG_CONNECTED) ||
+                (regTcPtr->connectState == TcConnectionrec::COPY_CONNECTED))))
+  {
+    /**
+     * This...is unpleasant...
+     *   LOG_CONNECTED and COPY_CONNECTED will not release there tcConnectptr
+     *   before all outstanding is finished.
+     *
+     *   CONNECTED on the other hand can, (in ::execABORT)
+     *     which means that findTransaction *should* be used
+     *     to make sure that correct tcConnectptr is accessed.
+     *
+     *   However, as LOG_CONNECTED & COPY_CONNECTED only uses 1 tcConnectptr
+     *     (and fiddles) with transid and other stuff, I could
+     *     not find an easy way to modify the code so that findTransaction
+     *     is usable also for them
+     */
+    if (findTransaction(transid1, transid2, tcOprec) != ZOK)
+    {
+      jam();
+      warningReport(signal, 14);
+      return;
+    }
+  }
+
   switch (regTcPtr->connectState) {
   case TcConnectionrec::CONNECTED:
     jam();
-    if ((regTcPtr->transid[0] != transid1) ||
-        (regTcPtr->transid[1] != transid2)) {
-      warningReport(signal, 14);
-      return;
-    }//if
     if (regTcPtr->abortState != TcConnectionrec::ABORT_IDLE) {
       warningReport(signal, 15);
       return;
@@ -3342,6 +3361,7 @@ void Dblqh::execTUPKEYREF(Signal* signal
 /* ------------------------------------------------------------------------- */
     break;
   default:
+    jamLine(tcConnectptr.p->transactionState);

     ndbrequire(false);
     break;
   }//switch
@@ -7327,7 +7347,7 @@ void Dblqh::execLQHKEYCONF(Signal* signa
     return;
     break;
   default:
-    jam();
+    jamLine(tcConnectptr.p->connectState);
     ndbrequire(false);
     break;
   }//switch
@@ -8169,15 +8189,7 @@ void Dblqh::abortStateHandlerLab(Signal*
     return;
   case TcConnectionrec::WAIT_ACC:
     jam();
-/* ------------------------------------------------------------------------- */
-// We start the abort immediately since the operation is still in the active
-// list and the fragment cannot have been frozen yet. By sending LCP_HOLDOPCONF
-// as direct signals we avoid the problem that we might find the operation
-// in an unexpected list in ACC.
-// We cannot accept being blocked before aborting ACC here since that would
-// lead to seriously complex issues.
-/* ------------------------------------------------------------------------- */
-    abortContinueAfterBlockedLab(signal, false);
+    abortContinueAfterBlockedLab(signal);
     return;
     break;
   case TcConnectionrec::LOG_QUEUED:
@@ -8332,7 +8344,7 @@ void Dblqh::abortCommonLab(Signal* signa
     case Fragrecord::CRASH_RECOVERING:
     case Fragrecord::ACTIVE_CREATION:
       jam();
-      abortContinueAfterBlockedLab(signal, true);
+      abortContinueAfterBlockedLab(signal);
       return;
       break;
     case Fragrecord::BLOCKED:
@@ -8357,7 +8369,7 @@ void Dblqh::abortCommonLab(Signal* signa
   }//if
 }//Dblqh::abortCommonLab()
 
-void Dblqh::abortContinueAfterBlockedLab(Signal* signal, bool canBlock) 
+void Dblqh::abortContinueAfterBlockedLab(Signal* signal) 
 {
   /* ------------------------------------------------------------------------
    *       INPUT:          TC_CONNECTPTR           ACTIVE OPERATION RECORD
@@ -8372,10 +8384,24 @@ void Dblqh::abortContinueAfterBlockedLab
   TcConnectionrec * const regTcPtr = tcConnectptr.p;
   
   TRACE_OP(regTcPtr, "ACC ABORT");
-  
+  Uint32 canBlock = 2; // 2, block if needed
+  switch(regTcPtr->transactionState){
+  case TcConnectionrec::WAIT_TUP:
+    jam();
+    /**
+     * This is when getting from execTUPKEYREF
+     *   in which case we *do* have ACC lock
+     *   and should not (need to) block
+     */
+    canBlock = 0;
+    break;
+  default:
+    break;
+  }
+
   regTcPtr->transactionState = TcConnectionrec::WAIT_ACC_ABORT;
   signal->theData[0] = regTcPtr->accConnectrec;
-  signal->theData[1] = 2; // JOB BUFFER IF NEEDED
+  signal->theData[1] = canBlock;
   EXECUTE_DIRECT(DBACC, GSN_ACC_ABORTREQ, signal, 2);
 
   if (signal->theData[1] == RNIL)
@@ -12752,6 +12778,25 @@ void Dblqh::execLCP_FRAG_ORD(Signal* sig
 
     lcpPtr.p->firstFragmentFlag= true;
     
+#ifdef ERROR_INSERT
+    if (check_ndb_versions())
+    {
+      /**
+       * Only (so-far) in error insert
+       *   check that keepGci (tail of REDO) is smaller than of head of REDO
+       *
+       */
+      if (! ((cnewestCompletedGci >= lcpFragOrd->keepGci) &&
+             (cnewestGci >= lcpFragOrd->keepGci)))
+      {
+        ndbout_c("lcpFragOrd->keepGci: %u cnewestCompletedGci: %u cnewestGci: %u",
+                 lcpFragOrd->keepGci, cnewestCompletedGci, cnewestGci);
+      }
+      ndbrequire(cnewestCompletedGci >= lcpFragOrd->keepGci);
+      ndbrequire(cnewestGci >= lcpFragOrd->keepGci);
+    }
+#endif
+
     c_lcpId = lcpFragOrd->lcpId;
     ndbrequire(lcpPtr.p->lcpState == LcpRecord::LCP_IDLE);
     setLogTail(signal, lcpFragOrd->keepGci);
@@ -15880,7 +15925,14 @@ void Dblqh::execSTART_FRAGREQ(Signal* si
   Uint32 noOfLogNodes = startFragReq->noOfLogNodes;
   Uint32 lcpId = startFragReq->lcpId;
 
-  if (noOfLogNodes > 1)
+  bool doprint = false;
+#ifdef ERROR_INSERT
+  /**
+   * Always printSTART_FRAG_REQ (for debugging) if ERROR_INSERT is set
+   */
+  doprint = true;
+#endif
+  if (doprint || noOfLogNodes > 1)
   {
     printSTART_FRAG_REQ(stdout, signal->getDataPtr(), signal->getLength(),
                         number());
@@ -16083,6 +16135,11 @@ void Dblqh::execSTART_RECREQ(Signal* sig
   cnewestGci = req->newestGci;
   cstartRecReqData = req->senderData;
 
+  if (check_ndb_versions())
+  {
+    ndbrequire(crestartOldestGci <= crestartNewestGci);
+  }
+
   ndbrequire(req->receivingNodeId == cownNodeid);
 
   cnewestCompletedGci = cnewestGci;
@@ -17393,6 +17450,14 @@ crash:
 		       crash_msg ? crash_msg : "",
 		       logPartPtr.p->logLastGci);
   
+  ndbout_c("%s", buf);
+  ndbout_c("logPartPtr.p->logExecState: %u", logPartPtr.p->logExecState);
+  ndbout_c("crestartOldestGci: %u", crestartOldestGci);
+  ndbout_c("crestartNewestGci: %u", crestartNewestGci);
+  ndbout_c("csrPhasesCompleted: %u", csrPhasesCompleted);
+  ndbout_c("logPartPtr.p->logStartGci: %u", logPartPtr.p->logStartGci);
+  ndbout_c("logPartPtr.p->logLastGci: %u", logPartPtr.p->logLastGci);
+  
   progError(__LINE__, NDBD_EXIT_SR_REDOLOG, buf);  
 }//Dblqh::execSr()
 
@@ -18125,8 +18190,20 @@ void Dblqh::readSrFourthPhaseLab(Signal*
    *  INITIALISE LOG LAP TO BE THE LOG LAP AS FOUND IN THE HEAD PAGE.
    *  WE HAVE TO CALCULATE THE NUMBER OF REMAINING WORDS IN THIS MBYTE.
    * ----------------------------------------------------------------------- */
-  cnewestGci = crestartNewestGci;
-  cnewestCompletedGci = crestartNewestGci;
+  Uint32 gci = crestartNewestGci;
+  if (crestartOldestGci > gci)
+  {
+    jam();
+    /**
+     * If "keepGci" is bigger than latest-completed-gci
+     *   move cnewest/cnewestCompletedGci forward
+     */
+    ndbout_c("readSrFourthPhaseLab: gci %u => %u",
+             gci, crestartOldestGci);
+    gci = crestartOldestGci;
+  }
+  cnewestGci = gci;
+  cnewestCompletedGci = gci;
   logPartPtr.p->logPartNewestCompletedGCI = cnewestCompletedGci;
   logPartPtr.p->currentLogfile = logFilePtr.i;
   logFilePtr.p->filePosition = logPartPtr.p->headPageNo;
@@ -22598,3 +22675,21 @@ Dblqh::release(Signal* signal, RedoOpenF
 }
 
 #endif
+
+bool
+Dblqh::check_ndb_versions() const
+{
+  Uint32 version = getNodeInfo(getOwnNodeId()).m_version;
+  for (Uint32 i = 0; i < cnoOfNodes; i++) 
+  {
+    Uint32 node = cnodeData[i];
+    if (cnodeStatus[i] == ZNODE_UP)
+    {
+      if(getNodeInfo(node).m_version != version)
+      {
+        return false;
+      }
+    }
+  }
+  return true;
+}

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.cpp	2010-03-02 15:37:59 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.cpp	2010-03-26 11:52:10 +0000
@@ -167,7 +167,8 @@ DblqhProxy::execCREATE_TAB_REQ(Signal* s
 }
 
 void
-DblqhProxy::sendCREATE_TAB_REQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendCREATE_TAB_REQ(Signal* signal, Uint32 ssId,
+                               SectionHandle* handle)
 {
   Ss_CREATE_TAB_REQ& ss = ssFind<Ss_CREATE_TAB_REQ>(ssId);
 
@@ -175,8 +176,8 @@ DblqhProxy::sendCREATE_TAB_REQ(Signal* s
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_CREATE_TAB_REQ,
-             signal, CreateTabReq::SignalLengthLDM, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_CREATE_TAB_REQ,
+                      signal, CreateTabReq::SignalLengthLDM, JBB, handle);
 }
 
 void
@@ -272,7 +273,7 @@ DblqhProxy::execLQHADDATTREQ(Signal* sig
 }
 
 void
-DblqhProxy::sendLQHADDATTREQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendLQHADDATTREQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_LQHADDATTREQ& ss = ssFind<Ss_LQHADDATTREQ>(ssId);
   Ss_CREATE_TAB_REQ& ss_main = ssFind<Ss_CREATE_TAB_REQ>(ssId);
@@ -284,8 +285,8 @@ DblqhProxy::sendLQHADDATTREQ(Signal* sig
   req->noOfAttributes = ss.m_req.noOfAttributes;
   req->senderData = ssId;
   req->senderAttrPtr = ss.m_req.senderAttrPtr;
-  sendSignal(workerRef(ss.m_worker), GSN_LQHADDATTREQ,
-             signal, reqlength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_LQHADDATTREQ,
+                      signal, reqlength, JBB, handle);
 }
 
 void
@@ -375,7 +376,8 @@ DblqhProxy::execTAB_COMMITREQ(Signal* si
 }
 
 void
-DblqhProxy::sendTAB_COMMITREQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendTAB_COMMITREQ(Signal* signal, Uint32 ssId,
+                              SectionHandle* handle)
 {
   Ss_TAB_COMMITREQ& ss = ssFind<Ss_TAB_COMMITREQ>(ssId);
 
@@ -383,8 +385,8 @@ DblqhProxy::sendTAB_COMMITREQ(Signal* si
   req->senderRef = reference();
   req->senderData = ssId;
   req->tableId = ss.m_req.tableId;
-  sendSignal(workerRef(ss.m_worker), GSN_TAB_COMMITREQ,
-             signal, TabCommitReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_TAB_COMMITREQ,
+                      signal, TabCommitReq::SignalLength, JBB, handle);
 }
 
 void
@@ -822,7 +824,7 @@ DblqhProxy::execGCP_SAVEREQ(Signal* sign
 }
 
 void
-DblqhProxy::sendGCP_SAVEREQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendGCP_SAVEREQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_GCP_SAVEREQ& ss = ssFind<Ss_GCP_SAVEREQ>(ssId);
 
@@ -831,8 +833,8 @@ DblqhProxy::sendGCP_SAVEREQ(Signal* sign
 
   req->dihBlockRef = reference();
   req->dihPtr = ss.m_worker;
-  sendSignal(workerRef(ss.m_worker), GSN_GCP_SAVEREQ,
-             signal, GCPSaveReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_GCP_SAVEREQ,
+                      signal, GCPSaveReq::SignalLength, JBB, handle);
 }
 
 void
@@ -914,7 +916,8 @@ DblqhProxy::execPREP_DROP_TAB_REQ(Signal
 }
 
 void
-DblqhProxy::sendPREP_DROP_TAB_REQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendPREP_DROP_TAB_REQ(Signal* signal, Uint32 ssId,
+                                  SectionHandle * handle)
 {
   Ss_PREP_DROP_TAB_REQ& ss = ssFind<Ss_PREP_DROP_TAB_REQ>(ssId);
 
@@ -922,8 +925,8 @@ DblqhProxy::sendPREP_DROP_TAB_REQ(Signal
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId; // redundant since tableId is used
-  sendSignal(workerRef(ss.m_worker), GSN_PREP_DROP_TAB_REQ,
-             signal, PrepDropTabReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_PREP_DROP_TAB_REQ,
+                      signal, PrepDropTabReq::SignalLength, JBB, handle);
 }
 
 void
@@ -993,7 +996,7 @@ DblqhProxy::execDROP_TAB_REQ(Signal* sig
 }
 
 void
-DblqhProxy::sendDROP_TAB_REQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendDROP_TAB_REQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_DROP_TAB_REQ& ss = ssFind<Ss_DROP_TAB_REQ>(ssId);
 
@@ -1001,8 +1004,8 @@ DblqhProxy::sendDROP_TAB_REQ(Signal* sig
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId; // redundant since tableId is used
-  sendSignal(workerRef(ss.m_worker), GSN_DROP_TAB_REQ,
-             signal, DropTabReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_DROP_TAB_REQ,
+                      signal, DropTabReq::SignalLength, JBB, handle);
 }
 
 void
@@ -1065,29 +1068,27 @@ DblqhProxy::sendDROP_TAB_CONF(Signal* si
 void
 DblqhProxy::execALTER_TAB_REQ(Signal* signal)
 {
+  jamEntry();
+  if (!assembleFragments(signal))
+  {
+    jam();
+    return;
+  }
   const AlterTabReq* req = (const AlterTabReq*)signal->getDataPtr();
   Uint32 ssId = getSsId(req);
   Ss_ALTER_TAB_REQ& ss = ssSeize<Ss_ALTER_TAB_REQ>(ssId);
   ss.m_req = *req;
   ndbrequire(signal->getLength() == AlterTabReq::SignalLength);
 
-  {
-    SectionHandle handle(this, signal);
-    ss.m_sections = handle.m_cnt;
-    ndbrequire(ss.m_sections <= 1);
-    if (ss.m_sections >= 1) {
-      ss.m_sz0 = handle.m_ptr[0].p->m_sz;
-      ndbrequire(ss.m_sz0 <= ss.MaxSection0);
-      ::copy(ss.m_section0, handle.m_ptr[0]);
-    }
-    releaseSections(handle);
-  }
+  SectionHandle handle(this, signal);
+  saveSections(ss, handle);
 
   sendREQ(signal, ss);
 }
 
 void
-DblqhProxy::sendALTER_TAB_REQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendALTER_TAB_REQ(Signal* signal, Uint32 ssId,
+                              SectionHandle* handle)
 {
   Ss_ALTER_TAB_REQ& ss = ssFind<Ss_ALTER_TAB_REQ>(ssId);
 
@@ -1095,18 +1096,8 @@ DblqhProxy::sendALTER_TAB_REQ(Signal* si
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  if (ss.m_sections == 0) {
-    jam();
-    sendSignal(workerRef(ss.m_worker), GSN_ALTER_TAB_REQ,
-               signal, AlterTabReq::SignalLength, JBB);
-  } else {
-    jam();
-    LinearSectionPtr ptr[3];
-    ptr[0].sz = ss.m_sz0;
-    ptr[0].p = ss.m_section0;
-    sendSignal(workerRef(ss.m_worker), GSN_ALTER_TAB_REQ,
-               signal, AlterTabReq::SignalLength, JBB, ptr, 1);
-  }
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_ALTER_TAB_REQ,
+                      signal, AlterTabReq::SignalLength, JBB, handle);
 }
 
 void
@@ -1202,7 +1193,7 @@ DblqhProxy::execSTART_RECREQ(Signal* sig
 }
 
 void
-DblqhProxy::sendSTART_RECREQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendSTART_RECREQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_START_RECREQ& ss = ssFind<Ss_START_RECREQ>(ssId);
 
@@ -1211,8 +1202,8 @@ DblqhProxy::sendSTART_RECREQ(Signal* sig
 
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_START_RECREQ,
-             signal, StartRecReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_START_RECREQ,
+                      signal, StartRecReq::SignalLength, JBB, handle);
 }
 
 void
@@ -1311,8 +1302,8 @@ DblqhProxy::sendSTART_RECREQ_2(Signal* s
       (Ss_START_RECREQ_2::Req*)signal->getDataPtrSend();
     *req = ss.m_req;
     BlockReference ref = numberToRef(req->proxyBlockNo, getOwnNodeId());
-    sendSignal(ref, GSN_START_RECREQ,
-               signal, Ss_START_RECREQ_2::Req::SignalLength, JBB);
+    sendSignal(ref, GSN_START_RECREQ, signal,
+               Ss_START_RECREQ_2::Req::SignalLength, JBB);
   }
 }
 
@@ -1332,15 +1323,16 @@ DblqhProxy::execSTART_RECCONF_2(Signal* 
 }
 
 void
-DblqhProxy::sendSTART_RECCONF_2(Signal* signal, Uint32 ssId)
+DblqhProxy::sendSTART_RECCONF_2(Signal* signal, Uint32 ssId,
+                                SectionHandle* handle)
 {
   Ss_START_RECREQ_2& ss = ssFind<Ss_START_RECREQ_2>(ssId);
 
   Ss_START_RECREQ_2::Conf* conf =
     (Ss_START_RECREQ_2::Conf*)signal->getDataPtrSend();
   *conf = ss.m_conf;
-  sendSignal(workerRef(ss.m_worker), GSN_START_RECCONF,
-             signal, Ss_START_RECREQ_2::Conf::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_START_RECCONF, signal,
+                      Ss_START_RECREQ_2::Conf::SignalLength, JBB, handle);
 }
 
 // GSN_LQH_TRANSREQ
@@ -1379,7 +1371,7 @@ DblqhProxy::execLQH_TRANSREQ(Signal* sig
 }
 
 void
-DblqhProxy::sendLQH_TRANSREQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendLQH_TRANSREQ(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_LQH_TRANSREQ& ss = ssFind<Ss_LQH_TRANSREQ>(ssId);
 
@@ -1388,8 +1380,8 @@ DblqhProxy::sendLQH_TRANSREQ(Signal* sig
 
   req->senderData = ssId;
   req->senderRef = reference();
-  sendSignal(workerRef(ss.m_worker), GSN_LQH_TRANSREQ,
-             signal, LqhTransReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_LQH_TRANSREQ,
+                      signal, LqhTransReq::SignalLength, JBB, handle);
 }
 
 void
@@ -1545,11 +1537,11 @@ DblqhProxy::execEXEC_SR_1(Signal* signal
 }
 
 void
-DblqhProxy::sendEXEC_SR_1(Signal* signal, Uint32 ssId)
+DblqhProxy::sendEXEC_SR_1(Signal* signal, Uint32 ssId, SectionHandle* handle)
 {
   Ss_EXEC_SR_1& ss = ssFind<Ss_EXEC_SR_1>(ssId);
   signal->theData[0] = ss.m_sig.nodeId;
-  sendSignal(workerRef(ss.m_worker), ss.m_gsn, signal, 1, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), ss.m_gsn, signal, 1, JBB, handle);
 }
 
 // GSN_EXEC_SRREQ_2 [ fictional gsn ]
@@ -1669,7 +1661,8 @@ DblqhProxy::execDROP_FRAG_REQ(Signal* si
 }
 
 void
-DblqhProxy::sendDROP_FRAG_REQ(Signal* signal, Uint32 ssId)
+DblqhProxy::sendDROP_FRAG_REQ(Signal* signal, Uint32 ssId,
+                              SectionHandle* handle)
 {
   Ss_DROP_FRAG_REQ& ss = ssFind<Ss_DROP_FRAG_REQ>(ssId);
 
@@ -1677,8 +1670,8 @@ DblqhProxy::sendDROP_FRAG_REQ(Signal* si
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_DROP_FRAG_REQ,
-             signal, DropFragReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_DROP_FRAG_REQ,
+                      signal, DropFragReq::SignalLength, JBB, handle);
 }
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.hpp	2010-03-02 15:37:59 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhProxy.hpp	2010-03-26 11:52:10 +0000
@@ -52,8 +52,8 @@ protected:
     CreateTabReq m_req;
     Uint32 m_lqhConnectPtr[MaxWorkers];
     Ss_CREATE_TAB_REQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendCREATE_TAB_REQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendCREATE_TAB_CONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendCREATE_TAB_REQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendCREATE_TAB_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_CREATE_TAB_REQ>& pool(LocalProxy* proxy) {
@@ -62,7 +62,7 @@ protected:
   };
   SsPool<Ss_CREATE_TAB_REQ> c_ss_CREATE_TAB_REQ;
   void execCREATE_TAB_REQ(Signal*);
-  void sendCREATE_TAB_REQ(Signal*, Uint32 ssId);
+  void sendCREATE_TAB_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execCREATE_TAB_CONF(Signal*);
   void execCREATE_TAB_REF(Signal*);
   void sendCREATE_TAB_CONF(Signal*, Uint32 ssId);
@@ -72,8 +72,8 @@ protected:
     LqhAddAttrReq m_req;
     Uint32 m_reqlength;
     Ss_LQHADDATTREQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendLQHADDATTREQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendLQHADDATTCONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendLQHADDATTREQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendLQHADDATTCONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_LQHADDATTREQ>& pool(LocalProxy* proxy) {
@@ -82,7 +82,7 @@ protected:
   };
   SsPool<Ss_LQHADDATTREQ> c_ss_LQHADDATTREQ;
   void execLQHADDATTREQ(Signal*);
-  void sendLQHADDATTREQ(Signal*, Uint32 ssId);
+  void sendLQHADDATTREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execLQHADDATTCONF(Signal*);
   void execLQHADDATTREF(Signal*);
   void sendLQHADDATTCONF(Signal*, Uint32 ssId);
@@ -94,8 +94,8 @@ protected:
   struct Ss_TAB_COMMITREQ : SsParallel {
     TabCommitReq m_req;
     Ss_TAB_COMMITREQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendTAB_COMMITREQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendTAB_COMMITCONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendTAB_COMMITREQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendTAB_COMMITCONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_TAB_COMMITREQ>& pool(LocalProxy* proxy) {
@@ -104,7 +104,7 @@ protected:
   };
   SsPool<Ss_TAB_COMMITREQ> c_ss_TAB_COMMITREQ;
   void execTAB_COMMITREQ(Signal*);
-  void sendTAB_COMMITREQ(Signal*, Uint32 ssId);
+  void sendTAB_COMMITREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execTAB_COMMITCONF(Signal*);
   void execTAB_COMMITREF(Signal*);
   void sendTAB_COMMITCONF(Signal*, Uint32 ssId);
@@ -114,8 +114,8 @@ protected:
     static const char* name() { return "GCP_SAVEREQ"; }
     GCPSaveReq m_req;
     Ss_GCP_SAVEREQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendGCP_SAVEREQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendGCP_SAVECONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendGCP_SAVEREQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendGCP_SAVECONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_GCP_SAVEREQ>& pool(LocalProxy* proxy) {
@@ -133,7 +133,7 @@ protected:
     return SsIdBase | (ref->gci & 0xFFFF);
   }
   void execGCP_SAVEREQ(Signal*);
-  void sendGCP_SAVEREQ(Signal*, Uint32 ssId);
+  void sendGCP_SAVEREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execGCP_SAVECONF(Signal*);
   void execGCP_SAVEREF(Signal*);
   void sendGCP_SAVECONF(Signal*, Uint32 ssId);
@@ -145,8 +145,8 @@ protected:
   struct Ss_PREP_DROP_TAB_REQ : SsParallel {
     PrepDropTabReq m_req;
     Ss_PREP_DROP_TAB_REQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendPREP_DROP_TAB_REQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendPREP_DROP_TAB_CONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendPREP_DROP_TAB_REQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendPREP_DROP_TAB_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_PREP_DROP_TAB_REQ>& pool(LocalProxy* proxy) {
@@ -164,7 +164,7 @@ protected:
     return SsIdBase | ref->tableId;
   }
   void execPREP_DROP_TAB_REQ(Signal*);
-  void sendPREP_DROP_TAB_REQ(Signal*, Uint32 ssId);
+  void sendPREP_DROP_TAB_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execPREP_DROP_TAB_CONF(Signal*);
   void execPREP_DROP_TAB_REF(Signal*);
   void sendPREP_DROP_TAB_CONF(Signal*, Uint32 ssId);
@@ -173,8 +173,8 @@ protected:
   struct Ss_DROP_TAB_REQ : SsParallel {
     DropTabReq m_req;
     Ss_DROP_TAB_REQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendDROP_TAB_REQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendDROP_TAB_CONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendDROP_TAB_REQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendDROP_TAB_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_DROP_TAB_REQ>& pool(LocalProxy* proxy) {
@@ -192,7 +192,7 @@ protected:
     return SsIdBase | ref->tableId;
   }
   void execDROP_TAB_REQ(Signal*);
-  void sendDROP_TAB_REQ(Signal*, Uint32 ssId);
+  void sendDROP_TAB_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execDROP_TAB_CONF(Signal*);
   void execDROP_TAB_REF(Signal*);
   void sendDROP_TAB_CONF(Signal*, Uint32 ssId);
@@ -200,16 +200,9 @@ protected:
   // GSN_ALTER_TAB_REQ
   struct Ss_ALTER_TAB_REQ : SsParallel {
     AlterTabReq m_req;
-    Uint32 m_sections;
-    // wl4391_todo check max length in various cases
-    enum { MaxSection0 = 2 * MAX_ATTRIBUTES_IN_TABLE };
-    Uint32 m_sz0;
-    Uint32 m_section0[MaxSection0];
     Ss_ALTER_TAB_REQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendALTER_TAB_REQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendALTER_TAB_CONF;
-      m_sections = 0;
-      m_sz0 = 0;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendALTER_TAB_REQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendALTER_TAB_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_ALTER_TAB_REQ>& pool(LocalProxy* proxy) {
@@ -227,7 +220,7 @@ protected:
     return ref->senderData;
   }
   void execALTER_TAB_REQ(Signal*);
-  void sendALTER_TAB_REQ(Signal*, Uint32 ssId);
+  void sendALTER_TAB_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execALTER_TAB_CONF(Signal*);
   void execALTER_TAB_REF(Signal*);
   void sendALTER_TAB_CONF(Signal*, Uint32 ssId);
@@ -254,8 +247,8 @@ protected:
       Uint32 m_ssId;
     } m_req2[m_req2cnt];
     Ss_START_RECREQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendSTART_RECREQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendSTART_RECCONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendSTART_RECREQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendSTART_RECCONF;
       m_req2[0].m_blockNo = LGMAN;
       m_req2[1].m_blockNo = TSMAN;
     }
@@ -266,7 +259,7 @@ protected:
   };
   SsPool<Ss_START_RECREQ> c_ss_START_RECREQ;
   void execSTART_RECREQ(Signal*);
-  void sendSTART_RECREQ(Signal*, Uint32 ssId);
+  void sendSTART_RECREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execSTART_RECCONF(Signal*);
   void sendSTART_RECCONF(Signal*, Uint32 ssId);
 
@@ -287,8 +280,8 @@ protected:
     Conf m_conf;
     Ss_START_RECREQ_2() {
       // reversed sendREQ/sendCONF
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendSTART_RECCONF_2;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendSTART_RECREQ_2;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendSTART_RECCONF_2;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendSTART_RECREQ_2;
     }
     enum { poolSize = 2 };
     static SsPool<Ss_START_RECREQ_2>& pool(LocalProxy* proxy) {
@@ -305,7 +298,7 @@ protected:
   void execSTART_RECREQ_2(Signal*);
   void sendSTART_RECREQ_2(Signal*, Uint32 ssId);
   void execSTART_RECCONF_2(Signal*);
-  void sendSTART_RECCONF_2(Signal*, Uint32 ssId);
+  void sendSTART_RECCONF_2(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_LQH_TRANSREQ
   struct Ss_LQH_TRANSREQ : SsParallel {
@@ -319,8 +312,8 @@ protected:
     LqhTransConf m_conf; // latest conf
     Ss_LQH_TRANSREQ() {
       m_valid = true;
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendLQH_TRANSREQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendLQH_TRANSCONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendLQH_TRANSREQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendLQH_TRANSCONF;
     }
     enum { poolSize = MAX_NDB_NODES };
     static SsPool<Ss_LQH_TRANSREQ>& pool(LocalProxy* proxy) {
@@ -329,7 +322,7 @@ protected:
   };
   SsPool<Ss_LQH_TRANSREQ> c_ss_LQH_TRANSREQ;
   void execLQH_TRANSREQ(Signal*);
-  void sendLQH_TRANSREQ(Signal*, Uint32 ssId);
+  void sendLQH_TRANSREQ(Signal*, Uint32 ssId, SectionHandle*);
   void execLQH_TRANSCONF(Signal*);
   void sendLQH_TRANSCONF(Signal*, Uint32 ssId);
 
@@ -350,8 +343,8 @@ protected:
     GlobalSignalNumber m_gsn;
     Sig m_sig;
     Ss_EXEC_SR_1() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendEXEC_SR_1;
-      m_sendCONF = (SsFUNC)0;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendEXEC_SR_1;
+      m_sendCONF = (SsFUNCREP)0;
       m_gsn = 0;
     };
     enum { poolSize = 1 };
@@ -366,7 +359,7 @@ protected:
   void execEXEC_SRREQ(Signal*);
   void execEXEC_SRCONF(Signal*);
   void execEXEC_SR_1(Signal*, GlobalSignalNumber gsn);
-  void sendEXEC_SR_1(Signal*, Uint32 ssId);
+  void sendEXEC_SR_1(Signal*, Uint32 ssId, SectionHandle*);
 
   // GSN_EXEC_SR_2 [ fictional gsn ]
   struct Ss_EXEC_SR_2 : SsParallel {
@@ -381,8 +374,8 @@ protected:
     Sig m_sig; // all signals must be identical
     Ss_EXEC_SR_2() {
       // reversed roles
-      m_sendREQ = (SsFUNC)0;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendEXEC_SR_2;
+      m_sendREQ = (SsFUNCREQ)0;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendEXEC_SR_2;
       m_gsn = 0;
       m_sigcount = 0;
     };
@@ -410,8 +403,8 @@ protected:
   struct Ss_DROP_FRAG_REQ : SsParallel {
     DropFragReq m_req;
     Ss_DROP_FRAG_REQ() {
-      m_sendREQ = (SsFUNC)&DblqhProxy::sendDROP_FRAG_REQ;
-      m_sendCONF = (SsFUNC)&DblqhProxy::sendDROP_FRAG_CONF;
+      m_sendREQ = (SsFUNCREQ)&DblqhProxy::sendDROP_FRAG_REQ;
+      m_sendCONF = (SsFUNCREP)&DblqhProxy::sendDROP_FRAG_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_DROP_FRAG_REQ>& pool(LocalProxy* proxy) {
@@ -429,7 +422,7 @@ protected:
     return SsIdBase | (ref->tableId ^ ref->fragId);
   }
   void execDROP_FRAG_REQ(Signal*);
-  void sendDROP_FRAG_REQ(Signal*, Uint32 ssId);
+  void sendDROP_FRAG_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execDROP_FRAG_CONF(Signal*);
   void execDROP_FRAG_REF(Signal*);
   void sendDROP_FRAG_CONF(Signal*, Uint32 ssId);

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2010-03-11 09:44:08 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2010-03-26 07:13:06 +0000
@@ -518,7 +518,7 @@ public:
     /**
      * Index attribute list.  Only the length is used in v21x.
      */
-    AttributeList attributeList;
+    IndexAttributeList attributeList;
 
     /**
      * Primary table id, the primary table to be indexed

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	2009-12-14 22:14:34 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp	2010-03-16 15:56:18 +0000
@@ -331,7 +331,7 @@ Dbtup::commit_operation(Signal* signal,
     memcpy(&key, copy->get_disk_ref_ptr(regTabPtr), sizeof(Local_key));
     Uint32 logfile_group_id= regFragPtr->m_logfile_group_id;
 
-    PagePtr diskPagePtr = *(PagePtr*)&m_pgman_ptr;
+    PagePtr diskPagePtr = { (Tup_page*)m_pgman_ptr.p, m_pgman_ptr.i };
     ndbassert(diskPagePtr.p->m_page_no == key.m_page_no);
     ndbassert(diskPagePtr.p->m_file_no == key.m_file_no);
     Uint32 sz, *dst;

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2010-03-11 19:47:09 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2010-03-21 19:05:55 +0000
@@ -3895,7 +3895,7 @@ Dbtup::nr_delete(Signal* signal, Uint32 
       return -1;
     }
 
-    PagePtr disk_page = *(PagePtr*)&m_pgman_ptr;
+    PagePtr disk_page = { (Tup_page*)m_pgman_ptr.p, m_pgman_ptr.i };
     disk_page_set_dirty(disk_page);
 
     CallbackPtr cptr;
@@ -3930,7 +3930,7 @@ Dbtup::nr_delete_page_callback(Signal* s
 {
   Ptr<GlobalPage> gpage;
   m_global_page_pool.getPtr(gpage, page_id);
-  PagePtr pagePtr= *(PagePtr*)&gpage;
+  PagePtr pagePtr= { (Tup_page*)gpage.p, gpage.i };
   disk_page_set_dirty(pagePtr);
   Dblqh::Nr_op_info op;
   op.m_ptr_i = userpointer;
@@ -3990,7 +3990,7 @@ Dbtup::nr_delete_log_buffer_callback(Sig
 
   Ptr<GlobalPage> gpage;
   m_global_page_pool.getPtr(gpage, op.m_page_id);
-  PagePtr pagePtr= *(PagePtr*)&gpage;
+  PagePtr pagePtr = { (Tup_page*)gpage.p, gpage.i };
 
   /**
    * reset page no

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.cpp	2009-09-19 06:30:50 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.cpp	2010-03-26 11:52:10 +0000
@@ -121,7 +121,8 @@ DbtupProxy::execBUILD_INDX_IMPL_REQ(Sign
 }
 
 void
-DbtupProxy::sendBUILD_INDX_IMPL_REQ(Signal* signal, Uint32 ssId)
+DbtupProxy::sendBUILD_INDX_IMPL_REQ(Signal* signal, Uint32 ssId,
+                                    SectionHandle* handle)
 {
   Ss_BUILD_INDX_IMPL_REQ& ss = ssFind<Ss_BUILD_INDX_IMPL_REQ>(ssId);
 
@@ -129,8 +130,8 @@ DbtupProxy::sendBUILD_INDX_IMPL_REQ(Sign
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_BUILD_INDX_IMPL_REQ,
-             signal, BuildIndxImplReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_BUILD_INDX_IMPL_REQ,
+                      signal, BuildIndxImplReq::SignalLength, JBB, handle);
 }
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.hpp	2009-09-19 06:30:50 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupProxy.hpp	2010-03-26 11:52:10 +0000
@@ -50,8 +50,8 @@ protected:
   struct Ss_BUILD_INDX_IMPL_REQ : SsParallel {
     BuildIndxImplReq m_req;
     Ss_BUILD_INDX_IMPL_REQ() {
-      m_sendREQ = (SsFUNC)&DbtupProxy::sendBUILD_INDX_IMPL_REQ;
-      m_sendCONF = (SsFUNC)&DbtupProxy::sendBUILD_INDX_IMPL_CONF;
+      m_sendREQ = (SsFUNCREQ)&DbtupProxy::sendBUILD_INDX_IMPL_REQ;
+      m_sendCONF = (SsFUNCREP)&DbtupProxy::sendBUILD_INDX_IMPL_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_BUILD_INDX_IMPL_REQ>& pool(LocalProxy* proxy) {
@@ -60,7 +60,7 @@ protected:
   };
   SsPool<Ss_BUILD_INDX_IMPL_REQ> c_ss_BUILD_INDX_IMPL_REQ;
   void execBUILD_INDX_IMPL_REQ(Signal*);
-  void sendBUILD_INDX_IMPL_REQ(Signal*, Uint32 ssId);
+  void sendBUILD_INDX_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execBUILD_INDX_IMPL_CONF(Signal*);
   void execBUILD_INDX_IMPL_REF(Signal*);
   void sendBUILD_INDX_IMPL_CONF(Signal*, Uint32 ssId);

=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.cpp	2009-09-19 06:30:50 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.cpp	2010-03-26 11:52:10 +0000
@@ -48,7 +48,8 @@ DbtuxProxy::execALTER_INDX_IMPL_REQ(Sign
 }
 
 void
-DbtuxProxy::sendALTER_INDX_IMPL_REQ(Signal* signal, Uint32 ssId)
+DbtuxProxy::sendALTER_INDX_IMPL_REQ(Signal* signal, Uint32 ssId,
+                                    SectionHandle * handle)
 {
   Ss_ALTER_INDX_IMPL_REQ& ss = ssFind<Ss_ALTER_INDX_IMPL_REQ>(ssId);
 
@@ -56,8 +57,8 @@ DbtuxProxy::sendALTER_INDX_IMPL_REQ(Sign
   *req = ss.m_req;
   req->senderRef = reference();
   req->senderData = ssId;
-  sendSignal(workerRef(ss.m_worker), GSN_ALTER_INDX_IMPL_REQ,
-             signal, AlterIndxImplReq::SignalLength, JBB);
+  sendSignalNoRelease(workerRef(ss.m_worker), GSN_ALTER_INDX_IMPL_REQ,
+                      signal, AlterIndxImplReq::SignalLength, JBB, handle);
 }
 
 void

=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.hpp	2009-09-19 06:30:50 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxProxy.hpp	2010-03-26 11:52:10 +0000
@@ -33,8 +33,8 @@ protected:
   struct Ss_ALTER_INDX_IMPL_REQ : SsParallel {
     AlterIndxImplReq m_req;
     Ss_ALTER_INDX_IMPL_REQ() {
-      m_sendREQ = (SsFUNC)&DbtuxProxy::sendALTER_INDX_IMPL_REQ;
-      m_sendCONF = (SsFUNC)&DbtuxProxy::sendALTER_INDX_IMPL_CONF;
+      m_sendREQ = (SsFUNCREQ)&DbtuxProxy::sendALTER_INDX_IMPL_REQ;
+      m_sendCONF = (SsFUNCREP)&DbtuxProxy::sendALTER_INDX_IMPL_CONF;
     }
     enum { poolSize = 1 };
     static SsPool<Ss_ALTER_INDX_IMPL_REQ>& pool(LocalProxy* proxy) {
@@ -43,7 +43,7 @@ protected:
   };
   SsPool<Ss_ALTER_INDX_IMPL_REQ> c_ss_ALTER_INDX_IMPL_REQ;
   void execALTER_INDX_IMPL_REQ(Signal*);
-  void sendALTER_INDX_IMPL_REQ(Signal*, Uint32 ssId);
+  void sendALTER_INDX_IMPL_REQ(Signal*, Uint32 ssId, SectionHandle*);
   void execALTER_INDX_IMPL_CONF(Signal*);
   void execALTER_INDX_IMPL_REF(Signal*);
   void sendALTER_INDX_IMPL_CONF(Signal*, Uint32 ssId);

=== modified file 'storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp'
--- a/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp	2009-09-03 13:52:29 +0000
+++ b/storage/ndb/src/kernel/blocks/qmgr/Qmgr.hpp	2010-03-16 15:56:18 +0000
@@ -382,11 +382,10 @@ private:
   void stateArbitRun(Signal* signal);
   void stateArbitChoose(Signal* signal);
   void stateArbitCrash(Signal* signal);
-  void computeArbitNdbMask(NodeBitmask& aMask);
-  void computeArbitNdbMask(NdbNodeBitmask& aMask);
+  void computeArbitNdbMask(NodeBitmaskPOD& aMask);
+  void computeArbitNdbMask(NdbNodeBitmaskPOD& aMask);
   void reportArbitEvent(Signal* signal, Ndb_logevent_type type,
                         const NodeBitmask mask = NodeBitmask());
-
   // Initialisation
   void initData();
   void initRecords();

=== modified file 'storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp'
--- a/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp	2009-10-06 14:14:05 +0000
+++ b/storage/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp	2010-03-21 19:05:55 +0000
@@ -4609,7 +4609,7 @@ Qmgr::execARBIT_CFG(Signal* signal)
   unsigned rank = sd->code;
   ndbrequire(1 <= rank && rank <= 2);
   arbitRec.apiMask[0].bitOR(sd->mask);
-  arbitRec.apiMask[rank] = sd->mask;
+  arbitRec.apiMask[rank].assign(sd->mask);
 }
 
 /**
@@ -5552,7 +5552,7 @@ Qmgr::execARBIT_STOPREP(Signal* signal)
 }
 
 void
-Qmgr::computeArbitNdbMask(NodeBitmask& aMask)
+Qmgr::computeArbitNdbMask(NodeBitmaskPOD& aMask)
 {
   NodeRecPtr aPtr;
   aMask.clear();
@@ -5567,7 +5567,7 @@ Qmgr::computeArbitNdbMask(NodeBitmask& a
 }
 
 void
-Qmgr::computeArbitNdbMask(NdbNodeBitmask& aMask)
+Qmgr::computeArbitNdbMask(NdbNodeBitmaskPOD& aMask)
 {
   NodeRecPtr aPtr;
   aMask.clear();

=== modified file 'storage/ndb/src/kernel/vm/WatchDog.cpp'
--- a/storage/ndb/src/kernel/vm/WatchDog.cpp	2010-01-21 15:48:38 +0000
+++ b/storage/ndb/src/kernel/vm/WatchDog.cpp	2010-04-01 15:22:57 +0000
@@ -19,7 +19,6 @@
 
 #include <ndb_global.h>
 #include <my_pthread.h>
-#include <my_times.h>
 
 #include "WatchDog.hpp"
 #include "GlobalData.hpp"
@@ -165,6 +164,58 @@ const char *get_action(Uint32 IPValue)
   return action;
 }
 
+
+#ifdef _WIN32
+struct tms {
+  clock_t tms_utime;  /* user time */
+  clock_t tms_stime;  /* system time */
+  clock_t tms_cutime; /* user time of children */
+  clock_t tms_cstime; /* system time of children */
+};
+
+static clock_t
+times(struct tms *buf)
+{
+  if (!buf)
+  {
+    errno = EINVAL;
+    return -1;
+  }
+
+  FILETIME create, exit, kernel, user;
+  if (GetProcessTimes(GetCurrentProcess(),
+                      &create, &exit, &kernel, &user) == 0)
+  {
+    errno = GetLastError();
+    return -1;
+  }
+
+  ULARGE_INTEGER ulint;
+  ulint.LowPart = kernel.dwLowDateTime;
+  ulint.HighPart = kernel.dwHighDateTime;
+  buf->tms_stime = (clock_t)ulint.QuadPart;
+  buf->tms_cstime = (clock_t)ulint.QuadPart;
+
+  ulint.LowPart = user.dwLowDateTime;
+  ulint.HighPart = user.dwHighDateTime;
+  buf->tms_utime = (clock_t)ulint.QuadPart;
+  buf->tms_cutime = (clock_t)ulint.QuadPart;
+
+  LARGE_INTEGER ticks;
+  if (QueryPerformanceCounter(&ticks) == 0)
+  {
+    errno = GetLastError();
+    return -1;
+  }
+
+  return (clock_t)ticks.QuadPart;
+}
+
+
+#else
+#include <sys/times.h>
+#endif
+
 void 
 WatchDog::run()
 {

=== modified file 'storage/ndb/src/mgmsrv/CMakeLists.txt'
--- a/storage/ndb/src/mgmsrv/CMakeLists.txt	2010-03-05 19:19:56 +0000
+++ b/storage/ndb/src/mgmsrv/CMakeLists.txt	2010-04-07 09:14:43 +0000
@@ -29,6 +29,8 @@ ADD_LIBRARY(ndbconf
 )
 
 ADD_EXECUTABLE(ndb_mgmd
+               ${CMAKE_SOURCE_DIR}/storage/ndb/src/common/logger/message.rc
+               ${CMAKE_SOURCE_DIR}/storage/ndb/src/common/logger/msg00001.bin
                MgmtSrvr.cpp
                main.cpp
                Services.cpp

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2010-03-02 17:49:20 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2010-04-09 11:25:22 +0000
@@ -121,7 +121,7 @@ MgmtSrvr::logLevelThreadRun() 
         for(int i = m_event_listner.m_clients.size() - 1; i >= 0; i--)
           tmp.set_max(m_event_listner[i].m_logLevel);
         m_event_listner.unlock();
-        req = tmp;
+        req.assign(tmp);
       }
       req.blockRef = _ownReference;
       while (m_started_nodes.size() > 0)
@@ -137,7 +137,7 @@ MgmtSrvr::logLevelThreadRun() 
         else
         {
           SetLogLevelOrd ord;
-          ord = m_nodeLogLevel[node];
+          ord.assign(m_nodeLogLevel[node]);
           setNodeLogLevelImpl(node, ord);
         }
         m_started_nodes.lock();
@@ -163,7 +163,7 @@ MgmtSrvr::logLevelThreadRun() 
       else 
       {
         SetLogLevelOrd ord;
-        ord = req;
+        ord.assign(req);
         if (setNodeLogLevelImpl(req.blockRef, ord))
         {
           failed_log_level_requests.push_back(req);
@@ -2513,8 +2513,11 @@ MgmtSrvr::handleStatus(NodeId nodeId, bo
   DBUG_PRINT("enter",("nodeid: %d, alive: %d, nfComplete: %d",
                       nodeId, alive, nfComplete));
 
-  Uint32 theData[25];
-  EventReport *rep = (EventReport *)theData;
+  union {
+    Uint32 theData[25];
+    EventReport repData;
+  };
+  EventReport * rep = &repData;
 
   theData[1] = nodeId;
   if (alive) {
@@ -2691,9 +2694,9 @@ MgmtSrvr::alloc_node_id_req(NodeId free_
   return 0;
 }
 
-int
-MgmtSrvr::match_hostname(const struct sockaddr *clnt_addr,
-                         const char *config_hostname) const
+static int
+match_hostname(const struct sockaddr *clnt_addr,
+               const char *config_hostname)
 {
   struct in_addr config_addr= {0};
   if (clnt_addr)
@@ -2708,11 +2711,6 @@ MgmtSrvr::match_hostname(const struct so
           || memcmp(&tmp_addr, clnt_in_addr, sizeof(config_addr)) != 0)
       {
         // not localhost
-#if 0
-        ndbout << "MgmtSrvr::getFreeNodeId compare failed for \""
-               << config_hostname
-               << "\" id=" << tmp << endl;
-#endif
         return -1;
       }
 

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.hpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2010-03-02 17:49:20 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2010-04-09 11:24:12 +0000
@@ -551,7 +551,6 @@ public:
                      NodeBitmask &exact_nodes,
                      Vector<nodeid_and_host> &nodes_info,
                      int &error_code, BaseString &error_string);
-  int match_hostname(const struct sockaddr *, const char *) const;
   int try_alloc(unsigned id,  const char *, enum ndb_mgm_node_type type,
                 const struct sockaddr *client_addr, Uint32 timeout_ms);
 

=== modified file 'storage/ndb/src/mgmsrv/Services.cpp'
--- a/storage/ndb/src/mgmsrv/Services.cpp	2010-03-02 17:49:20 +0000
+++ b/storage/ndb/src/mgmsrv/Services.cpp	2010-03-16 10:35:47 +0000
@@ -1459,7 +1459,7 @@ Ndb_mgmd_event_service::update_log_level
 {
   m_logLevel = tmp;
   EventSubscribeReq req;
-  req = tmp;
+  req.assign(tmp);
   // send update to all nodes
   req.blockRef = 0;
   m_mgmsrv->m_log_level_requests.push_back(req);

=== modified file 'storage/ndb/src/mgmsrv/main.cpp'
--- a/storage/ndb/src/mgmsrv/main.cpp	2009-11-13 11:24:05 +0000
+++ b/storage/ndb/src/mgmsrv/main.cpp	2010-04-07 09:14:43 +0000
@@ -202,21 +202,14 @@ static int mgmd_main(int argc, char** ar
 
   g_eventLogger->setCategory(opt_logname);
 
-#ifdef _WIN32
-#ifdef _DEBUG
-  if (opts.daemon)
-  {
-    /* Write eventlog output to file for easier debugging */
-    g_eventLogger->createFileHandler("c:\\ndb_mgmd_debug.log");
-    g_eventLogger->info("StdoutFileName: %s", NdbConfig_StdoutFileName(0));
-    g_eventLogger->info("get_path: %s", NdbConfig_get_path(0));
-    g_eventLogger->info("GetCommandLine: %s", GetCommandLine());
-  }
-#endif
-#endif
   /* Output to console initially */
   g_eventLogger->createConsoleHandler();
 
+#ifdef _WIN32
+  /* Output to Windows event log */
+  g_eventLogger->createEventLogHandler("MySQL Cluster Management Server");
+#endif
+
   if (opts.verbose)
     g_eventLogger->enable(Logger::LL_DEBUG);
 

=== modified file 'storage/ndb/src/ndbapi/NdbApiSignal.hpp'
--- a/storage/ndb/src/ndbapi/NdbApiSignal.hpp	2010-03-16 08:54:58 +0000
+++ b/storage/ndb/src/ndbapi/NdbApiSignal.hpp	2010-03-21 19:05:55 +0000
@@ -56,6 +56,7 @@
 #include <signaldata/SchemaTrans.hpp>
 #include <signaldata/CreateHashMap.hpp>
 #include <signaldata/ApiRegSignalData.hpp>

+#include <signaldata/ArbitSignalData.hpp>
 
 /**
  * A NdbApiSignal : public SignalHeader
@@ -142,6 +143,8 @@ private:
     SchemaTransBeginReq _SchemaTransBeginReq;
     SchemaTransEndReq _SchemaTransEndReq;
     ApiRegReq _ApiRegReq;
+    ApiRegConf _ApiRegConf;
+    ArbitSignalData _ArbitSignalData;
   };
   NdbApiSignal *theNextSignal;
   Uint32 *theRealData;

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2010-03-02 15:49:27 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2010-03-26 07:13:06 +0000
@@ -3992,7 +3992,7 @@ NdbDictInterface::createIndex(Ndb & ndb,
   req->tableId = table.m_id;
   req->tableVersion = table.m_version;
   req->online = true;
-  AttributeList attributeList;
+  IndexAttributeList attributeList;
   attributeList.sz = impl.m_columns.size();
   for(i = 0; i<attributeList.sz; i++){
     const NdbColumnImpl* col = 
@@ -5157,8 +5157,8 @@ NdbDictionaryImpl::listObjects(List& lis
   }
 
   ListTablesReq req;
-  req.requestData = 0;
-  req.tableId = 0;
+  req.init();
+  req.setTableId(0);
   req.setTableType(getKernelConstant(type, objectTypeMapping, 0));
   req.setListNames(true);
   if (!list2.count)
@@ -5189,9 +5189,9 @@ int
 NdbDictionaryImpl::listIndexes(List& list, Uint32 indexId)
 {
   ListTablesReq req;
-  req.requestData = 0;
+  req.init();
   req.setTableId(indexId);
-  req.tableType = 0;
+  req.setTableType(0);
   req.setListNames(true);
   req.setListIndexes(true);
   return m_receiver.listObjects(list, req, m_ndb.usingFullyQualifiedNames());
@@ -5204,11 +5204,9 @@ NdbDictInterface::listObjects(NdbDiction
   bool listTablesLongSignal = false;
   NdbApiSignal tSignal(m_reference);
   ListTablesReq* const req = CAST_PTR(ListTablesReq, tSignal.getDataPtrSend());
+  memcpy(req, &ltreq, sizeof(ListTablesReq));
   req->senderRef = m_reference;
   req->senderData = 0;
-  req->requestData = ltreq.requestData;
-  req->setTableId(ltreq.getTableId());
-  req->setTableType(ltreq.getTableType());
   if (ltreq.getTableId() > 4096)
   {
     /*
@@ -5256,7 +5254,9 @@ NdbDictInterface::unpackListTables(NdbDi
   while (count < m_noOfTables)
   {
     NdbDictionary::Dictionary::List::Element& element = list.elements[count];
-    ListTablesData* ltd = (ListTablesData *) tableData;
+    ListTablesData _ltd;
+    ListTablesData * ltd = &_ltd;
+    memcpy(ltd, tableData, 4 * listTablesDataSizeInWords);
     tableData += listTablesDataSizeInWords;
     element.id = ltd->getTableId();
     element.type = (NdbDictionary::Object::Type)

=== modified file 'storage/ndb/src/ndbapi/NdbInfo.cpp'
--- a/storage/ndb/src/ndbapi/NdbInfo.cpp	2010-01-25 10:04:59 +0000
+++ b/storage/ndb/src/ndbapi/NdbInfo.cpp	2010-03-23 08:38:52 +0000
@@ -313,7 +313,15 @@ void NdbInfo::flush_tables()
   // Delete all but the hardcoded tables
   while (m_tables.entries() > NUM_HARDCODED_TABLES)
   {
-    m_tables.remove(NUM_HARDCODED_TABLES);
+    for (size_t i = 0; i<m_tables.entries(); i++)
+    {
+      Table * tab = m_tables.value(i);
+      if (! (tab == m_tables_table || tab == m_columns_table))
+      {
+        m_tables.remove(i);
+        break;
+      }
+    }
   }
   assert(m_tables.entries() == NUM_HARDCODED_TABLES);
 }

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-02-04 15:18:17 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-03-23 11:51:32 +0000
@@ -446,7 +446,9 @@ TransporterFacade::start_instance(NodeId
   if (!theTransporterRegistry->init(nodeId))
     return -1;
 
-  theClusterMgr = new ClusterMgr(*this);
+  if (theClusterMgr == NULL)
+    theClusterMgr = new ClusterMgr(*this);
+
   if (theClusterMgr == NULL)
     return -1;
 
@@ -750,6 +752,9 @@ TransporterFacade::TransporterFacade(Glo
 #ifdef API_TRACE
   apiSignalLog = 0;
 #endif
+
+  theClusterMgr = new ClusterMgr(*this);
+
   DBUG_VOID_RETURN;
 }
 

=== modified file 'storage/ndb/src/ndbapi/ndberror.c'
--- a/storage/ndb/src/ndbapi/ndberror.c	2010-03-02 15:49:27 +0000
+++ b/storage/ndb/src/ndbapi/ndberror.c	2010-04-01 05:20:25 +0000
@@ -432,6 +432,7 @@ ErrorBundle ErrorCodes[] = {
   { 770,  DMEC, SE, "Cant drop file, file is used" },
   { 774,  DMEC, SE, "Invalid schema object for drop" },
   { 790,  HA_WRONG_CREATE_OPTION, SE, "Invalid hashmap" },
+  { 793,  DMEC, AE, "Object definition too big" },
   { 241,  HA_ERR_TABLE_DEF_CHANGED, SE, "Invalid schema object version" },
   { 283,  HA_ERR_NO_SUCH_TABLE, SE, "Table is being dropped" },
   { 284,  HA_ERR_TABLE_DEF_CHANGED, SE, "Table not defined in transaction coordinator" },

=== modified file 'storage/ndb/test/include/NdbRestarts.hpp'
--- a/storage/ndb/test/include/NdbRestarts.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/test/include/NdbRestarts.hpp	2010-03-19 14:15:57 +0000
@@ -40,6 +40,7 @@
  *
  */
 
+class NDBT_Context;
 
 class NdbRestarts {
 public:
@@ -56,7 +57,7 @@ public:
   };
 
   struct NdbRestart {
-    typedef int (restartFunc)(NdbRestarter&, const NdbRestart*);
+    typedef int (restartFunc)(NDBT_Context*, NdbRestarter&, const NdbRestart*);
     
     NdbRestart(const char* _name,
 	       NdbRestartType _type,
@@ -74,13 +75,13 @@ public:
 
   int getNumRestarts();
 
-  int executeRestart(int _num, unsigned int _timeout = 120);
-  int executeRestart(const char* _name, unsigned int _timeout = 120);
+  int executeRestart(NDBT_Context*, int _num, unsigned int _to = 120);
+  int executeRestart(NDBT_Context*, const char* _name, unsigned int _to = 120);
 
   void listRestarts();
   void listRestarts(NdbRestartType _type);
 private:
-  int executeRestart(const NdbRestart*, unsigned int _timeout);
+  int executeRestart(NDBT_Context*, const NdbRestart*, unsigned int _timeout);
 
   struct NdbErrorInsert {
     NdbErrorInsert(const char* _name,

=== modified file 'storage/ndb/test/ndbapi/CMakeLists.txt'
--- a/storage/ndb/test/ndbapi/CMakeLists.txt	2009-11-13 04:50:47 +0000
+++ b/storage/ndb/test/ndbapi/CMakeLists.txt	2010-04-16 12:25:53 +0000
@@ -73,5 +73,14 @@ Add_EXECUTABLE(testNdbinfo testNdbinfo.c
 TARGET_LINK_LIBRARIES(testBackup ndbbank)
 TARGET_LINK_LIBRARIES(testSRBank ndbbank)
 
-INSTALL(TARGETS testBasic testBackup testNdbApi testDict testIndex testSRBank
+INSTALL(TARGETS create_all_tabs create_tab drop_all_tabs flexAsynch flexBench
+                flexHammer flexTT testBackup testBasic testBasicAsynch
+                testBlobs testDataBuffers testDict testIndex testMgm
+                testNdbApi testNodeRestart testOIBasic testOperations
+                testRestartGci testScan testSRBank testInterpreter
+                testScanFilter testScanInterpreter testScanPerf
+                testSystemRestart testTimeout testTransactions
+                testDeadlock test_event ndbapi_slow_select testReadPerf
+                testLcp testPartitioning testBitfield DbCreate
+                DbAsyncGenerator test_event_merge testNdbinfo 
         DESTINATION bin)

=== modified file 'storage/ndb/test/ndbapi/flexAsynch.cpp'
--- a/storage/ndb/test/ndbapi/flexAsynch.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/test/ndbapi/flexAsynch.cpp	2010-03-16 15:56:18 +0000
@@ -604,8 +604,10 @@ executeThread(ThreadNdb* pThread, 
           tBase2 = getKey(threadBase, tBase2);
         }//if
         if (startTransGuess == true) {
-          Uint64 Tkey64;
-          Uint32* Tkey32 = (Uint32*)&Tkey64;
+	  union {
+            Uint64 Tkey64;
+            Uint32 Tkey32[2];
+	  };
           Tkey32[0] = threadBase;
           Tkey32[1] = tBase2;
           tConArray[j] = aNdbObject->startTransaction((Uint32)0, //Priority
@@ -655,8 +657,10 @@ static 
 Uint32
 getKey(Uint32 aBase, Uint32 anIndex) {
   Uint32 Tfound = anIndex;
-  Uint64 Tkey64;
-  Uint32* Tkey32 = (Uint32*)&Tkey64;
+  union {
+    Uint64 Tkey64;
+    Uint32 Tkey32[2];
+  };
   Tkey32[0] = aBase;
   Uint32 hash;
   for (Uint32 i = anIndex; i < (anIndex + MAX_SEEK); i++) {

=== modified file 'storage/ndb/test/ndbapi/flexTT.cpp'
--- a/storage/ndb/test/ndbapi/flexTT.cpp	2009-09-25 14:08:15 +0000
+++ b/storage/ndb/test/ndbapi/flexTT.cpp	2010-03-16 15:56:18 +0000
@@ -469,8 +469,10 @@ Uint32
 getKey(Uint32 aBase, Uint32 aThreadBase) {
   Uint32 Tfound = aBase;
   Uint32 hash;
-  Uint64 Tkey64;
-  Uint32* tKey32 = (Uint32*)&Tkey64;
+  union {
+    Uint64 Tkey64;
+    Uint32 tKey32[2];
+  };
   tKey32[0] = aThreadBase;
   for (Uint32 i = aBase; i < (aBase + MAX_SEEK); i++) {
     tKey32[1] = i;

=== modified file 'storage/ndb/test/ndbapi/testIndex.cpp'
--- a/storage/ndb/test/ndbapi/testIndex.cpp	2010-03-11 09:44:08 +0000
+++ b/storage/ndb/test/ndbapi/testIndex.cpp	2010-03-19 14:15:57 +0000
@@ -635,7 +635,7 @@ int runRestarts(NDBT_Context* ctx, NDBT_
   int sync_threads = ctx->getProperty("Threads", (unsigned)0);
 
   while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
-    if(restarts.executeRestart("RestartRandomNodeAbort", timeout) != 0){
+    if(restarts.executeRestart(ctx, "RestartRandomNodeAbort", timeout) != 0){
       g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
       result = NDBT_FAILED;
       break;

=== modified file 'storage/ndb/test/ndbapi/testMgm.cpp'
--- a/storage/ndb/test/ndbapi/testMgm.cpp	2010-03-11 19:47:09 +0000
+++ b/storage/ndb/test/ndbapi/testMgm.cpp	2010-03-16 15:56:18 +0000
@@ -469,8 +469,11 @@ int runTestMgmApiEventTimeout(NDBT_Conte
       result= NDBT_FAILED;
     }
 
-    Uint32 theData[25];
-    EventReport *fake_event = (EventReport*)theData;
+    union {
+      Uint32 theData[25];
+      EventReport repData;
+    };
+    EventReport *fake_event = &repData;
     fake_event->setEventType(NDB_LE_NDBStopForced);
     fake_event->setNodeId(42);
     theData[2]= 0;
@@ -579,8 +582,11 @@ int runTestMgmApiStructEventTimeout(NDBT
     {
       if(error_ins==0 || (error_ins!=0 && i<5))
       {
-        Uint32 theData[25];
-        EventReport *fake_event = (EventReport*)theData;
+        union {
+	  Uint32 theData[25];
+	  EventReport repData;
+	};
+        EventReport *fake_event = &repData;
         fake_event->setEventType(NDB_LE_NDBStopForced);
         fake_event->setNodeId(42);
         theData[2]= 0;

=== modified file 'storage/ndb/test/ndbapi/testNdbApi.cpp'
--- a/storage/ndb/test/ndbapi/testNdbApi.cpp	2010-01-28 15:16:46 +0000
+++ b/storage/ndb/test/ndbapi/testNdbApi.cpp	2010-03-19 14:15:57 +0000
@@ -526,7 +526,7 @@ int runTestDeleteNdb(NDBT_Context* ctx, 
     if ((l % 2) == 0){
       // Restart random node 
       ndbout << "Restart random node " << endl;
-      if(restarts.executeRestart("RestartRandomNodeAbort", 120) != 0){
+      if(restarts.executeRestart(ctx, "RestartRandomNodeAbort", 120) != 0){
 	g_err << "Failed to executeRestart(RestartRandomNode)"<<endl;
 	result = NDBT_FAILED;
 	goto end_test;
@@ -534,7 +534,7 @@ int runTestDeleteNdb(NDBT_Context* ctx, 
     } else {
       // Restart all nodes
       ndbout << "Restart all nodes " << endl;
-      if(restarts.executeRestart("RestartAllNodesAbort", 120) != 0){
+      if(restarts.executeRestart(ctx, "RestartAllNodesAbort", 120) != 0){
 	g_err << "Failed to executeRestart(RestartAllNodes)"<<endl;
 	result = NDBT_FAILED;
 	goto end_test;

=== modified file 'storage/ndb/test/ndbapi/testNodeRestart.cpp'
--- a/storage/ndb/test/ndbapi/testNodeRestart.cpp	2010-01-28 15:16:46 +0000
+++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp	2010-03-19 14:15:57 +0000
@@ -453,7 +453,7 @@ int runRestarts(NDBT_Context* ctx, NDBT_
 
   while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
     
-    if(restarts.executeRestart(pCase->getName(), timeout) != 0){
+    if(restarts.executeRestart(ctx, pCase->getName(), timeout) != 0){
       g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
       result = NDBT_FAILED;
       break;

=== modified file 'storage/ndb/test/ndbapi/testReconnect.cpp'
--- a/storage/ndb/test/ndbapi/testReconnect.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/test/ndbapi/testReconnect.cpp	2010-03-19 14:15:57 +0000
@@ -152,7 +152,7 @@ int runRestartCluster(NDBT_Context* ctx,
 
     ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
-    if(restarts.executeRestart("RestartAllNodesAbort", timeout) != 0){
+    if(restarts.executeRestart(ctx, "RestartAllNodesAbort", timeout) != 0){
       g_err << "Failed to restart all nodes with abort" << endl;
       result = NDBT_FAILED;
       break;

=== modified file 'storage/ndb/test/ndbapi/testSystemRestart.cpp'
--- a/storage/ndb/test/ndbapi/testSystemRestart.cpp	2009-11-05 10:16:57 +0000
+++ b/storage/ndb/test/ndbapi/testSystemRestart.cpp	2010-03-17 12:35:51 +0000
@@ -1860,7 +1860,8 @@ runTO(NDBT_Context* ctx, NDBT_Step* step
       CHECK(res.waitNodesNoStart(&node, 1) == 0);
       for (Uint32 j = 0; j<25; j++)
       {
-        CHECK(hugoTrans.scanUpdateRecords(pNdb, 0) == 0);
+        if (! (hugoTrans.scanUpdateRecords(pNdb, 0) == 0))
+          break;
       }
       while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
             event.type != NDB_LE_LocalCheckpointCompleted);
@@ -1872,13 +1873,23 @@ runTO(NDBT_Context* ctx, NDBT_Step* step
     Uint32 LCP = event.LocalCheckpointCompleted.lci;
     ndbout_c("LCP: %u", LCP);
     
-    do {
+    do 
+    {
+      bzero(&event, sizeof(event));
       while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
             event.type != NDB_LE_LocalCheckpointCompleted)
+        bzero(&event, sizeof(event));
+      
+      if (event.type == NDB_LE_LocalCheckpointCompleted &&
+          event.LocalCheckpointCompleted.lci < LCP + 3)
       {
-        CHECK(hugoTrans.scanUpdateRecords(pNdb, 0) == 0);
+        hugoTrans.scanUpdateRecords(pNdb, 0);
+      }
+      else
+      {
+        break;
       }
-    } while (event.LocalCheckpointCompleted.lci < LCP + 3);
+    } while (true);
     
     ndbout_c("LCP: %u", event.LocalCheckpointCompleted.lci);
     

=== modified file 'storage/ndb/test/ndbapi/testTimeout.cpp'
--- a/storage/ndb/test/ndbapi/testTimeout.cpp	2009-09-25 13:38:00 +0000
+++ b/storage/ndb/test/ndbapi/testTimeout.cpp	2010-03-17 12:35:51 +0000
@@ -370,10 +370,16 @@ int runBuddyTransNoTimeout(NDBT_Context*
       CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
       
       int remain = maxSleep;
-      for (int i = 0; i < 3; i++){
-	// Perform buddy scan reads
-	CHECK((hugoOps.scanReadRecords(pNdb)) == 0);
-	CHECK(hugoOps.execute_NoCommit(pNdb) == 0); 
+      for (int i = 0; i < 3; i++)
+      {
+        NdbTransaction* pTrans = hugoOps.getTransaction();
+
+        // Perform buddy scan reads
+        NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab());
+        CHECK(pOp != 0);
+        CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0);
+        CHECK(pTrans->execute(NoCommit) == 0);
+        while(pOp->nextResult() == 0);
 	
         int sleep = myRandom48(remain);
         remain = remain - sleep + 1;

=== modified file 'storage/ndb/test/ndbapi/testUpgrade.cpp'
--- a/storage/ndb/test/ndbapi/testUpgrade.cpp	2010-02-18 23:50:31 +0000
+++ b/storage/ndb/test/ndbapi/testUpgrade.cpp	2010-03-22 12:38:39 +0000
@@ -578,7 +578,7 @@ int runCheckStarted(NDBT_Context* ctx, N
 
   // Make sure atrt assigns nodeid != -1
   SqlResultSet procs;
-  if (!atrt.doQuery("SELECT * FROM process", procs))
+  if (!atrt.doQuery("SELECT * FROM process where type <> \'mysql\'", procs))
     return NDBT_FAILED;
 
   while (procs.next())

=== modified file 'storage/ndb/test/ndbapi/test_event.cpp'
--- a/storage/ndb/test/ndbapi/test_event.cpp	2009-09-25 21:26:33 +0000
+++ b/storage/ndb/test/ndbapi/test_event.cpp	2010-03-19 14:15:57 +0000
@@ -1660,7 +1660,7 @@ static int runMulti_NR(NDBT_Context* ctx
     {
       // restart a node
       int timeout = 240;
-      if (restarts.executeRestart("RestartRandomNodeAbort", timeout))
+      if (restarts.executeRestart(ctx, "RestartRandomNodeAbort", timeout))
       {
 	DBUG_RETURN(NDBT_FAILED);
       }

=== modified file 'storage/ndb/test/run-test/CMakeLists.txt'
--- a/storage/ndb/test/run-test/CMakeLists.txt	2010-01-04 00:50:23 +0000
+++ b/storage/ndb/test/run-test/CMakeLists.txt	2010-04-16 12:25:53 +0000
@@ -34,19 +34,15 @@ INCLUDE_DIRECTORIES(
 ADD_EXECUTABLE(atrt main.cpp setup.cpp files.cpp db.cpp command.cpp)
 TARGET_LINK_LIBRARIES(atrt ndbNDBT ndbclient dbug mysys strings mysqlclient)
 
-INSTALL(TARGETS atrt DESTINATION bin)
-INSTALL(FILES
-               atrt-testBackup
-               atrt-analyze-result.sh
-               atrt-backtrace.sh
-               atrt-gather-result.sh
-               atrt-setup.sh
-               autotest-boot.sh
-               autotest-run.sh
-               check-tests.sh
-               make-config.sh
-               make-html-reports.sh
-               make-index.sh
-               ndb-autotest.sh
-               upgrade-boot.sh
-         DESTINATION bin)
+INSTALL(TARGETS atrt DESTINATION mysql-test/bin)
+INSTALL(FILES   atrt-testBackup atrt-mysql-test-run DESTINATION bin)
+INSTALL(FILES   atrt-analyze-result.sh atrt-backtrace.sh atrt-gather-result.sh
+                atrt-setup.sh autotest-boot.sh autotest-run.sh
+                check-tests.sh make-config.sh make-html-reports.sh
+                make-index.sh ndb-autotest.sh upgrade-boot.sh
+                daily-basic-tests.txt daily-devel-tests.txt 16node-tests.txt
+                conf-ndbmaster.cnf conf-fimafeng08.cnf conf-fimafeng09.cnf 
+                conf-dl145a.cnf conf-loki27.cnf conf-ndb07.cnf conf-repl.conf
+                conf-techra29-conf conf-test.cnf conf-tyr64.cnf conf-upgrade.cnf
+                test-tests.txt upgrade-tests.txt 
+         DESTINATION mysql-test/ndb)

=== modified file 'storage/ndb/test/run-test/atrt-backtrace.sh'
--- a/storage/ndb/test/run-test/atrt-backtrace.sh	2008-09-03 13:59:40 +0000
+++ b/storage/ndb/test/run-test/atrt-backtrace.sh	2010-04-16 12:25:53 +0000
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+# Does not work on Windows (gcc only)
+if uname | grep -iq cygwin
+then
+    exit
+fi
+
 core=$1
 out=$2
 

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2010-03-11 09:44:08 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2010-03-17 12:37:40 +0000
@@ -1511,7 +1511,7 @@ max-time: 300
 cmd: testIndex
 args: -n ConstraintDetails
 
-max-time: 500
+max-time: 900
 cmd: testNdbinfo
 args:
 

=== modified file 'storage/ndb/test/run-test/main.cpp'
--- a/storage/ndb/test/run-test/main.cpp	2009-12-03 05:53:33 +0000
+++ b/storage/ndb/test/run-test/main.cpp	2010-04-16 08:53:12 +0000
@@ -177,32 +177,50 @@ main(int argc, char ** argv)
   g_logger.createConsoleHandler();
   
   if(!parse_args(argc, argv))
+  {
+    g_logger.critical("Failed to parse arguments");
     goto end;
+  }
   
   g_logger.info("Starting...");
   g_config.m_generated = false;
   g_config.m_replication = g_replicate;
   if (!setup_config(g_config, g_mysqld_host))
+  {
+    g_logger.critical("Failed to setup configuration");
     goto end;
+  }
 
   if (!configure(g_config, g_do_setup))
+  {
+    g_logger.critical("Failed to configure");
     goto end;
+  }
   
   g_logger.info("Setting up directories...");
   if (!setup_directories(g_config, g_do_setup))
+  {
+    g_logger.critical("Failed to set up directories");
     goto end;
+  }
 
   if (g_do_setup)
   {
     g_logger.info("Setting up files...");
     if (!setup_files(g_config, g_do_setup, g_do_sshx))
+    {
+      g_logger.critical("Failed to set up files");
       goto end;
+    }
   }
   
   if (g_do_deploy)
   {
     if (!deploy(g_config))
+    {
+      g_logger.critical("Failed to deploy");
       goto end;
+    }
   }
 
   if (g_do_quit)
@@ -212,19 +230,28 @@ main(int argc, char ** argv)
   }
 
   if(!setup_hosts(g_config))
+  {
+    g_logger.critical("Failed to setup hosts");
     goto end;
+  }
 
   if (g_do_sshx)
   {
     g_logger.info("Starting xterm-ssh");
     if (!sshx(g_config, g_do_sshx))
+    {
+      g_logger.critical("Failed to start xterm-ssh");
       goto end;
+    }
 
     g_logger.info("Done...sleeping");
     while(true)
     {
       if (!do_command(g_config))
+      {
+        g_logger.critical("Failed to do ssh command");
         goto end;
+      }
 
       NdbSleep_SecSleep(1);
     }
@@ -234,17 +261,26 @@ main(int argc, char ** argv)
  
   g_logger.info("Connecting to hosts...");
   if(!connect_hosts(g_config))
+  {
+    g_logger.critical("Failed to connect to CPCD on hosts");
     goto end;
+  }
 
 #ifndef _WIN32
   if (g_do_start && !g_test_case_filename)
   {
     g_logger.info("Starting server processes: %x", g_do_start);    
     if (!start(g_config, g_do_start))
+    {
+      g_logger.critical("Failed to start server processes");
       goto end;
+    }
     
     if (!setup_db(g_config))
+    {
+      g_logger.critical("Failed to setup database");
       goto end;
+    }
 
     g_logger.info("Done...sleeping");
     while(true)
@@ -267,6 +303,7 @@ main(int argc, char ** argv)
   /**
    * Main loop
    */
+  g_logger.debug("Entering main loop");
   while(!feof(g_test_case_file))
   {
     /**
@@ -278,25 +315,41 @@ main(int argc, char ** argv)
       g_logger.info("(Re)starting server processes...");
 
       if(!stop_processes(g_config, ~0))
-	goto end;
+      {
+        g_logger.critical("Failed to stop all processes");
+        goto end;
+      }
       
       if (!setup_directories(g_config, 2))
-	goto end;
+      {
+        g_logger.critical("Failed to setup directories");
+        goto end;
+      }
       
       if (!setup_files(g_config, 2, 1))
-	goto end;
+      {
+        g_logger.critical("Failed to setup files");
+        goto end;
+      }
       
       if(!setup_hosts(g_config))
+      {
+        g_logger.critical("Failed to setup hosts");
         goto end;
+      }
       
+      g_logger.debug("Setup complete, starting servers");
       if (!start(g_config, p_ndb | p_servers))
       {
-        g_logger.info("Failed to start server processes");
+        g_logger.critical("Failed to start server processes");
         g_logger.info("Gathering logs and saving them as test %u", test_no);
         
         int tmp;
         if(!gather_result(g_config, &tmp))
+        {
+          g_logger.critical("Failed to gather results");
           goto end;
+        }
         
         if(g_report_file != 0)
         {
@@ -319,7 +372,10 @@ main(int argc, char ** argv)
       }
 
       if (!setup_db(g_config))
-	goto end;
+      {
+        g_logger.critical("Failed to setup database");
+        goto end;
+      }
       
       g_logger.info("All servers start completed");
     }
@@ -335,10 +391,16 @@ main(int argc, char ** argv)
     
     // Assign processes to programs
     if(!setup_test_case(g_config, test_case))
+    {
+      g_logger.critical("Failed to setup test case");
       goto end;
+    }
     
     if(!start_processes(g_config, p_clients))
+    {
+      g_logger.critical("Failed to start client processes");
       goto end;
+    }
 
     int result = 0;
     
@@ -347,7 +409,10 @@ main(int argc, char ** argv)
     do 
     {
       if(!update_status(g_config, atrt_process::AP_ALL))
-	goto end;
+      {
+        g_logger.critical("Failed to get updated status for all processes");
+        goto end;
+      }
       
       if(is_running(g_config, p_ndb) != 2)
       {
@@ -375,6 +440,7 @@ main(int argc, char ** argv)
       now = time(0);
       if(now  > (start + test_case.m_max_time))
       {
+        g_logger.debug("Timed out");
 	result = ERR_MAX_TIME_ELAPSED;
 	break;
       }
@@ -384,11 +450,17 @@ main(int argc, char ** argv)
     const time_t elapsed = time(0) - start;
    
     if(!stop_processes(g_config, p_clients))
+    {
+      g_logger.critical("Failed to stop client processes");
       goto end;
+    }
     
     int tmp, *rp = result ? &tmp : &result;
     if(!gather_result(g_config, rp))
+    {
+      g_logger.critical("Failed to gather result after test run");
       goto end;
+    }
     
     g_logger.info("#%d %s(%d)", 
 		  test_no, 
@@ -712,8 +784,14 @@ parse_args(int argc, char** argv)
     return false;
   }
   
+  /* Read username from environment, default to sakila */
   g_user = strdup(getenv("LOGNAME"));
-  
+  if (g_user == 0)
+  {
+    g_user = "sakila";
+    g_logger.info("No default user specified, will use 'sakila'.");
+    g_logger.info("Please set LOGNAME environment variable for other username");
+  }
   return true;
 }
 

=== modified file 'storage/ndb/test/run-test/setup.cpp'
--- a/storage/ndb/test/run-test/setup.cpp	2009-10-07 06:35:51 +0000
+++ b/storage/ndb/test/run-test/setup.cpp	2010-03-17 12:35:51 +0000
@@ -219,7 +219,7 @@ load_process(atrt_config& config, atrt_c
   proc.m_type = type;
   proc.m_host = host_ptr;
   proc.m_save.m_saved = false;
-  proc.m_nodeid= cluster.m_next_nodeid++;
+  proc.m_nodeid= -1;
   proc.m_cluster = &cluster;
   proc.m_options.m_features = 0;
   proc.m_rep_src = 0;
@@ -244,6 +244,8 @@ load_process(atrt_config& config, atrt_c
   const char *groups[] = { 0, 0, 0, 0 };
   switch(type){
   case atrt_process::AP_NDB_MGMD:
+    proc.m_nodeid= cluster.m_next_nodeid++; // always specify node-id
+
     groups[0] = "cluster_config";
     buf[1].assfmt("cluster_config.ndb_mgmd.%u", idx);
     groups[1] = buf[1].c_str();
@@ -251,6 +253,9 @@ load_process(atrt_config& config, atrt_c
     argv[argc++] = buf[0].c_str();
     break;
   case atrt_process::AP_NDBD: 
+    if (g_fix_nodeid)
+      proc.m_nodeid= cluster.m_next_nodeid++;
+
     groups[0] = "cluster_config";
     buf[1].assfmt("cluster_config.ndbd.%u", idx);
     groups[1] = buf[1].c_str();
@@ -258,6 +263,9 @@ load_process(atrt_config& config, atrt_c
     argv[argc++] = buf[0].c_str();
     break;
   case atrt_process::AP_MYSQLD:
+    if (g_fix_nodeid)
+      proc.m_nodeid= cluster.m_next_nodeid++;
+
     groups[0] = "mysqld";
     groups[1] = "mysql_cluster";
     buf[0].assfmt("--defaults-group-suffix=.%u%s",idx,cluster.m_name.c_str());
@@ -268,6 +276,8 @@ load_process(atrt_config& config, atrt_c
     groups[0] = buf[0].c_str();
     break;
   case atrt_process::AP_NDB_API:
+    if (g_fix_nodeid)
+      proc.m_nodeid= cluster.m_next_nodeid++;
     break;
   default:
     g_logger.critical("Unhandled process type: %d", type);

=== modified file 'storage/ndb/test/src/NdbRestarts.cpp'
--- a/storage/ndb/test/src/NdbRestarts.cpp	2009-05-28 09:12:44 +0000
+++ b/storage/ndb/test/src/NdbRestarts.cpp	2010-03-19 14:15:57 +0000
@@ -23,24 +23,25 @@
 #include <kernel/ndb_limits.h>
 #include <signaldata/DumpStateOrd.hpp>
 #include <NdbEnv.h>
+#include <NDBT_Test.hpp>
 
+#define F_ARGS NDBT_Context* ctx, NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart
 
-int restartRandomNodeGraceful(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartRandomNodeAbort(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartRandomNodeError(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartRandomNodeInitial(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartNFDuringNR(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartMasterNodeError(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int twoNodeFailure(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int fiftyPercentFail(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int twoMasterNodeFailure(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartAllNodesGracfeul(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartAllNodesAbort(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartAllNodesError9999(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int fiftyPercentStopAndWait(NdbRestarter&, const NdbRestarts::NdbRestart*);
-int restartNodeDuringLCP(NdbRestarter& _restarter,
-			 const NdbRestarts::NdbRestart* _restart);
-int stopOnError(NdbRestarter&, const NdbRestarts::NdbRestart*);
+int restartRandomNodeGraceful(F_ARGS);
+int restartRandomNodeAbort(F_ARGS);
+int restartRandomNodeError(F_ARGS);
+int restartRandomNodeInitial(F_ARGS);
+int restartNFDuringNR(F_ARGS);
+int restartMasterNodeError(F_ARGS);
+int twoNodeFailure(F_ARGS);
+int fiftyPercentFail(F_ARGS);
+int twoMasterNodeFailure(F_ARGS);
+int restartAllNodesGracfeul(F_ARGS);
+int restartAllNodesAbort(F_ARGS);
+int restartAllNodesError9999(F_ARGS);
+int fiftyPercentStopAndWait(F_ARGS);
+int restartNodeDuringLCP(F_ARGS);
+int stopOnError(F_ARGS);
 int getRandomNodeId(NdbRestarter& _restarter);
 
 /**
@@ -240,7 +241,8 @@ const NdbRestarts::NdbRestart* NdbRestar
 }
 
 
-int NdbRestarts::executeRestart(const NdbRestarts::NdbRestart* _restart, 
+int NdbRestarts::executeRestart(NDBT_Context* ctx,
+                                const NdbRestarts::NdbRestart* _restart,
 				unsigned int _timeout){
   // Check that there are enough nodes in the cluster
   // for this test
@@ -257,7 +259,7 @@ int NdbRestarts::executeRestart(const Nd
     return NDBT_FAILED;
   }
   
-  int res = _restart->m_restartFunc(restarter, _restart);
+  int res = _restart->m_restartFunc(ctx, restarter, _restart);
 
   // Sleep a little waiting for nodes to react to command
   NdbSleep_SecSleep(2);
@@ -277,23 +279,25 @@ int NdbRestarts::executeRestart(const Nd
   return res;
 } 
 
-int NdbRestarts::executeRestart(int _num,
+int NdbRestarts::executeRestart(NDBT_Context* ctx,
+                                int _num,
 				unsigned int _timeout){
   const NdbRestarts::NdbRestart* r = getRestart(_num);
   if (r == NULL)
     return NDBT_FAILED;
 
-  int res = executeRestart(r, _timeout);
+  int res = executeRestart(ctx, r, _timeout);
   return res;
 }
 
-int NdbRestarts::executeRestart(const char* _name,
+int NdbRestarts::executeRestart(NDBT_Context* ctx,
+                                const char* _name,
 				unsigned int _timeout){
   const NdbRestarts::NdbRestart* r = getRestart(_name);
   if (r == NULL)
     return NDBT_FAILED;
 
-  int res = executeRestart(r, _timeout);
+  int res = executeRestart(ctx, r, _timeout);
   return res;
 }
 
@@ -356,8 +360,7 @@ const NdbRestarts::NdbErrorInsert* NdbRe
 
 
 
-int restartRandomNodeGraceful(NdbRestarter& _restarter, 
-			      const NdbRestarts::NdbRestart* _restart){
+int restartRandomNodeGraceful(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int randomId = myRandom48(_restarter.getNumDbNodes());
@@ -371,8 +374,7 @@ int restartRandomNodeGraceful(NdbRestart
   return NDBT_OK;
 }
 
-int restartRandomNodeAbort(NdbRestarter& _restarter, 
-			      const NdbRestarts::NdbRestart* _restart){
+int restartRandomNodeAbort(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int randomId = myRandom48(_restarter.getNumDbNodes());
@@ -386,8 +388,7 @@ int restartRandomNodeAbort(NdbRestarter&
   return NDBT_OK;
 }
 
-int restartRandomNodeError(NdbRestarter& _restarter, 
-			   const NdbRestarts::NdbRestart* _restart){
+int restartRandomNodeError(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int randomId = myRandom48(_restarter.getNumDbNodes());
@@ -401,8 +402,7 @@ int restartRandomNodeError(NdbRestarter&
   return NDBT_OK;
 }
 
-int restartMasterNodeError(NdbRestarter& _restarter, 
-			   const NdbRestarts::NdbRestart* _restart){
+int restartMasterNodeError(F_ARGS){
 
   int nodeId = _restarter.getDbNodeId(0);
   
@@ -414,8 +414,7 @@ int restartMasterNodeError(NdbRestarter&
   return NDBT_OK;
 }
 
-int restartRandomNodeInitial(NdbRestarter& _restarter, 
-			     const NdbRestarts::NdbRestart* _restart){
+int restartRandomNodeInitial(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int randomId = myRandom48(_restarter.getNumDbNodes());
@@ -429,8 +428,7 @@ int restartRandomNodeInitial(NdbRestarte
   return NDBT_OK;
 }
 
-int twoNodeFailure(NdbRestarter& _restarter, 
-		   const NdbRestarts::NdbRestart* _restart){
+int twoNodeFailure(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int randomId = myRandom48(_restarter.getNumDbNodes());
@@ -467,8 +465,7 @@ int twoNodeFailure(NdbRestarter& _restar
   return NDBT_OK;
 }
 
-int twoMasterNodeFailure(NdbRestarter& _restarter, 
-			 const NdbRestarts::NdbRestart* _restart){
+int twoMasterNodeFailure(F_ARGS){
 
   int n[2];
   n[0] = _restarter.getMasterNodeId();  
@@ -526,8 +523,7 @@ int get50PercentOfNodes(NdbRestarter& re
   return num50Percent;
 }
 
-int fiftyPercentFail(NdbRestarter& _restarter, 
-			    const NdbRestarts::NdbRestart* _restart){
+int fiftyPercentFail(F_ARGS){
 
 
   int nodes[MAX_NDB_NODES];
@@ -553,8 +549,7 @@ int fiftyPercentFail(NdbRestarter& _rest
 }
 
 
-int restartAllNodesGracfeul(NdbRestarter& _restarter, 
-			    const NdbRestarts::NdbRestart* _restart){
+int restartAllNodesGracfeul(F_ARGS){
 
   g_info << _restart->m_name  << endl;
 
@@ -566,8 +561,7 @@ int restartAllNodesGracfeul(NdbRestarter
 
 }
 
-int restartAllNodesAbort(NdbRestarter& _restarter, 
-			 const NdbRestarts::NdbRestart* _restart){
+int restartAllNodesAbort(F_ARGS){
   
   g_info << _restart->m_name  << endl;
 
@@ -578,8 +572,7 @@ int restartAllNodesAbort(NdbRestarter& _
   return NDBT_OK;
 }
 
-int restartAllNodesError9999(NdbRestarter& _restarter, 
-			     const NdbRestarts::NdbRestart* _restart){
+int restartAllNodesError9999(F_ARGS){
   
   g_info << _restart->m_name <<  endl;
 
@@ -602,8 +595,7 @@ int restartAllNodesError9999(NdbRestarte
   return NDBT_OK;
 }
 
-int fiftyPercentStopAndWait(NdbRestarter& _restarter, 
-			    const NdbRestarts::NdbRestart* _restart){
+int fiftyPercentStopAndWait(F_ARGS){
 
   int nodes[MAX_NDB_NODES];
   int numNodes = get50PercentOfNodes(_restarter, nodes);
@@ -667,8 +659,7 @@ NFDuringNR_codes[] = {
   5002
 };
 
-int restartNFDuringNR(NdbRestarter& _restarter, 
-			   const NdbRestarts::NdbRestart* _restart){
+int restartNFDuringNR(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int i;
@@ -718,7 +709,7 @@ int restartNFDuringNR(NdbRestarter& _res
   if(NdbEnv_GetEnv("USER", buf, 256) == 0 || strcmp(buf, "ejonore") != 0)
     return NDBT_OK;
   
-  for(i = 0; i<sz; i++){
+  for(i = 0; i<sz && !ctx->isTestStopped(); i++){
     const int randomId = myRandom48(_restarter.getNumDbNodes());
     int nodeId = _restarter.getDbNodeId(randomId);
     const int error = NFDuringNR_codes[i];
@@ -796,8 +787,7 @@ NRDuringLCP_NonMaster_codes[] = {
   7018  // Crash in !master when changing state to LCP_TAB_SAVED
 };
 
-int restartNodeDuringLCP(NdbRestarter& _restarter, 
-			 const NdbRestarts::NdbRestart* _restart) {
+int restartNodeDuringLCP(F_ARGS) {
   int i;
   // Master
   int val = DumpStateOrd::DihMinTimeBetweenLCP;
@@ -883,8 +873,7 @@ int restartNodeDuringLCP(NdbRestarter& _
   return NDBT_OK;
 }
 
-int stopOnError(NdbRestarter& _restarter, 
-		const NdbRestarts::NdbRestart* _restart){
+int stopOnError(F_ARGS){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
 

=== modified file 'storage/ndb/tools/waiter.cpp'
--- a/storage/ndb/tools/waiter.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/tools/waiter.cpp	2010-03-29 14:16:24 +0000
@@ -16,7 +16,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-
+#include <time.h>
 #include <ndb_global.h>
 #include <ndb_opts.h>
 
@@ -43,6 +43,7 @@ static int _no_contact = 0;
 static int _not_started = 0;
 static int _single_user = 0;
 static int _timeout = 120;
+static const char* _wait_nodes = 0;
 static const char* _nowait_nodes = 0;
 static NdbNodeBitmask nowait_nodes_bitmask;
 
@@ -64,8 +65,11 @@ static struct my_option my_long_options[
   { "timeout", 't', "Timeout to wait in seconds",
     (uchar**) &_timeout, (uchar**) &_timeout, 0,
     GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, 
+  { "wait-nodes", 'w', "Node ids to wait on, e.g. '1,2-4'",
+    (uchar**) &_wait_nodes, (uchar**) &_wait_nodes, 0,
+    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   { "nowait-nodes", OPT_NOWAIT_NODES, 
-    "Nodes that will not be waited for",
+    "Nodes that will not be waited for, e.g. '2,3,4-7'",
     (uchar**) &_nowait_nodes, (uchar**) &_nowait_nodes, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@@ -135,6 +139,32 @@ int main(int argc, char** argv){
     }
   }
 
+  if (_wait_nodes)
+  {
+    if (_nowait_nodes)
+    {
+      ndbout_c("Can not set both wait-nodes and nowait-nodes.");
+      exit(-1);
+    }
+
+    int res = nowait_nodes_bitmask.parseMask(_wait_nodes);
+    if (res == -2 || (res > 0 && nowait_nodes_bitmask.get(0)))
+    {
+      ndbout_c("Invalid nodeid specified in wait-nodes: %s",
+               _wait_nodes);
+      exit(-1);
+    }
+    else if (res < 0)
+    {
+      ndbout_c("Unable to parse wait-nodes argument: %s",
+               _wait_nodes);
+      exit(-1);
+    }
+
+    // Don't wait for any other nodes than the ones we have set explicitly
+    nowait_nodes_bitmask.bitNOT();
+  }
+
   if (waitClusterStatus(_hostName, wait_status) != 0)
     return NDBT_ProgramExit(NDBT_FAILED);
   return NDBT_ProgramExit(NDBT_OK);
@@ -212,6 +242,28 @@ getStatus(){
   return -1;
 }
 
+char*
+getTimeAsString(char* pStr)
+{
+  time_t now;
+  now= ::time((time_t*)NULL);
+
+  struct tm* tm_now;
+#ifdef NDB_WIN32
+  tm_now = localtime(&now);
+#else
+  tm_now = ::localtime(&now); //uses the "current" timezone
+#endif
+
+  BaseString::snprintf(pStr, 9,
+	   "%02d:%02d:%02d",
+	   tm_now->tm_hour,
+	   tm_now->tm_min,
+	   tm_now->tm_sec);
+
+  return pStr;
+}
+
 static int
 waitClusterStatus(const char* _addr,
 		  ndb_mgm_node_status _status)
@@ -316,8 +368,10 @@ waitClusterStatus(const char* _addr,

     }
 
     if (!allInState) {
-      g_info << "Waiting for cluster enter state "
-             << ndb_mgm_get_node_status_string(_status)<< endl;
+      char time[9];
+      g_info << "[" << getTimeAsString(time) << "] "
+             << "Waiting for cluster enter state "
+             << ndb_mgm_get_node_status_string(_status) << endl;
     }
 
     attempts++;

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20100420130000-gsu6vhh9b35zpjyd.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3465)Magnus Blåudd20 Apr