List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:February 2 2011 3:17pm
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3414 to 3415)
View as plain text  
 3415 Ole John Aske	2011-02-02 [merge]
      merge from mysql-5.1-telco-7.0

    added:
      mysql-test/suite/ndb/r/ndb_restore_rewrite_db.result
      mysql-test/suite/ndb/r/ndbinfo_cache.result
      mysql-test/suite/ndb/t/ndb_restore_rewrite_db.test
      mysql-test/suite/ndb/t/ndbinfo_cache.test
    modified:
      CMakeLists.txt
      cmake/mysql_version.cmake
      mysql-test/mysql-test-run.pl
      mysql-test/r/join_outer.result
      mysql-test/r/subselect.result
      mysql-test/suite/ndb/r/ndb_alter_table_online.result
      mysql-test/suite/ndb/r/ndb_basic.result
      mysql-test/suite/ndb/r/ndb_dd_basic.result
      mysql-test/suite/ndb/r/ndb_load.result
      mysql-test/suite/ndb/r/ndb_partition_error.result
      mysql-test/suite/ndb/r/ndb_partition_range.result
      mysql-test/suite/ndb/r/ndb_restore.result
      mysql-test/suite/ndb/r/ndb_temporary.result
      mysql-test/suite/ndb/t/ndb_alter_table_online.test
      mysql-test/suite/ndb/t/ndb_basic.test
      mysql-test/suite/ndb/t/ndb_dd_alter.test
      mysql-test/suite/ndb/t/ndb_dd_basic.test
      mysql-test/suite/ndb/t/ndb_load.test
      mysql-test/suite/ndb/t/ndb_partition_error.test
      mysql-test/suite/ndb/t/ndb_restore.test
      mysql-test/suite/ndb/t/ndb_temporary.test
      mysql-test/suite/ndb_team/t/ndb_dd_backuprestore.test
      mysql-test/t/join_outer.test
      mysql-test/t/subselect.test
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_tables.h
      sql/ha_ndbinfo.h
      sql/rpl_injector.cc
      sql/rpl_injector.h
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_select.cc
      sql/sql_table.cc
      storage/ndb/docs/doxygen/Doxyfile.mgmapi
      storage/ndb/docs/doxygen/Doxyfile.ndb
      storage/ndb/docs/doxygen/Doxyfile.ndbapi
      storage/ndb/docs/doxygen/Doxyfile.odbc
      storage/ndb/docs/doxygen/postdoxy.pl
      storage/ndb/docs/doxygen/predoxy.pl
      storage/ndb/include/CMakeLists.txt
      storage/ndb/include/kernel/signaldata/ConfigChange.hpp
      storage/ndb/include/kernel/signaldata/GCP.hpp
      storage/ndb/include/mgmcommon/IPCConfig.hpp
      storage/ndb/include/ndb_version.h.in
      storage/ndb/include/ndbapi/NdbDictionary.hpp
      storage/ndb/include/ndbapi/ndb_cluster_connection.hpp
      storage/ndb/include/portlib/NdbDir.hpp
      storage/ndb/include/portlib/NdbMutex.h
      storage/ndb/include/portlib/ndb_daemon.h
      storage/ndb/include/util/HashMap.hpp
      storage/ndb/ndbjtie/Makefile.defaults
      storage/ndb/ndbjtie/env.properties
      storage/ndb/ndbjtie/src/jtie/jtie/Wrapper.java
      storage/ndb/src/common/debugger/SignalLoggerManager.cpp
      storage/ndb/src/common/debugger/signaldata/CreateTrigImpl.cpp
      storage/ndb/src/common/logger/message.h
      storage/ndb/src/common/mgmcommon/IPCConfig.cpp
      storage/ndb/src/common/portlib/NdbCondition.c
      storage/ndb/src/common/portlib/NdbDir.cpp
      storage/ndb/src/common/portlib/NdbMutex.c
      storage/ndb/src/common/portlib/ndb_daemon.cc
      storage/ndb/src/common/util/ndb_opts.c
      storage/ndb/src/common/util/require.c
      storage/ndb/src/kernel/CMakeLists.txt
      storage/ndb/src/kernel/angel.cpp
      storage/ndb/src/kernel/angel.hpp
      storage/ndb/src/kernel/blocks/CMakeLists.txt
      storage/ndb/src/kernel/blocks/ERROR_codes.txt
      storage/ndb/src/kernel/blocks/backup/CMakeLists.txt
      storage/ndb/src/kernel/blocks/dbdict/CMakeLists.txt
      storage/ndb/src/kernel/blocks/dbdih/CMakeLists.txt
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
      storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.hpp
      storage/ndb/src/kernel/blocks/dblqh/CMakeLists.txt
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
      storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp
      storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp
      storage/ndb/src/kernel/blocks/dbtup/test_dynbm.c
      storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp
      storage/ndb/src/kernel/blocks/lgman.cpp
      storage/ndb/src/kernel/blocks/tsman.cpp
      storage/ndb/src/kernel/blocks/tsman.hpp
      storage/ndb/src/kernel/ndbd.cpp
      storage/ndb/src/kernel/ndbd.hpp
      storage/ndb/src/kernel/vm/SimulatedBlock.hpp
      storage/ndb/src/kernel/vm/dummy_mt.cpp
      storage/ndb/src/kernel/vm/dummy_nonmt.cpp
      storage/ndb/src/libndb.ver.in
      storage/ndb/src/mgmclient/CMakeLists.txt
      storage/ndb/src/mgmclient/CommandInterpreter.cpp
      storage/ndb/src/mgmsrv/CMakeLists.txt
      storage/ndb/src/mgmsrv/ConfigManager.cpp
      storage/ndb/src/mgmsrv/ConfigManager.hpp
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp
      storage/ndb/src/ndbapi/ClusterMgr.cpp
      storage/ndb/src/ndbapi/NdbDictionary.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
      storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
      storage/ndb/src/ndbapi/NdbScanOperation.cpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
      storage/ndb/src/ndbapi/trp_client.cpp
      storage/ndb/src/ndbapi/trp_client.hpp
      storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp
      storage/ndb/test/ndbapi/slow_select.cpp
      storage/ndb/test/ndbapi/testBasic.cpp
      storage/ndb/test/ndbapi/testBitfield.cpp
      storage/ndb/test/ndbapi/testDict.cpp
      storage/ndb/test/ndbapi/testLcp.cpp
      storage/ndb/test/run-test/16node-tests.txt
      storage/ndb/test/run-test/CMakeLists.txt
      storage/ndb/test/run-test/atrt-analyze-result.sh
      storage/ndb/test/run-test/atrt-backtrace.sh
      storage/ndb/test/run-test/atrt-gather-result.sh
      storage/ndb/test/run-test/atrt-mysql-test-run
      storage/ndb/test/run-test/atrt-mysqltest
      storage/ndb/test/run-test/atrt-setup.sh
      storage/ndb/test/run-test/atrt-testBackup
      storage/ndb/test/run-test/autotest-boot.sh
      storage/ndb/test/run-test/autotest-run.sh
      storage/ndb/test/run-test/basic.txt
      storage/ndb/test/run-test/check-tests.sh
      storage/ndb/test/run-test/create_mtr_suites.pl
      storage/ndb/test/run-test/daily-basic-tests.txt
      storage/ndb/test/run-test/daily-devel-tests.txt
      storage/ndb/test/run-test/files.cpp
      storage/ndb/test/run-test/make-config.sh
      storage/ndb/test/run-test/make-html-reports.sh
      storage/ndb/test/run-test/make-index.sh
      storage/ndb/test/run-test/ndb-autotest.sh
      storage/ndb/test/run-test/setup.cpp
      storage/ndb/test/run-test/upgrade-boot.sh
      storage/ndb/test/sql/BANK.sql
      storage/ndb/test/sql/T1.sql
      storage/ndb/test/sql/test_create_drop.pl
      storage/ndb/test/sql/test_range_bounds.pl
      storage/ndb/test/tools/log_listner.cpp
      storage/ndb/tools/CMakeLists.txt
      storage/ndb/tools/clean-links.sh
      storage/ndb/tools/make-errors.pl
      storage/ndb/tools/make-links.sh
      storage/ndb/tools/ndb_error_reporter
      storage/ndb/tools/restore/Restore.cpp
      storage/ndb/tools/restore/consumer_restore.cpp
      storage/ndb/tools/restore/restore_main.cpp
 3414 Jonas Oreland	2011-01-26
      ndb - spj - change so that 4word scan-tabconf is requested by API for easier upgrade handling

    modified:
      storage/ndb/include/kernel/signaldata/ScanTab.hpp
      storage/ndb/include/ndb_version.h.in
      storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbTransactionScan.cpp
=== modified file 'CMakeLists.txt'
--- a/CMakeLists.txt	2010-08-30 14:10:58 +0000
+++ b/CMakeLists.txt	2011-01-26 09:21:19 +0000
@@ -23,6 +23,14 @@ PROJECT(MySql)
 # This reads user configuration, generated by configure.js.
 INCLUDE(win/configure.data)
 
+# MCP_CMAKE_COMPATIBILITY_55 ->
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
+INCLUDE(mysql_version)
+INCLUDE(install_layout)
+INCLUDE(install_macros)
+INCLUDE(mysql_add_executable)
+# MCP_CMAKE_COMPATIBILITY_55 <-
+
 # Hardcode support for CSV storage engine
 SET(WITH_CSV_STORAGE_ENGINE TRUE)
 

=== modified file 'cmake/mysql_version.cmake'
--- a/cmake/mysql_version.cmake	2010-11-09 14:33:15 +0000
+++ b/cmake/mysql_version.cmake	2011-01-24 12:27:41 +0000
@@ -41,7 +41,11 @@ MACRO(GET_MYSQL_VERSION)
         STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}")
         IF(NOT VERSION_STRING)
           FILE(STRINGS  configure.in  str REGEX "AC_INIT\\(")
+          IF(NOT MCP_BUG57843)
+            STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-.a-zAZ0-9]+" VERSION_STRING "${str}")
+          ELSEIF()
           STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zAZ0-9]+" VERSION_STRING "${str}")
+          ENDIF()
         ENDIF()
       ENDIF()
     ENDIF()

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2010-11-15 14:03:22 +0000
+++ b/mysql-test/mysql-test-run.pl	2011-01-21 09:51:07 +0000
@@ -461,7 +461,6 @@ sub run_test_server ($$$) {
   my $max_ndb= $ENV{MTR_MAX_NDB} || $childs / 2;
   $max_ndb = $childs if $max_ndb > $childs;
   $max_ndb = 1 if $max_ndb < 1;
-  print "max_ndb: $max_ndb\n";
   my $num_ndb_tests= 0;
 
   my $completed= [];

=== modified file 'mysql-test/r/join_outer.result'
--- a/mysql-test/r/join_outer.result	2011-01-17 12:08:49 +0000
+++ b/mysql-test/r/join_outer.result	2011-02-02 15:16:35 +0000
@@ -1551,4 +1551,146 @@ WHERE t3.pk2 = t2.i
 IS UNKNOWN;
 I	I
 DROP TABLE t1,t2,t3;
+#
+# Bug#58490: Incorrect result in multi level OUTER JOIN
+# in combination with IS NULL
+#
+CREATE TABLE t1 (i INT NOT NULL);
+INSERT INTO t1 VALUES (0),    (2),(3),(4);
+CREATE TABLE t2 (i INT NOT NULL);
+INSERT INTO t2 VALUES (0),(1),    (3),(4);
+CREATE TABLE t3 (i INT NOT NULL);
+INSERT INTO t3 VALUES (0),(1),(2),    (4);
+CREATE TABLE t4 (i INT NOT NULL);
+INSERT INTO t4 VALUES (0),(1),(2),(3)   ;
+SELECT * FROM
+t1 LEFT JOIN
+( t2 LEFT JOIN
+( t3 LEFT JOIN
+t4
+ON t4.i = t3.i
+)
+ON t3.i = t2.i
+)
+ON t2.i = t1.i
+;
+i	i	i	i
+0	0	0	0
+2	NULL	NULL	NULL
+3	3	NULL	NULL
+4	4	4	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( t2 LEFT JOIN
+( t3 LEFT JOIN
+t4
+ON t4.i = t3.i
+)
+ON t3.i = t2.i
+)
+ON t2.i = t1.i
+WHERE t4.i IS NULL;
+i	i	i	i
+2	NULL	NULL	NULL
+3	3	NULL	NULL
+4	4	4	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i
+2	NULL	NULL
+3	3	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN t4
+ON t4.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i
+2	NULL	NULL	NULL
+3	3	NULL	3
+4	NULL	NULL	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i)
+ON t4a.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i	i
+2	NULL	NULL	NULL	NULL
+3	3	NULL	3	3
+4	NULL	NULL	NULL	NULL
+SELECT * FROM
+t1 LEFT JOIN
+( ( t2 LEFT JOIN
+t3
+ON t3.i = t2.i
+)
+JOIN (t4 AS t4a, t4 AS t4b)
+ON t4a.i=t2.i
+)
+ON t2.i = t1.i
+WHERE t3.i IS NULL;
+i	i	i	i	i
+2	NULL	NULL	NULL	NULL
+3	3	NULL	3	0
+3	3	NULL	3	1
+3	3	NULL	3	2
+3	3	NULL	3	3
+4	NULL	NULL	NULL	NULL
+DROP TABLE t1,t2,t3,t4;
+#
+# Bug#49322(Duplicate): Server is adding extra NULL row
+# on processing a WHERE clause
+#
+CREATE TABLE h (pk INT NOT NULL, col_int_key INT);
+INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8);
+CREATE TABLE m (pk INT NOT NULL, col_int_key INT);
+INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9);
+CREATE TABLE k (pk INT NOT NULL, col_int_key INT);
+INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5);
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key;
+pk
+2
+4
+2
+4
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key
+WHERE TABLE1.pk IS NULL;
+pk
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
+DROP TABLE h,m,k;
 End of 5.1 tests

=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2011-01-17 12:08:49 +0000
+++ b/mysql-test/r/subselect.result	2011-02-02 15:16:35 +0000
@@ -4785,4 +4785,30 @@ HAVING t2s.i = 999
 ) IS UNKNOWN;
 i
 DROP TABLE t1,t1s,t2s;
+#
+# Bug #56690  Wrong results with subquery with 
+# GROUP BY inside < ANY clause
+#
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+CREATE TABLE t2 (
+pk INT NOT NULL PRIMARY KEY,
+number INT,
+KEY key_number (number)
+);
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+pk	number
+8	8
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+pk	number
+8	8
+DROP TABLE t1,t2;
 End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/r/ndb_alter_table_online.result'
--- a/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2009-10-09 15:48:57 +0000
+++ b/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2011-01-21 10:29:46 +0000
@@ -691,7 +691,10 @@ SELECT COUNT(*) FROM t1;
 COUNT(*)
 16384
 ALTER ONLINE TABLE t1 ADD b INT;
-********************
-* Cleanup Section
-********************
 DROP TABLE t1, ndb_show_tables_results;
+create table t1 ( c499 int, c498 int, c497 int, c496 int, c495 int, c494 int, c493 int, c492 int, c491 int, c490 int, c489 int, c488 int, c487 int, c486 int, c485 int, c484 int, c483 int, c482 int, c481 int, c480 int, c479 int, c478 int, c477 int, c476 int, c475 int, c474 int, c473 int, c472 int, c471 int, c470 int, c469 int, c468 int, c467 int, c466 int, c465 int, c464 int, c463 int, c462 int, c461 int, c460 int, c459 int, c458 int, c457 int, c456 int, c455 int, c454 int, c453 int, c452 int, c451 int, c450 int, c449 int, c448 int, c447 int, c446 int, c445 int, c444 int, c443 int, c442 int, c441 int, c440 int, c439 int, c438 int, c437 int, c436 int, c435 int, c434 int, c433 int, c432 int, c431 int, c430 int, c429 int, c428 int, c427 int, c426 int, c425 int, c424 int, c423 int, c422 int, c421 int, c420 int, c419 int, c418 int, c417 int, c416 int, c415 int, c414 int, c413 int, c412 int, c411 int, c410 int, c409 int, c408 int, c407 int, c406 int, c405 int, c404 int, c403 int, c
 402 int, c401 int, c400 int, c399 int, c398 int, c397 int, c396 int, c395 int, c394 int, c393 int, c392 int, c391 int, c390 int, c389 int, c388 int, c387 int, c386 int, c385 int, c384 int, c383 int, c382 int, c381 int, c380 int, c379 int, c378 int, c377 int, c376 int, c375 int, c374 int, c373 int, c372 int, c371 int, c370 int, c369 int, c368 int, c367 int, c366 int, c365 int, c364 int, c363 int, c362 int, c361 int, c360 int, c359 int, c358 int, c357 int, c356 int, c355 int, c354 int, c353 int, c352 int, c351 int, c350 int, c349 int, c348 int, c347 int, c346 int, c345 int, c344 int, c343 int, c342 int, c341 int, c340 int, c339 int, c338 int, c337 int, c336 int, c335 int, c334 int, c333 int, c332 int, c331 int, c330 int, c329 int, c328 int, c327 int, c326 int, c325 int, c324 int, c323 int, c322 int, c321 int, c320 int, c319 int, c318 int, c317 int, c316 int, c315 int, c314 int, c313 int, c312 int, c311 int, c310 int, c309 int, c308 int, c307 int, c306 int, c305 int, c304 int, 
 c303 int, c302 int, c301 int, c300 int, c299 int, c298 int, c297 int, c296 int, c295 int, c294 int, c293 int, c292 int, c291 int, c290 int, c289 int, c288 int, c287 int, c286 int, c285 int, c284 int, c283 int, c282 int, c281 int, c280 int, c279 int, c278 int, c277 int, c276 int, c275 int, c274 int, c273 int, c272 int, c271 int, c270 int, c269 int, c268 int, c267 int, c266 int, c265 int, c264 int, c263 int, c262 int, c261 int, c260 int, c259 int, c258 int, c257 int, c256 int, c255 int, c254 int, c253 int, c252 int, c251 int, c250 int, c249 int, c248 int, c247 int, c246 int, c245 int, c244 int, c243 int, c242 int, c241 int, c240 int, c239 int, c238 int, c237 int, c236 int, c235 int, c234 int, c233 int, c232 int, c231 int, c230 int, c229 int, c228 int, c227 int, c226 int, c225 int, c224 int, c223 int, c222 int, c221 int, c220 int, c219 int, c218 int, c217 int, c216 int, c215 int, c214 int, c213 int, c212 int, c211 int, c210 int, c209 int, c208 int, c207 int, c206 int, c205 int,
  c204 int, c203 int, c202 int, c201 int, c200 int, c199 int, c198 int, c197 int, c196 int, c195 int, c194 int, c193 int, c192 int, c191 int, c190 int, c189 int, c188 int, c187 int, c186 int, c185 int, c184 int, c183 int, c182 int, c181 int, c180 int, c179 int, c178 int, c177 int, c176 int, c175 int, c174 int, c173 int, c172 int, c171 int, c170 int, c169 int, c168 int, c167 int, c166 int, c165 int, c164 int, c163 int, c162 int, c161 int, c160 int, c159 int, c158 int, c157 int, c156 int, c155 int, c154 int, c153 int, c152 int, c151 int, c150 int, c149 int, c148 int, c147 int, c146 int, c145 int, c144 int, c143 int, c142 int, c141 int, c140 int, c139 int, c138 int, c137 int, c136 int, c135 int, c134 int, c133 int, c132 int, c131 int, c130 int, c129 int, c128 int, c127 int, c126 int, c125 int, c124 int, c123 int, c122 int, c121 int, c120 int, c119 int, c118 int, c117 int, c116 int, c115 int, c114 int, c113 int, c112 int, c111 int, c110 int, c109 int, c108 int, c107 int, c106 int
 , c105 int, c104 int, c103 int, c102 int, c101 int, c100 int, c99 int, c98 int, c97 int, c96 int, c95 int, c94 int, c93 int, c92 int, c91 int, c90 int, c89 int, c88 int, c87 int, c86 int, c85 int, c84 int, c83 int, c82 int, c81 int, c80 int, c79 int, c78 int, c77 int, c76 int, c75 int, c74 int, c73 int, c72 int, c71 int, c70 int, c69 int, c68 int, c67 int, c66 int, c65 int, c64 int, c63 int, c62 int, c61 int, c60 int, c59 int, c58 int, c57 int, c56 int, c55 int, c54 int, c53 int, c52 int, c51 int, c50 int, c49 int, c48 int, c47 int, c46 int, c45 int, c44 int, c43 int, c42 int, c41 int, c40 int, c39 int, c38 int, c37 int, c36 int, c35 int, c34 int, c33 int, c32 int, c31 int, c30 int, c29 int, c28 int, c27 int, c26 int, c25 int, c24 int, c23 int, c22 int, c21 int, c20 int, c19 int, c18 int, c17 int, c16 int, c15 int, c14 int, c13 int, c12 int, c11 int, c10 int, c9 int, c8 int, c7 int, c6 int, c5 int, c4 int, c3 int, c2 int, c1 int, primary key using hash(c1)) engine=ndb;
+insert into t1 (c1) values (1), (2), (3);
+alter offline table t1 modify c1 int auto_increment;
+alter online table t1 add column c500 bit(1) column_format DYNAMIC;
+delete from t1;
+drop table t1;

=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_basic.result	2011-01-06 21:19:05 +0000
+++ b/mysql-test/suite/ndb/r/ndb_basic.result	2011-02-02 15:16:35 +0000
@@ -1,12 +1,5 @@
 DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
 drop database if exists mysqltest;
-CREATE TABLE t1 (
-pk1 INT NOT NULL PRIMARY KEY,
-attr1 INT NOT NULL,
-attr2 INT,
-attr3 VARCHAR(10)
-) ENGINE=ndbcluster;
-drop table t1;
 SHOW GLOBAL STATUS LIKE 'ndb\_%';
 Variable_name	Value
 Ndb_cluster_node_id	#
@@ -488,514 +481,10 @@ select * from t1 where b IS NOT NULL;
 a	b
 1	
 drop table t1;
-create table t1 (
-c1 int,
-c2 int,
-c3 int,
-c4 int,
-c5 int,
-c6 int,
-c7 int,
-c8 int,
-c9 int,
-c10 int,
-c11 int,
-c12 int,
-c13 int,
-c14 int,
-c15 int,
-c16 int,
-c17 int,
-c18 int,
-c19 int,
-c20 int,
-c21 int,
-c22 int,
-c23 int,
-c24 int,
-c25 int,
-c26 int,
-c27 int,
-c28 int,
-c29 int,
-c30 int,
-c31 int,
-c32 int,
-c33 int,
-c34 int,
-c35 int,
-c36 int,
-c37 int,
-c38 int,
-c39 int,
-c40 int,
-c41 int,
-c42 int,
-c43 int,
-c44 int,
-c45 int,
-c46 int,
-c47 int,
-c48 int,
-c49 int,
-c50 int,
-c51 int,
-c52 int,
-c53 int,
-c54 int,
-c55 int,
-c56 int,
-c57 int,
-c58 int,
-c59 int,
-c60 int,
-c61 int,
-c62 int,
-c63 int,
-c64 int,
-c65 int,
-c66 int,
-c67 int,
-c68 int,
-c69 int,
-c70 int,
-c71 int,
-c72 int,
-c73 int,
-c74 int,
-c75 int,
-c76 int,
-c77 int,
-c78 int,
-c79 int,
-c80 int,
-c81 int,
-c82 int,
-c83 int,
-c84 int,
-c85 int,
-c86 int,
-c87 int,
-c88 int,
-c89 int,
-c90 int,
-c91 int,
-c92 int,
-c93 int,
-c94 int,
-c95 int,
-c96 int,
-c97 int,
-c98 int,
-c99 int,
-c100 int,
-c101 int,
-c102 int,
-c103 int,
-c104 int,
-c105 int,
-c106 int,
-c107 int,
-c108 int,
-c109 int,
-c110 int,
-c111 int,
-c112 int,
-c113 int,
-c114 int,
-c115 int,
-c116 int,
-c117 int,
-c118 int,
-c119 int,
-c120 int,
-c121 int,
-c122 int,
-c123 int,
-c124 int,
-c125 int,
-c126 int,
-c127 int,
-c128 int,
-c129 int,
-c130 int,
-c131 int,
-c132 int,
-c133 int,
-c134 int,
-c135 int,
-c136 int,
-c137 int,
-c138 int,
-c139 int,
-c140 int,
-c141 int,
-c142 int,
-c143 int,
-c144 int,
-c145 int,
-c146 int,
-c147 int,
-c148 int,
-c149 int,
-c150 int,
-c151 int,
-c152 int,
-c153 int,
-c154 int,
-c155 int,
-c156 int,
-c157 int,
-c158 int,
-c159 int,
-c160 int,
-c161 int,
-c162 int,
-c163 int,
-c164 int,
-c165 int,
-c166 int,
-c167 int,
-c168 int,
-c169 int,
-c170 int,
-c171 int,
-c172 int,
-c173 int,
-c174 int,
-c175 int,
-c176 int,
-c177 int,
-c178 int,
-c179 int,
-c180 int,
-c181 int,
-c182 int,
-c183 int,
-c184 int,
-c185 int,
-c186 int,
-c187 int,
-c188 int,
-c189 int,
-c190 int,
-c191 int,
-c192 int,
-c193 int,
-c194 int,
-c195 int,
-c196 int,
-c197 int,
-c198 int,
-c199 int,
-c200 int,
-c201 int,
-c202 int,
-c203 int,
-c204 int,
-c205 int,
-c206 int,
-c207 int,
-c208 int,
-c209 int,
-c210 int,
-c211 int,
-c212 int,
-c213 int,
-c214 int,
-c215 int,
-c216 int,
-c217 int,
-c218 int,
-c219 int,
-c220 int,
-c221 int,
-c222 int,
-c223 int,
-c224 int,
-c225 int,
-c226 int,
-c227 int,
-c228 int,
-c229 int,
-c230 int,
-c231 int,
-c232 int,
-c233 int,
-c234 int,
-c235 int,
-c236 int,
-c237 int,
-c238 int,
-c239 int,
-c240 int,
-c241 int,
-c242 int,
-c243 int,
-c244 int,
-c245 int,
-c246 int,
-c247 int,
-c248 int,
-c249 int,
-c250 int,
-c251 int,
-c252 int,
-c253 int,
-c254 int,
-c255 int,
-c256 int,
-c257 int,
-c258 int,
-c259 int,
-c260 int,
-c261 int,
-c262 int,
-c263 int,
-c264 int,
-c265 int,
-c266 int,
-c267 int,
-c268 int,
-c269 int,
-c270 int,
-c271 int,
-c272 int,
-c273 int,
-c274 int,
-c275 int,
-c276 int,
-c277 int,
-c278 int,
-c279 int,
-c280 int,
-c281 int,
-c282 int,
-c283 int,
-c284 int,
-c285 int,
-c286 int,
-c287 int,
-c288 int,
-c289 int,
-c290 int,
-c291 int,
-c292 int,
-c293 int,
-c294 int,
-c295 int,
-c296 int,
-c297 int,
-c298 int,
-c299 int,
-c300 int,
-c301 int,
-c302 int,
-c303 int,
-c304 int,
-c305 int,
-c306 int,
-c307 int,
-c308 int,
-c309 int,
-c310 int,
-c311 int,
-c312 int,
-c313 int,
-c314 int,
-c315 int,
-c316 int,
-c317 int,
-c318 int,
-c319 int,
-c320 int,
-c321 int,
-c322 int,
-c323 int,
-c324 int,
-c325 int,
-c326 int,
-c327 int,
-c328 int,
-c329 int,
-c330 int,
-c331 int,
-c332 int,
-c333 int,
-c334 int,
-c335 int,
-c336 int,
-c337 int,
-c338 int,
-c339 int,
-c340 int,
-c341 int,
-c342 int,
-c343 int,
-c344 int,
-c345 int,
-c346 int,
-c347 int,
-c348 int,
-c349 int,
-c350 int,
-c351 int,
-c352 int,
-c353 int,
-c354 int,
-c355 int,
-c356 int,
-c357 int,
-c358 int,
-c359 int,
-c360 int,
-c361 int,
-c362 int,
-c363 int,
-c364 int,
-c365 int,
-c366 int,
-c367 int,
-c368 int,
-c369 int,
-c370 int,
-c371 int,
-c372 int,
-c373 int,
-c374 int,
-c375 int,
-c376 int,
-c377 int,
-c378 int,
-c379 int,
-c380 int,
-c381 int,
-c382 int,
-c383 int,
-c384 int,
-c385 int,
-c386 int,
-c387 int,
-c388 int,
-c389 int,
-c390 int,
-c391 int,
-c392 int,
-c393 int,
-c394 int,
-c395 int,
-c396 int,
-c397 int,
-c398 int,
-c399 int,
-c400 int,
-c401 int,
-c402 int,
-c403 int,
-c404 int,
-c405 int,
-c406 int,
-c407 int,
-c408 int,
-c409 int,
-c410 int,
-c411 int,
-c412 int,
-c413 int,
-c414 int,
-c415 int,
-c416 int,
-c417 int,
-c418 int,
-c419 int,
-c420 int,
-c421 int,
-c422 int,
-c423 int,
-c424 int,
-c425 int,
-c426 int,
-c427 int,
-c428 int,
-c429 int,
-c430 int,
-c431 int,
-c432 int,
-c433 int,
-c434 int,
-c435 int,
-c436 int,
-c437 int,
-c438 int,
-c439 int,
-c440 int,
-c441 int,
-c442 int,
-c443 int,
-c444 int,
-c445 int,
-c446 int,
-c447 int,
-c448 int,
-c449 int,
-c450 int,
-c451 int,
-c452 int,
-c453 int,
-c454 int,
-c455 int,
-c456 int,
-c457 int,
-c458 int,
-c459 int,
-c460 int,
-c461 int,
-c462 int,
-c463 int,
-c464 int,
-c465 int,
-c466 int,
-c467 int,
-c468 int,
-c469 int,
-c470 int,
-c471 int,
-c472 int,
-c473 int,
-c474 int,
-c475 int,
-c476 int,
-c477 int,
-c478 int,
-c479 int,
-c480 int,
-c481 int,
-c482 int,
-c483 int,
-c484 int,
-c485 int,
-c486 int,
-c487 int,
-c488 int,
-c489 int,
-c490 int,
-c491 int,
-c492 int,
-c493 int,
-c494 int,
-c495 int,
-c496 int,
-c497 int,
-c498 int,
-c499 int,
-primary key using hash(c1)) engine=ndb partition by key(c1);
+create table t1 ( c512 int, c511 int, c510 int, c509 int, c508 int, c507 int, c506 int, c505 int, c504 int, c503 int, c502 int, c501 int, c500 int, c499 int, c498 int, c497 int, c496 int, c495 int, c494 int, c493 int, c492 int, c491 int, c490 int, c489 int, c488 int, c487 int, c486 int, c485 int, c484 int, c483 int, c482 int, c481 int, c480 int, c479 int, c478 int, c477 int, c476 int, c475 int, c474 int, c473 int, c472 int, c471 int, c470 int, c469 int, c468 int, c467 int, c466 int, c465 int, c464 int, c463 int, c462 int, c461 int, c460 int, c459 int, c458 int, c457 int, c456 int, c455 int, c454 int, c453 int, c452 int, c451 int, c450 int, c449 int, c448 int, c447 int, c446 int, c445 int, c444 int, c443 int, c442 int, c441 int, c440 int, c439 int, c438 int, c437 int, c436 int, c435 int, c434 int, c433 int, c432 int, c431 int, c430 int, c429 int, c428 int, c427 int, c426 int, c425 int, c424 int, c423 int, c422 int, c421 int, c420 int, c419 int, c418 int, c417 int, c416 int, c
 415 int, c414 int, c413 int, c412 int, c411 int, c410 int, c409 int, c408 int, c407 int, c406 int, c405 int, c404 int, c403 int, c402 int, c401 int, c400 int, c399 int, c398 int, c397 int, c396 int, c395 int, c394 int, c393 int, c392 int, c391 int, c390 int, c389 int, c388 int, c387 int, c386 int, c385 int, c384 int, c383 int, c382 int, c381 int, c380 int, c379 int, c378 int, c377 int, c376 int, c375 int, c374 int, c373 int, c372 int, c371 int, c370 int, c369 int, c368 int, c367 int, c366 int, c365 int, c364 int, c363 int, c362 int, c361 int, c360 int, c359 int, c358 int, c357 int, c356 int, c355 int, c354 int, c353 int, c352 int, c351 int, c350 int, c349 int, c348 int, c347 int, c346 int, c345 int, c344 int, c343 int, c342 int, c341 int, c340 int, c339 int, c338 int, c337 int, c336 int, c335 int, c334 int, c333 int, c332 int, c331 int, c330 int, c329 int, c328 int, c327 int, c326 int, c325 int, c324 int, c323 int, c322 int, c321 int, c320 int, c319 int, c318 int, c317 int, 
 c316 int, c315 int, c314 int, c313 int, c312 int, c311 int, c310 int, c309 int, c308 int, c307 int, c306 int, c305 int, c304 int, c303 int, c302 int, c301 int, c300 int, c299 int, c298 int, c297 int, c296 int, c295 int, c294 int, c293 int, c292 int, c291 int, c290 int, c289 int, c288 int, c287 int, c286 int, c285 int, c284 int, c283 int, c282 int, c281 int, c280 int, c279 int, c278 int, c277 int, c276 int, c275 int, c274 int, c273 int, c272 int, c271 int, c270 int, c269 int, c268 int, c267 int, c266 int, c265 int, c264 int, c263 int, c262 int, c261 int, c260 int, c259 int, c258 int, c257 int, c256 int, c255 int, c254 int, c253 int, c252 int, c251 int, c250 int, c249 int, c248 int, c247 int, c246 int, c245 int, c244 int, c243 int, c242 int, c241 int, c240 int, c239 int, c238 int, c237 int, c236 int, c235 int, c234 int, c233 int, c232 int, c231 int, c230 int, c229 int, c228 int, c227 int, c226 int, c225 int, c224 int, c223 int, c222 int, c221 int, c220 int, c219 int, c218 int,
  c217 int, c216 int, c215 int, c214 int, c213 int, c212 int, c211 int, c210 int, c209 int, c208 int, c207 int, c206 int, c205 int, c204 int, c203 int, c202 int, c201 int, c200 int, c199 int, c198 int, c197 int, c196 int, c195 int, c194 int, c193 int, c192 int, c191 int, c190 int, c189 int, c188 int, c187 int, c186 int, c185 int, c184 int, c183 int, c182 int, c181 int, c180 int, c179 int, c178 int, c177 int, c176 int, c175 int, c174 int, c173 int, c172 int, c171 int, c170 int, c169 int, c168 int, c167 int, c166 int, c165 int, c164 int, c163 int, c162 int, c161 int, c160 int, c159 int, c158 int, c157 int, c156 int, c155 int, c154 int, c153 int, c152 int, c151 int, c150 int, c149 int, c148 int, c147 int, c146 int, c145 int, c144 int, c143 int, c142 int, c141 int, c140 int, c139 int, c138 int, c137 int, c136 int, c135 int, c134 int, c133 int, c132 int, c131 int, c130 int, c129 int, c128 int, c127 int, c126 int, c125 int, c124 int, c123 int, c122 int, c121 int, c120 int, c119 int
 , c118 int, c117 int, c116 int, c115 int, c114 int, c113 int, c112 int, c111 int, c110 int, c109 int, c108 int, c107 int, c106 int, c105 int, c104 int, c103 int, c102 int, c101 int, c100 int, c99 int, c98 int, c97 int, c96 int, c95 int, c94 int, c93 int, c92 int, c91 int, c90 int, c89 int, c88 int, c87 int, c86 int, c85 int, c84 int, c83 int, c82 int, c81 int, c80 int, c79 int, c78 int, c77 int, c76 int, c75 int, c74 int, c73 int, c72 int, c71 int, c70 int, c69 int, c68 int, c67 int, c66 int, c65 int, c64 int, c63 int, c62 int, c61 int, c60 int, c59 int, c58 int, c57 int, c56 int, c55 int, c54 int, c53 int, c52 int, c51 int, c50 int, c49 int, c48 int, c47 int, c46 int, c45 int, c44 int, c43 int, c42 int, c41 int, c40 int, c39 int, c38 int, c37 int, c36 int, c35 int, c34 int, c33 int, c32 int, c31 int, c30 int, c29 int, c28 int, c27 int, c26 int, c25 int, c24 int, c23 int, c22 int, c21 int, c20 int, c19 int, c18 int, c17 int, c16 int, c15 int, c14 int, c13 int, c12 int, c11 i
 nt, c10 int, c9 int, c8 int, c7 int, c6 int, c5 int, c4 int, c3 int, c2 int, c1 int, primary key using hash(c1)) engine=ndb partition by key(c1);
 insert into t1 (c1) values (1), (2), (3);
-alter offline table t1 modify c1 int auto_increment;
-alter online table t1 add column c500 bit(1) column_format DYNAMIC;
 delete from t1;
 drop table t1;
-create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
-ERROR HY000: Field in list of fields for partition function not found in table
 create table t1 (
 a1234567890123456789012345678901234567890 int primary key,
 a12345678901234567890123456789a1234567890 int,
@@ -1193,7 +682,7 @@ f1	f2	f3
 111111	aaaaaa	1
 222222	bbbbbb	2
 drop table t1;
-Illegal ndb error code: 1186
+Illegal ndb error code: 123456
 CREATE TABLE t1 (
 a VARBINARY(40) NOT NULL,
 b VARCHAR (256) CHARACTER SET UTF8 NOT NULL,
@@ -1390,4 +879,16 @@ id	parent_id
 2	2
 3	3
 DROP TABLE child, parent;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT)
+ENGINE=ndb PARTITION BY KEY(a) PARTITIONS 24;
+ERROR HY000: Can't create table 'test.t1' (errno: 140)
+show warnings;
+Level	Code	Message
+Error	1296	Got error 1224 'Too many fragments' from NDB
+Error	1005	Can't create table 'test.t1' (errno: 140)
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT)
+ENGINE=ndb;
+show warnings;
+Level	Code	Message
+drop table t1;
 End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/r/ndb_dd_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_dd_basic.result	2010-02-09 05:24:15 +0000
+++ b/mysql-test/suite/ndb/r/ndb_dd_basic.result	2011-01-28 10:48:23 +0000
@@ -167,6 +167,21 @@ INSERT INTO t1 VALUES 
 SELECT COUNT(*) FROM t1;
 COUNT(*)
 501
+SELECT table_name, 
+SUM(table_rows),
+SUM(data_length),
+MAX(max_data_length),
+SUM(data_free)
+FROM INFORMATION_SCHEMA.partitions
+WHERE table_name='t1'
+GROUP BY table_name;
+table_name	SUM(table_rows)	SUM(data_length)	MAX(max_data_length)	SUM(data_free)
+t1	501	65536	1048576	2078940
+SELECT table_name, table_rows, data_length, max_data_length, data_free
+FROM information_schema.tables
+WHERE table_name='t1';
+table_name	table_rows	data_length	max_data_length	data_free
+t1	501	65536	2097152	2078940
 CREATE LOGFILE GROUP lg2
 ADD UNDOFILE 'x.dat'
 INITIAL_SIZE 10y

=== modified file 'mysql-test/suite/ndb/r/ndb_load.result'
--- a/mysql-test/suite/ndb/r/ndb_load.result	2009-04-06 10:37:55 +0000
+++ b/mysql-test/suite/ndb/r/ndb_load.result	2011-01-21 12:21:05 +0000
@@ -124,7 +124,7 @@ COUNT(*)
 DROP PROCEDURE bulkinsert;
 DROP TABLE t2;
 Now check bulk insert using create .. as select.
-SHOW VARIABLES LIKE '%storage_engine%';
+SHOW VARIABLES LIKE 'storage_engine';
 Variable_name	Value
 storage_engine	MyISAM
 SET storage_engine="ndb";

=== modified file 'mysql-test/suite/ndb/r/ndb_partition_error.result'
--- a/mysql-test/suite/ndb/r/ndb_partition_error.result	2009-05-15 14:00:51 +0000
+++ b/mysql-test/suite/ndb/r/ndb_partition_error.result	2011-01-21 09:14:41 +0000
@@ -45,3 +45,5 @@ partition x234 values in (5, 1));
 insert into t1 values (NULL,1,1);
 Got one of the listed errors
 drop table t1;
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+ERROR HY000: Field in list of fields for partition function not found in table

=== modified file 'mysql-test/suite/ndb/r/ndb_partition_range.result'
--- a/mysql-test/suite/ndb/r/ndb_partition_range.result	2010-10-01 10:08:29 +0000
+++ b/mysql-test/suite/ndb/r/ndb_partition_range.result	2011-01-27 17:57:43 +0000
@@ -17,9 +17,9 @@ INSERT into t1 values (10, 1, 1);
 INSERT into t1 values (15, 1, 1);
 select * from information_schema.partitions where table_name= 't1';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	PARTITION_NAME	SUBPARTITION_NAME	PARTITION_ORDINAL_POSITION	SUBPARTITION_ORDINAL_POSITION	PARTITION_METHOD	SUBPARTITION_METHOD	PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION	PARTITION_DESCRIPTION	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	CREATE_TIME	UPDATE_TIME	CHECK_TIME	CHECKSUM	PARTITION_COMMENT	NODEGROUP	TABLESPACE_NAME
-NULL	test	t1	x1	NULL	1	NULL	RANGE	NULL	a	NULL	5	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
-NULL	test	t1	x2	NULL	2	NULL	RANGE	NULL	a	NULL	10	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
-NULL	test	t1	x3	NULL	3	NULL	RANGE	NULL	a	NULL	20	0	0	0	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x1	NULL	1	NULL	RANGE	NULL	a	NULL	5	1	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x2	NULL	2	NULL	RANGE	NULL	a	NULL	10	1	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
+NULL	test	t1	x3	NULL	3	NULL	RANGE	NULL	a	NULL	20	2	40	32768	#	0	0	#	#	NULL	NULL		default	NULL
 select * from t1 order by a;
 a	b	c
 1	1	1

=== modified file 'mysql-test/suite/ndb/r/ndb_restore.result'
--- a/mysql-test/suite/ndb/r/ndb_restore.result	2010-10-12 14:11:45 +0000
+++ b/mysql-test/suite/ndb/r/ndb_restore.result	2011-01-21 10:29:46 +0000
@@ -630,3 +630,6 @@ id	type	state	logging	_database	_schema	
 drop table ndb_show_tables_results;
 create table t1 (a int primary key) engine = ndb;
 drop table t1;
+create table t1 ( c499 int, c498 int, c497 int, c496 int, c495 int, c494 int, c493 int, c492 int, c491 int, c490 int, c489 int, c488 int, c487 int, c486 int, c485 int, c484 int, c483 int, c482 int, c481 int, c480 int, c479 int, c478 int, c477 int, c476 int, c475 int, c474 int, c473 int, c472 int, c471 int, c470 int, c469 int, c468 int, c467 int, c466 int, c465 int, c464 int, c463 int, c462 int, c461 int, c460 int, c459 int, c458 int, c457 int, c456 int, c455 int, c454 int, c453 int, c452 int, c451 int, c450 int, c449 int, c448 int, c447 int, c446 int, c445 int, c444 int, c443 int, c442 int, c441 int, c440 int, c439 int, c438 int, c437 int, c436 int, c435 int, c434 int, c433 int, c432 int, c431 int, c430 int, c429 int, c428 int, c427 int, c426 int, c425 int, c424 int, c423 int, c422 int, c421 int, c420 int, c419 int, c418 int, c417 int, c416 int, c415 int, c414 int, c413 int, c412 int, c411 int, c410 int, c409 int, c408 int, c407 int, c406 int, c405 int, c404 int, c403 int, c
 402 int, c401 int, c400 int, c399 int, c398 int, c397 int, c396 int, c395 int, c394 int, c393 int, c392 int, c391 int, c390 int, c389 int, c388 int, c387 int, c386 int, c385 int, c384 int, c383 int, c382 int, c381 int, c380 int, c379 int, c378 int, c377 int, c376 int, c375 int, c374 int, c373 int, c372 int, c371 int, c370 int, c369 int, c368 int, c367 int, c366 int, c365 int, c364 int, c363 int, c362 int, c361 int, c360 int, c359 int, c358 int, c357 int, c356 int, c355 int, c354 int, c353 int, c352 int, c351 int, c350 int, c349 int, c348 int, c347 int, c346 int, c345 int, c344 int, c343 int, c342 int, c341 int, c340 int, c339 int, c338 int, c337 int, c336 int, c335 int, c334 int, c333 int, c332 int, c331 int, c330 int, c329 int, c328 int, c327 int, c326 int, c325 int, c324 int, c323 int, c322 int, c321 int, c320 int, c319 int, c318 int, c317 int, c316 int, c315 int, c314 int, c313 int, c312 int, c311 int, c310 int, c309 int, c308 int, c307 int, c306 int, c305 int, c304 int, 
 c303 int, c302 int, c301 int, c300 int, c299 int, c298 int, c297 int, c296 int, c295 int, c294 int, c293 int, c292 int, c291 int, c290 int, c289 int, c288 int, c287 int, c286 int, c285 int, c284 int, c283 int, c282 int, c281 int, c280 int, c279 int, c278 int, c277 int, c276 int, c275 int, c274 int, c273 int, c272 int, c271 int, c270 int, c269 int, c268 int, c267 int, c266 int, c265 int, c264 int, c263 int, c262 int, c261 int, c260 int, c259 int, c258 int, c257 int, c256 int, c255 int, c254 int, c253 int, c252 int, c251 int, c250 int, c249 int, c248 int, c247 int, c246 int, c245 int, c244 int, c243 int, c242 int, c241 int, c240 int, c239 int, c238 int, c237 int, c236 int, c235 int, c234 int, c233 int, c232 int, c231 int, c230 int, c229 int, c228 int, c227 int, c226 int, c225 int, c224 int, c223 int, c222 int, c221 int, c220 int, c219 int, c218 int, c217 int, c216 int, c215 int, c214 int, c213 int, c212 int, c211 int, c210 int, c209 int, c208 int, c207 int, c206 int, c205 int,
  c204 int, c203 int, c202 int, c201 int, c200 int, c199 int, c198 int, c197 int, c196 int, c195 int, c194 int, c193 int, c192 int, c191 int, c190 int, c189 int, c188 int, c187 int, c186 int, c185 int, c184 int, c183 int, c182 int, c181 int, c180 int, c179 int, c178 int, c177 int, c176 int, c175 int, c174 int, c173 int, c172 int, c171 int, c170 int, c169 int, c168 int, c167 int, c166 int, c165 int, c164 int, c163 int, c162 int, c161 int, c160 int, c159 int, c158 int, c157 int, c156 int, c155 int, c154 int, c153 int, c152 int, c151 int, c150 int, c149 int, c148 int, c147 int, c146 int, c145 int, c144 int, c143 int, c142 int, c141 int, c140 int, c139 int, c138 int, c137 int, c136 int, c135 int, c134 int, c133 int, c132 int, c131 int, c130 int, c129 int, c128 int, c127 int, c126 int, c125 int, c124 int, c123 int, c122 int, c121 int, c120 int, c119 int, c118 int, c117 int, c116 int, c115 int, c114 int, c113 int, c112 int, c111 int, c110 int, c109 int, c108 int, c107 int, c106 int
 , c105 int, c104 int, c103 int, c102 int, c101 int, c100 int, c99 int, c98 int, c97 int, c96 int, c95 int, c94 int, c93 int, c92 int, c91 int, c90 int, c89 int, c88 int, c87 int, c86 int, c85 int, c84 int, c83 int, c82 int, c81 int, c80 int, c79 int, c78 int, c77 int, c76 int, c75 int, c74 int, c73 int, c72 int, c71 int, c70 int, c69 int, c68 int, c67 int, c66 int, c65 int, c64 int, c63 int, c62 int, c61 int, c60 int, c59 int, c58 int, c57 int, c56 int, c55 int, c54 int, c53 int, c52 int, c51 int, c50 int, c49 int, c48 int, c47 int, c46 int, c45 int, c44 int, c43 int, c42 int, c41 int, c40 int, c39 int, c38 int, c37 int, c36 int, c35 int, c34 int, c33 int, c32 int, c31 int, c30 int, c29 int, c28 int, c27 int, c26 int, c25 int, c24 int, c23 int, c22 int, c21 int, c20 int, c19 int, c18 int, c17 int, c16 int, c15 int, c14 int, c13 int, c12 int, c11 int, c10 int, c9 int, c8 int, c7 int, c6 int, c5 int, c4 int, c3 int, c2 int, c1 int, primary key using hash(c1)) engine=ndb;
+insert into t1 (c1) values (1), (2), (3);
+drop table t1;

=== added file 'mysql-test/suite/ndb/r/ndb_restore_rewrite_db.result'
--- a/mysql-test/suite/ndb/r/ndb_restore_rewrite_db.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/r/ndb_restore_rewrite_db.result	2011-02-02 06:52:12 +0000
@@ -0,0 +1,328 @@
+************************************************************
+* Creating multiple databases with identical tables
+* (have blobs and indexes to cover the hidden tables)
+************************************************************
+CREATE DATABASE db0;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+USE db0;
+CREATE TABLE t0 (
+id              INT             PRIMARY KEY,
+cint            INT,
+cvarchar        VARCHAR(5),
+cblob           BLOB(1000004),
+UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+USE db1;
+CREATE TABLE t0 (
+id              INT             PRIMARY KEY,
+cint            INT,
+cvarchar        VARCHAR(5),
+cblob           BLOB(1000004),
+UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+USE db2;
+CREATE TABLE t0 (
+id              INT             PRIMARY KEY,
+cint            INT,
+cvarchar        VARCHAR(5),
+cblob           BLOB(1000004),
+UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+************************************************************
+* Inserting data
+* (create disjunct sets of rows to merge without conflicts;
+*  at this time, ndb_restore does not offer any detection
+*  of data conflicts between databases in the backup or in
+*  memory; databases are restored in an unspecified order)
+* (make blob data long enough to be held in extra table)
+************************************************************
+USE db0;
+INSERT INTO t0 VALUES (0, 0, '00000', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (1, 1, '11111', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (2, 2, '22222', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+USE db1;
+INSERT INTO t0 VALUES (3, 3, '33333', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (4, 4, '44444', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (5, 5, '55555', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+USE db2;
+INSERT INTO t0 VALUES (6, 6, '66666', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (7, 7, '77777', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (8, 8, '88888', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+************************************************************
+* Creating in-memory copies of the NDB tables
+************************************************************
+CREATE TABLE db0.t0_data ENGINE=MYISAM AS SELECT * FROM db0.t0;
+CREATE TABLE db1.t0_data ENGINE=MYISAM AS SELECT * FROM db1.t0;
+CREATE TABLE db2.t0_data ENGINE=MYISAM AS SELECT * FROM db2.t0;
+************************************************************
+* Backing up databases
+************************************************************
+************************************************************
+* Restoring databases with no rewrite (sanity check)
+************************************************************
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Negative testing: check wrong usage of command-line option
+* (expected exit code for usage errors: NDBT_WRONGARGS = 2)
+************************************************************
+************************************************************
+* Restoring databases with redundant/self-rewrite options
+************************************************************
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with overriding rewrite options
+************************************************************
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with a single rewrite
+************************************************************
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+6
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db1.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+6
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with multiple rewrites
+************************************************************
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+6
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+6
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with multiple rewrites into same target
+************************************************************
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+9
+INSERT db2.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+0
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+9
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with swapping rewrites
+************************************************************
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db0.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Restoring databases with permutating rewrites
+************************************************************
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+SELECT COUNT(*) FROM db0.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0;
+COUNT(*)
+3
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db0.t0_temp SELECT * FROM db2.t0_data;
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+COUNT(*)
+3
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+COUNT(*)
+3
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+************************************************************
+* Deleting tables and databases
+************************************************************
+DROP DATABASE db0;
+DROP DATABASE db1;
+DROP DATABASE db2;

=== modified file 'mysql-test/suite/ndb/r/ndb_temporary.result'
--- a/mysql-test/suite/ndb/r/ndb_temporary.result	2007-08-02 22:14:05 +0000
+++ b/mysql-test/suite/ndb/r/ndb_temporary.result	2011-01-25 09:45:42 +0000
@@ -5,6 +5,10 @@ create temporary table t1 (a int key) en
 alter table t1 engine=ndb;
 ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY'
 drop table t1;
+CREATE TABLE bar ( id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=NDBCluster ;
+CREATE TEMPORARY TABLE foo LIKE bar ;
+ERROR HY000: Can't create table 'test.foo' (errno: 1478)
+DROP TABLE bar;
 SET SESSION storage_engine=NDBCLUSTER;
 create table t1 (a int key);
 select engine from information_schema.tables where table_name = 't1';

=== added file 'mysql-test/suite/ndb/r/ndbinfo_cache.result'
--- a/mysql-test/suite/ndb/r/ndbinfo_cache.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/r/ndbinfo_cache.result	2011-02-01 14:58:21 +0000
@@ -0,0 +1,16 @@
+USE ndbinfo;
+set GLOBAL query_cache_type=on;
+set GLOBAL query_cache_size=1355776;
+reset query cache;
+flush status;
+select * from counters;
+select * from counters;
+select * from counters;
+show status like "Qcache_queries_in_cache";
+Variable_name	Value
+Qcache_queries_in_cache	0
+show status like "Qcache_inserts";
+Variable_name	Value
+Qcache_inserts	0
+SET GLOBAL query_cache_size=default;
+SET GLOBAL query_cache_type=default;

=== modified file 'mysql-test/suite/ndb/t/ndb_alter_table_online.test'
--- a/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2009-10-09 15:48:57 +0000
+++ b/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2011-01-21 10:29:46 +0000
@@ -744,11 +744,27 @@ ALTER ONLINE TABLE t1 ADD b INT;
 --sleep 10
 
 --enable_warnings
---echo ********************
---echo * Cleanup Section
---echo ********************
 
 DROP TABLE t1, ndb_show_tables_results;
-# End of 5.1 Test Case
 
+#
+# test alter of table with many attributes
+#
+let $i=499;
+let $separator=;
+let $sql=create table t1 (;
+while ($i)
+{
+  let $sql=$sql$separator c$i int;
+  let $separator=,;
+  dec $i;
+}
+let $sql=$sql, primary key using hash(c1)) engine=ndb;
+eval $sql; # eval the sql and create the table
+
+insert into t1 (c1) values (1), (2), (3);
+alter offline table t1 modify c1 int auto_increment;
+alter online table t1 add column c500 bit(1) column_format DYNAMIC;
+delete from t1;
+drop table t1;
 

=== modified file 'mysql-test/suite/ndb/t/ndb_basic.test'
--- a/mysql-test/suite/ndb/t/ndb_basic.test	2010-11-01 09:13:06 +0000
+++ b/mysql-test/suite/ndb/t/ndb_basic.test	2011-01-27 13:31:04 +0000
@@ -5,17 +5,6 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t
 drop database if exists mysqltest;
 --enable_warnings
 
-# workaround for bug#16445
-# remove to reproduce bug and run tests from ndb start
-# and with ndb_autodiscover disabled. Fails on Linux 50 % of the times
-CREATE TABLE t1 (
-  pk1 INT NOT NULL PRIMARY KEY,
-  attr1 INT NOT NULL,
-  attr2 INT,
-  attr3 VARCHAR(10)
-) ENGINE=ndbcluster;
-drop table t1;
-
 #
 # Basic test to show that the NDB 
 # table handler is working
@@ -410,526 +399,30 @@ drop table t1;
 
 #
 # test the limit of no of attributes in one table
+#  - use while loop to build dynamic sql string
 #
-# also tests bug#17179, more than 31 attributes in
-# a partitioned table
-#
-create table t1 (
-c1 int,
-c2 int,
-c3 int,
-c4 int,
-c5 int,
-c6 int,
-c7 int,
-c8 int,
-c9 int,
-c10 int,
-c11 int,
-c12 int,
-c13 int,
-c14 int,
-c15 int,
-c16 int,
-c17 int,
-c18 int,
-c19 int,
-c20 int,
-c21 int,
-c22 int,
-c23 int,
-c24 int,
-c25 int,
-c26 int,
-c27 int,
-c28 int,
-c29 int,
-c30 int,
-c31 int,
-c32 int,
-c33 int,
-c34 int,
-c35 int,
-c36 int,
-c37 int,
-c38 int,
-c39 int,
-c40 int,
-c41 int,
-c42 int,
-c43 int,
-c44 int,
-c45 int,
-c46 int,
-c47 int,
-c48 int,
-c49 int,
-c50 int,
-c51 int,
-c52 int,
-c53 int,
-c54 int,
-c55 int,
-c56 int,
-c57 int,
-c58 int,
-c59 int,
-c60 int,
-c61 int,
-c62 int,
-c63 int,
-c64 int,
-c65 int,
-c66 int,
-c67 int,
-c68 int,
-c69 int,
-c70 int,
-c71 int,
-c72 int,
-c73 int,
-c74 int,
-c75 int,
-c76 int,
-c77 int,
-c78 int,
-c79 int,
-c80 int,
-c81 int,
-c82 int,
-c83 int,
-c84 int,
-c85 int,
-c86 int,
-c87 int,
-c88 int,
-c89 int,
-c90 int,
-c91 int,
-c92 int,
-c93 int,
-c94 int,
-c95 int,
-c96 int,
-c97 int,
-c98 int,
-c99 int,
-c100 int,
-c101 int,
-c102 int,
-c103 int,
-c104 int,
-c105 int,
-c106 int,
-c107 int,
-c108 int,
-c109 int,
-c110 int,
-c111 int,
-c112 int,
-c113 int,
-c114 int,
-c115 int,
-c116 int,
-c117 int,
-c118 int,
-c119 int,
-c120 int,
-c121 int,
-c122 int,
-c123 int,
-c124 int,
-c125 int,
-c126 int,
-c127 int,
-c128 int,
-c129 int,
-c130 int,
-c131 int,
-c132 int,
-c133 int,
-c134 int,
-c135 int,
-c136 int,
-c137 int,
-c138 int,
-c139 int,
-c140 int,
-c141 int,
-c142 int,
-c143 int,
-c144 int,
-c145 int,
-c146 int,
-c147 int,
-c148 int,
-c149 int,
-c150 int,
-c151 int,
-c152 int,
-c153 int,
-c154 int,
-c155 int,
-c156 int,
-c157 int,
-c158 int,
-c159 int,
-c160 int,
-c161 int,
-c162 int,
-c163 int,
-c164 int,
-c165 int,
-c166 int,
-c167 int,
-c168 int,
-c169 int,
-c170 int,
-c171 int,
-c172 int,
-c173 int,
-c174 int,
-c175 int,
-c176 int,
-c177 int,
-c178 int,
-c179 int,
-c180 int,
-c181 int,
-c182 int,
-c183 int,
-c184 int,
-c185 int,
-c186 int,
-c187 int,
-c188 int,
-c189 int,
-c190 int,
-c191 int,
-c192 int,
-c193 int,
-c194 int,
-c195 int,
-c196 int,
-c197 int,
-c198 int,
-c199 int,
-c200 int,
-c201 int,
-c202 int,
-c203 int,
-c204 int,
-c205 int,
-c206 int,
-c207 int,
-c208 int,
-c209 int,
-c210 int,
-c211 int,
-c212 int,
-c213 int,
-c214 int,
-c215 int,
-c216 int,
-c217 int,
-c218 int,
-c219 int,
-c220 int,
-c221 int,
-c222 int,
-c223 int,
-c224 int,
-c225 int,
-c226 int,
-c227 int,
-c228 int,
-c229 int,
-c230 int,
-c231 int,
-c232 int,
-c233 int,
-c234 int,
-c235 int,
-c236 int,
-c237 int,
-c238 int,
-c239 int,
-c240 int,
-c241 int,
-c242 int,
-c243 int,
-c244 int,
-c245 int,
-c246 int,
-c247 int,
-c248 int,
-c249 int,
-c250 int,
-c251 int,
-c252 int,
-c253 int,
-c254 int,
-c255 int,
-c256 int,
-c257 int,
-c258 int,
-c259 int,
-c260 int,
-c261 int,
-c262 int,
-c263 int,
-c264 int,
-c265 int,
-c266 int,
-c267 int,
-c268 int,
-c269 int,
-c270 int,
-c271 int,
-c272 int,
-c273 int,
-c274 int,
-c275 int,
-c276 int,
-c277 int,
-c278 int,
-c279 int,
-c280 int,
-c281 int,
-c282 int,
-c283 int,
-c284 int,
-c285 int,
-c286 int,
-c287 int,
-c288 int,
-c289 int,
-c290 int,
-c291 int,
-c292 int,
-c293 int,
-c294 int,
-c295 int,
-c296 int,
-c297 int,
-c298 int,
-c299 int,
-c300 int,
-c301 int,
-c302 int,
-c303 int,
-c304 int,
-c305 int,
-c306 int,
-c307 int,
-c308 int,
-c309 int,
-c310 int,
-c311 int,
-c312 int,
-c313 int,
-c314 int,
-c315 int,
-c316 int,
-c317 int,
-c318 int,
-c319 int,
-c320 int,
-c321 int,
-c322 int,
-c323 int,
-c324 int,
-c325 int,
-c326 int,
-c327 int,
-c328 int,
-c329 int,
-c330 int,
-c331 int,
-c332 int,
-c333 int,
-c334 int,
-c335 int,
-c336 int,
-c337 int,
-c338 int,
-c339 int,
-c340 int,
-c341 int,
-c342 int,
-c343 int,
-c344 int,
-c345 int,
-c346 int,
-c347 int,
-c348 int,
-c349 int,
-c350 int,
-c351 int,
-c352 int,
-c353 int,
-c354 int,
-c355 int,
-c356 int,
-c357 int,
-c358 int,
-c359 int,
-c360 int,
-c361 int,
-c362 int,
-c363 int,
-c364 int,
-c365 int,
-c366 int,
-c367 int,
-c368 int,
-c369 int,
-c370 int,
-c371 int,
-c372 int,
-c373 int,
-c374 int,
-c375 int,
-c376 int,
-c377 int,
-c378 int,
-c379 int,
-c380 int,
-c381 int,
-c382 int,
-c383 int,
-c384 int,
-c385 int,
-c386 int,
-c387 int,
-c388 int,
-c389 int,
-c390 int,
-c391 int,
-c392 int,
-c393 int,
-c394 int,
-c395 int,
-c396 int,
-c397 int,
-c398 int,
-c399 int,
-c400 int,
-c401 int,
-c402 int,
-c403 int,
-c404 int,
-c405 int,
-c406 int,
-c407 int,
-c408 int,
-c409 int,
-c410 int,
-c411 int,
-c412 int,
-c413 int,
-c414 int,
-c415 int,
-c416 int,
-c417 int,
-c418 int,
-c419 int,
-c420 int,
-c421 int,
-c422 int,
-c423 int,
-c424 int,
-c425 int,
-c426 int,
-c427 int,
-c428 int,
-c429 int,
-c430 int,
-c431 int,
-c432 int,
-c433 int,
-c434 int,
-c435 int,
-c436 int,
-c437 int,
-c438 int,
-c439 int,
-c440 int,
-c441 int,
-c442 int,
-c443 int,
-c444 int,
-c445 int,
-c446 int,
-c447 int,
-c448 int,
-c449 int,
-c450 int,
-c451 int,
-c452 int,
-c453 int,
-c454 int,
-c455 int,
-c456 int,
-c457 int,
-c458 int,
-c459 int,
-c460 int,
-c461 int,
-c462 int,
-c463 int,
-c464 int,
-c465 int,
-c466 int,
-c467 int,
-c468 int,
-c469 int,
-c470 int,
-c471 int,
-c472 int,
-c473 int,
-c474 int,
-c475 int,
-c476 int,
-c477 int,
-c478 int,
-c479 int,
-c480 int,
-c481 int,
-c482 int,
-c483 int,
-c484 int,
-c485 int,
-c486 int,
-c487 int,
-c488 int,
-c489 int,
-c490 int,
-c491 int,
-c492 int,
-c493 int,
-c494 int,
-c495 int,
-c496 int,
-c497 int,
-c498 int,
-c499 int,
-primary key using hash(c1)) engine=ndb partition by key(c1);
+let $i=512; # The current max number of attributes
+let $separator=;
+let $sql=create table t1 (;
+while ($i)
+{
+  let $sql=$sql$separator c$i int;
+  let $separator=,;
+  dec $i;
+}
+let $sql=$sql, primary key using hash(c1)) engine=ndb;
+let $sql=$sql partition by key(c1);
+#             ^^^^^^^^^^^^^^^^^^^^
+#             also tests bug#17179, more than 31
+#             attributes in a partitioned table
+
+eval $sql; # eval the sql and create the table
+
 insert into t1 (c1) values (1), (2), (3);
-alter offline table t1 modify c1 int auto_increment;
-alter online table t1 add column c500 bit(1) column_format DYNAMIC;
---source include/ndb_backup.inc
 delete from t1;
 drop table t1;
 
 #
-# test bug#53354 - crash when creating partitioned table with multiple columns in the partition key
-#
-
---error ER_FIELD_NOT_FOUND_PART_ERROR
-create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
-
-#
 # test max size of attribute name and truncation
 #
 
@@ -1122,10 +615,10 @@ drop table t1;
 # Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror
 #
 
-# As long there is no error code 1186 defined by NDB
-# we should get a message "Illegal ndb error code: 1186"
+# As long there is no error code XXX defined by NDB
+# we should get a message "Illegal ndb error code: XXX"
 --error 1
---exec $MY_PERROR --ndb 1186 2>&1
+--exec $MY_PERROR --ndb 123456 2>&1
 
 #
 # Bug #25746 - VARCHAR UTF8 PK issue
@@ -1292,4 +785,16 @@ SELECT * FROM child ORDER BY id;
 
 DROP TABLE child, parent;
 
+#
+# bug#59756
+#
+--error 1005
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT)
+ENGINE=ndb PARTITION BY KEY(a) PARTITIONS 24;
+show warnings;
+CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT)
+ENGINE=ndb;
+show warnings;
+drop table t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/t/ndb_dd_alter.test'
--- a/mysql-test/suite/ndb/t/ndb_dd_alter.test	2010-11-30 10:35:37 +0000
+++ b/mysql-test/suite/ndb/t/ndb_dd_alter.test	2011-01-28 11:00:16 +0000
@@ -161,10 +161,12 @@ enable_query_log;
 
 SELECT * FROM test.t1 ORDER BY a1;
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 
 ALTER TABLE test.t1 ADD a2 FLOAT, ADD a3 DOUBLE;
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't1' AND partition_name = 'p0';
 
 let $1=20;

=== modified file 'mysql-test/suite/ndb/t/ndb_dd_basic.test'
--- a/mysql-test/suite/ndb/t/ndb_dd_basic.test	2010-02-09 05:24:15 +0000
+++ b/mysql-test/suite/ndb/t/ndb_dd_basic.test	2011-01-28 10:48:23 +0000
@@ -199,6 +199,23 @@ INSERT INTO t1 VALUES 
 
 SELECT COUNT(*) FROM t1;
 
+########################################
+# WL#5568: Check disk space usage.
+########################################
+
+SELECT table_name, 
+       SUM(table_rows),
+       SUM(data_length),
+       MAX(max_data_length),
+       SUM(data_free)
+FROM INFORMATION_SCHEMA.partitions
+WHERE table_name='t1'
+GROUP BY table_name;
+
+SELECT table_name, table_rows, data_length, max_data_length, data_free
+FROM information_schema.tables
+WHERE table_name='t1';
+
 ####################################
 # Test error cases with size numbers
 ####################################

=== modified file 'mysql-test/suite/ndb/t/ndb_load.test'
--- a/mysql-test/suite/ndb/t/ndb_load.test	2009-04-06 10:37:55 +0000
+++ b/mysql-test/suite/ndb/t/ndb_load.test	2011-01-21 12:21:05 +0000
@@ -78,7 +78,7 @@ DROP PROCEDURE bulkinsert;
 DROP TABLE t2;
 
 --echo Now check bulk insert using create .. as select.
-SHOW VARIABLES LIKE '%storage_engine%';
+SHOW VARIABLES LIKE 'storage_engine';
 SET storage_engine="ndb";
 
 CREATE TABLE t2 AS SELECT * FROM t1;

=== modified file 'mysql-test/suite/ndb/t/ndb_partition_error.test'
--- a/mysql-test/suite/ndb/t/ndb_partition_error.test	2009-05-15 14:00:51 +0000
+++ b/mysql-test/suite/ndb/t/ndb_partition_error.test	2011-01-21 09:14:41 +0000
@@ -72,3 +72,11 @@ partitions 2
 --error ER_BAD_NULL_ERROR,ER_NO_PARTITION_FOR_GIVEN_VALUE
 insert into t1 values (NULL,1,1);
 drop table t1;
+
+#
+# test bug#53354 - crash when creating partitioned table with multiple columns in the partition key
+#
+
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+

=== modified file 'mysql-test/suite/ndb/t/ndb_restore.test'
--- a/mysql-test/suite/ndb/t/ndb_restore.test	2010-10-25 09:15:03 +0000
+++ b/mysql-test/suite/ndb/t/ndb_restore.test	2011-01-21 10:29:46 +0000
@@ -560,3 +560,21 @@ create table t1 (a int primary key) engi
 --exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "abort backup 33" >> $NDB_TOOLS_OUTPUT
 drop table t1;
 
+#
+# test backup of table with many attributes
+#
+let $i=499;
+let $separator=;
+let $sql=create table t1 (;
+while ($i)
+{
+  let $sql=$sql$separator c$i int;
+  let $separator=,;
+  dec $i;
+}
+let $sql=$sql, primary key using hash(c1)) engine=ndb;
+eval $sql; # eval the sql and create the table
+
+insert into t1 (c1) values (1), (2), (3);
+--source include/ndb_backup.inc
+drop table t1;

=== added file 'mysql-test/suite/ndb/t/ndb_restore_rewrite_db.test'
--- a/mysql-test/suite/ndb/t/ndb_restore_rewrite_db.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_restore_rewrite_db.test	2011-02-02 10:17:58 +0000
@@ -0,0 +1,415 @@
+######################################################################
+# Author: Martin Zaun
+# Date: 2011-01
+# Purpose: test of rewrite-database feature
+######################################################################
+
+-- source include/have_ndb.inc
+
+# mysqld's configuration is not relevant to this test
+-- source include/not_embedded.inc
+
+--echo ************************************************************
+--echo * Creating multiple databases with identical tables
+--echo * (have blobs and indexes to cover the hidden tables)
+--echo ************************************************************
+
+CREATE DATABASE db0;
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+USE db0;
+CREATE TABLE t0 (
+        id              INT             PRIMARY KEY,
+        cint            INT,
+        cvarchar        VARCHAR(5),
+        cblob           BLOB(1000004),
+        UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+        UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+
+USE db1;
+CREATE TABLE t0 (
+        id              INT             PRIMARY KEY,
+        cint            INT,
+        cvarchar        VARCHAR(5),
+        cblob           BLOB(1000004),
+        UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+        UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+
+USE db2;
+CREATE TABLE t0 (
+        id              INT             PRIMARY KEY,
+        cint            INT,
+        cvarchar        VARCHAR(5),
+        cblob           BLOB(1000004),
+        UNIQUE INDEX UNIQUE_t0_0 USING BTREE (cint ASC),
+        UNIQUE INDEX UNIQUE_t0_2 USING BTREE (cvarchar ASC)
+) ENGINE=NDB;
+
+
+--echo ************************************************************
+--echo * Inserting data
+--echo * (create disjunct sets of rows to merge without conflicts;
+--echo *  at this time, ndb_restore does not offer any detection
+--echo *  of data conflicts between databases in the backup or in
+--echo *  memory; databases are restored in an unspecified order)
+--echo * (make blob data long enough to be held in extra table)
+--echo ************************************************************
+
+USE db0;
+INSERT INTO t0 VALUES (0, 0, '00000', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (1, 1, '11111', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (2, 2, '22222', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+
+USE db1;
+INSERT INTO t0 VALUES (3, 3, '33333', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (4, 4, '44444', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (5, 5, '55555', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+
+USE db2;
+INSERT INTO t0 VALUES (6, 6, '66666', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (7, 7, '77777', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+INSERT INTO t0 VALUES (8, 8, '88888', '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
+
+--echo ************************************************************
+--echo * Creating in-memory copies of the NDB tables
+--echo ************************************************************
+
+CREATE TABLE db0.t0_data ENGINE=MYISAM AS SELECT * FROM db0.t0;
+CREATE TABLE db1.t0_data ENGINE=MYISAM AS SELECT * FROM db1.t0;
+CREATE TABLE db2.t0_data ENGINE=MYISAM AS SELECT * FROM db2.t0;
+
+--echo ************************************************************
+--echo * Backing up databases
+--echo ************************************************************
+
+--source include/ndb_backup.inc
+
+# command shortcuts, cover rebuilding of indexes
+--let $restore_cmd=$NDB_RESTORE --no-defaults
+--let $restore_cmd=$restore_cmd --disable-indexes --rebuild-indexes
+--let $restore_cmd=$restore_cmd -b $the_backup_id -r
+--let $restore_cmd=$restore_cmd --backup_path=$NDB_BACKUPS-$the_backup_id
+
+--echo ************************************************************
+--echo * Restoring databases with no rewrite (sanity check)
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Negative testing: check wrong usage of command-line option
+--echo * (expected exit code for usage errors: NDBT_WRONGARGS = 2)
+--echo ************************************************************
+
+# empty argument
+--let $restore_opt=--rewrite-database=
+--error 2
+--exec $restore_cmd -n 1 $restore_opt > /dev/null
+
+# missing separator
+--let $restore_opt=--rewrite-database=aaaa
+--error 2
+--exec $restore_cmd -n 1 $restore_opt > /dev/null
+
+# missing source and target
+--let $restore_opt=--rewrite-database=,
+--error 2
+--exec $restore_cmd -n 1 $restore_opt > /dev/null
+
+# missing source
+--let $restore_opt=--rewrite-database=,a
+--error 2
+--exec $restore_cmd -n 1 $restore_opt > /dev/null
+
+# missing target
+--let $restore_opt=--rewrite-database=a,
+--error 2
+--exec $restore_cmd -n 1 $restore_opt > /dev/null
+
+--echo ************************************************************
+--echo * Restoring databases with redundant/self-rewrite options
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db0 --rewrite-database=db1,db1
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with overriding rewrite options
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp ENGINE=MYISAM AS SELECT * FROM db0.t0_data;
+CREATE TABLE db1.t0_temp ENGINE=MYISAM AS SELECT * FROM db1.t0_data;
+CREATE TABLE db2.t0_temp ENGINE=MYISAM AS SELECT * FROM db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+# no rewrite, since the later option overrides the former
+--let $restore_opt=--rewrite-database=db0,db1 --rewrite-database=db0,db0
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with a single rewrite
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db1
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# fill temporary tables
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db1.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with multiple rewrites
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db1 --rewrite-database=db1,db2
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# fill temporary tables
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with multiple rewrites into same target
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db2 --rewrite-database=db1,db2
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# fill temporary tables
+INSERT db2.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with swapping rewrites
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db1 --rewrite-database=db1,db0
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# fill temporary tables
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db0.t0_temp SELECT * FROM db1.t0_data;
+INSERT db2.t0_temp SELECT * FROM db2.t0_data;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Restoring databases with permutating rewrites
+--echo ************************************************************
+
+# create temporary tables against which to compare data
+CREATE TABLE db0.t0_temp LIKE db0.t0_data;
+CREATE TABLE db1.t0_temp LIKE db1.t0_data;
+CREATE TABLE db2.t0_temp LIKE db2.t0_data;
+
+# restore NDB tables
+DELETE FROM db0.t0;
+DELETE FROM db1.t0;
+DELETE FROM db2.t0;
+--let $restore_opt=--rewrite-database=db0,db1 --rewrite-database=db1,db2
+--let $restore_opt=$restore_opt --rewrite-database=db2,db0
+--exec $restore_cmd -n 1 $restore_opt --print > /dev/null
+--exec $restore_cmd -n 2 $restore_opt --print > /dev/null
+
+# summary-check ndb tables
+SELECT COUNT(*) FROM db0.t0;
+SELECT COUNT(*) FROM db1.t0;
+SELECT COUNT(*) FROM db2.t0;
+
+# fill temporary tables
+INSERT db1.t0_temp SELECT * FROM db0.t0_data;
+INSERT db2.t0_temp SELECT * FROM db1.t0_data;
+INSERT db0.t0_temp SELECT * FROM db2.t0_data;
+
+# verify ndb tables
+SELECT COUNT(*) FROM db0.t0 NATURAL JOIN db0.t0_temp;
+SELECT COUNT(*) FROM db1.t0 NATURAL JOIN db1.t0_temp;
+SELECT COUNT(*) FROM db2.t0 NATURAL JOIN db2.t0_temp;
+
+# delete temporary tables
+DROP TABLE db0.t0_temp;
+DROP TABLE db1.t0_temp;
+DROP TABLE db2.t0_temp;
+
+--echo ************************************************************
+--echo * Deleting tables and databases
+--echo ************************************************************
+
+DROP DATABASE db0;
+DROP DATABASE db1;
+DROP DATABASE db2;

=== modified file 'mysql-test/suite/ndb/t/ndb_temporary.test'
--- a/mysql-test/suite/ndb/t/ndb_temporary.test	2007-11-29 10:29:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_temporary.test	2011-01-25 09:50:48 +0000
@@ -21,6 +21,14 @@ drop table t1;
 
 
 #
+# create temporary like on an ndb table should give an error (bug#57437)
+#
+CREATE TABLE bar ( id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=NDBCluster ;
+--error ER_CANT_CREATE_TABLE
+CREATE TEMPORARY TABLE foo LIKE bar ;
+DROP TABLE bar;
+
+#
 # if default storage engine=ndb, temporary tables
 # without explicit engine= should be created as myisam
 #

=== added file 'mysql-test/suite/ndb/t/ndbinfo_cache.test'
--- a/mysql-test/suite/ndb/t/ndbinfo_cache.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo_cache.test	2011-02-01 14:58:21 +0000
@@ -0,0 +1,31 @@
+--source include/have_query_cache.inc
+--source include/have_ndb.inc
+
+--source ndbinfo_create.inc
+
+USE ndbinfo;
+
+# BUG#59831 ndbinfo - counters not increasing after first query
+# - ndbinfo tables should never be cached in query cache
+
+# Turn on and reset query cache
+set GLOBAL query_cache_type=on;
+set GLOBAL query_cache_size=1355776;
+reset query cache;
+flush status;
+
+# Perform same query several times, which were inserted
+# in the cache  before fix but not inserted anymore
+--disable_result_log
+select * from counters;
+select * from counters;
+select * from counters;
+--enable_result_log
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_inserts";
+
+# Turn off query cache
+SET GLOBAL query_cache_size=default;
+SET GLOBAL query_cache_type=default;
+
+--source ndbinfo_drop.inc

=== modified file 'mysql-test/suite/ndb_team/t/ndb_dd_backuprestore.test'
--- a/mysql-test/suite/ndb_team/t/ndb_dd_backuprestore.test	2008-12-22 16:27:38 +0000
+++ b/mysql-test/suite/ndb_team/t/ndb_dd_backuprestore.test	2011-01-28 10:55:54 +0000
@@ -288,16 +288,22 @@ SHOW CREATE TABLE test.t5;
 
 SHOW CREATE TABLE test.t6;
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't1'; 
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't2'; 
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't3'; 
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't4'; 
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't5'; 
 
+--replace_column 13 0 14 0 15 0 16 NULL 18 0
 SELECT * FROM information_schema.partitions WHERE table_name= 't6'; 
 
 SELECT COUNT(*) FROM test.t1; 

=== modified file 'mysql-test/t/join_outer.test'
--- a/mysql-test/t/join_outer.test	2011-01-17 12:08:49 +0000
+++ b/mysql-test/t/join_outer.test	2011-02-02 15:16:35 +0000
@@ -1147,4 +1147,128 @@ SELECT * FROM
 
 DROP TABLE t1,t2,t3;
 
+
+--echo #
+--echo # Bug#58490: Incorrect result in multi level OUTER JOIN
+--echo # in combination with IS NULL
+--echo #
+
+CREATE TABLE t1 (i INT NOT NULL);
+INSERT INTO t1 VALUES (0),    (2),(3),(4);
+CREATE TABLE t2 (i INT NOT NULL);
+INSERT INTO t2 VALUES (0),(1),    (3),(4);
+CREATE TABLE t3 (i INT NOT NULL);
+INSERT INTO t3 VALUES (0),(1),(2),    (4);
+CREATE TABLE t4 (i INT NOT NULL);
+INSERT INTO t4 VALUES (0),(1),(2),(3)   ;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( t2 LEFT JOIN
+   ( t3 LEFT JOIN
+     t4
+     ON t4.i = t3.i
+   )
+   ON t3.i = t2.i
+ )
+ ON t2.i = t1.i
+ ;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( t2 LEFT JOIN
+   ( t3 LEFT JOIN
+     t4
+     ON t4.i = t3.i
+   )
+   ON t3.i = t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t4.i IS NULL;
+
+
+# Most simplified testcase to reproduce the bug.
+# (Has to be at least a two level nested outer join)
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+     t3
+     ON t3.i = t2.i
+   )
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+
+# Extended testing:
+# We then add some equi-join inside the query above:
+# (There Used to be some problems here with first
+#  proposed patch for this bug)
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+     t3
+     ON t3.i = t2.i
+   )
+   JOIN t4
+   ON t4.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+     t3
+     ON t3.i = t2.i
+   )
+   JOIN (t4 AS t4a JOIN t4 AS t4b ON t4a.i=t4b.i)
+   ON t4a.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+SELECT * FROM
+ t1 LEFT JOIN
+ ( ( t2 LEFT JOIN
+     t3
+     ON t3.i = t2.i
+   )
+   JOIN (t4 AS t4a, t4 AS t4b)
+   ON t4a.i=t2.i
+ )
+ ON t2.i = t1.i
+ WHERE t3.i IS NULL;
+
+
+DROP TABLE t1,t2,t3,t4;
+
+## Bug#49322 & bug#58490 are duplicates. However, we include testcases
+## for both.
+--echo #
+--echo # Bug#49322(Duplicate): Server is adding extra NULL row
+--echo # on processing a WHERE clause
+--echo #
+
+CREATE TABLE h (pk INT NOT NULL, col_int_key INT);
+INSERT INTO h VALUES (1,NULL),(4,2),(5,2),(3,4),(2,8);
+
+CREATE TABLE m (pk INT NOT NULL, col_int_key INT);
+INSERT INTO m VALUES (1,2),(2,7),(3,5),(4,7),(5,5),(6,NULL),(7,NULL),(8,9);
+CREATE TABLE k (pk INT NOT NULL, col_int_key INT);
+INSERT INTO k VALUES (1,9),(2,2),(3,5),(4,2),(5,7),(6,0),(7,5);
+
+# Baseline query wo/ 'WHERE ... IS NULL' - was correct
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key;
+
+# Adding 'WHERE ... IS NULL' -> incorrect result
+SELECT TABLE1.pk FROM k TABLE1
+RIGHT JOIN h TABLE2 ON TABLE1.col_int_key=TABLE2.col_int_key
+RIGHT JOIN m TABLE4 ON TABLE2.col_int_key=TABLE4.col_int_key
+WHERE TABLE1.pk IS NULL;
+
+DROP TABLE h,m,k;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2011-01-17 12:08:49 +0000
+++ b/mysql-test/t/subselect.test	2011-02-02 15:16:35 +0000
@@ -3774,4 +3774,32 @@ SELECT * FROM t1
 
 DROP TABLE t1,t1s,t2s;
 
+--echo #
+--echo # Bug #56690  Wrong results with subquery with 
+--echo # GROUP BY inside < ANY clause
+--echo #
+
+CREATE TABLE t1 (
+ pk INT NOT NULL PRIMARY KEY,
+ number INT,
+ KEY key_number (number)
+);
+INSERT INTO t1 VALUES (8,8);
+
+CREATE TABLE t2 (
+ pk INT NOT NULL PRIMARY KEY,
+ number INT,
+ KEY key_number (number)
+);
+
+INSERT INTO t2 VALUES (1,2);
+INSERT INTO t2 VALUES (2,8);
+INSERT INTO t2 VALUES (3,NULL);
+INSERT INTO t2 VALUES (4,166);
+
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2 GROUP BY number);
+SELECT * FROM t1 WHERE t1.number < ANY(SELECT number FROM t2);
+
+DROP TABLE t1,t2;
+
 --echo End of 5.1 tests

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-01-21 13:56:43 +0000
+++ b/sql/ha_ndbcluster.cc	2011-02-02 15:16:35 +0000
@@ -381,7 +381,8 @@ static uchar *ndbcluster_get_key(NDB_SHA
 
 static int ndb_get_table_statistics(THD *thd, ha_ndbcluster*, bool, Ndb*,
                                     const NdbRecord *, struct Ndb_statistics *,
-                                    bool have_lock= FALSE);
+                                    bool have_lock= FALSE,
+                                    uint part_id= ~(uint)0);
 
 THD *injector_thd= 0;
 
@@ -7159,13 +7160,36 @@ int ha_ndbcluster::info(uint flag)
 void ha_ndbcluster::get_dynamic_partition_info(PARTITION_STATS *stat_info,
                                                uint part_id)
 {
-  /* 
-     This functions should be fixed. Suggested fix: to
-     implement ndb function which retrives the statistics
-     about ndb partitions.
-  */
+  DBUG_PRINT("info", ("ha_ndbcluster::get_dynamic_partition_info"));
+
   bzero((char*) stat_info, sizeof(PARTITION_STATS));
-  return;
+  int error = 0;
+  THD *thd = table->in_use;
+
+  if (!thd)
+    thd = current_thd;
+  if (!m_table_info)
+  {
+    if ((error = check_ndb_connection(thd)))
+      goto err;
+  }
+  error = update_stats(thd, 1, false, part_id);
+
+  if (error == 0)
+  {
+    stat_info->records = stats.records;
+    stat_info->mean_rec_length = stats.mean_rec_length;
+    stat_info->data_file_length = stats.data_file_length;
+    stat_info->delete_length = stats.delete_length;
+    stat_info->max_data_file_length = stats.max_data_file_length;
+    return;
+  }
+
+err: 
+
+  DBUG_PRINT("warning", 
+    ("ha_ndbcluster::get_dynamic_partition_info failed with error code %u", 
+     error));
 }
 
 
@@ -8874,20 +8898,74 @@ static uint get_no_fragments(ulonglong m
   of number of nodes and never more than 4 times the number of nodes.
 
 */
-static bool adjusted_frag_count(uint no_fragments, 
-                                uint no_nodes,
-                                uint &reported_frags)
-{
-  uint i= 0;
-
-  // Should really depend on #replicas
-  uint max_per_node = no_nodes == 1 ? 8 : 4;
-
-  reported_frags= no_nodes;
-  while (reported_frags < no_fragments && ++i < max_per_node &&
-         (reported_frags + no_nodes) < MAX_PARTITIONS) 
-    reported_frags+= no_nodes;
-  return (reported_frags < no_fragments);
+static
+bool
+adjusted_frag_count(Ndb* ndb,
+                    uint requested_frags,
+                    uint &reported_frags)
+{
+  unsigned no_nodes= g_ndb_cluster_connection->no_db_nodes();
+  unsigned no_replicas= no_nodes == 1 ? 1 : 2;
+
+  unsigned no_threads= 1;
+  const unsigned no_nodegroups= g_ndb_cluster_connection->max_nodegroup() + 1;
+
+  {
+    /**
+     * Use SYSTAB_0 to get #replicas, and to guess #threads
+     */
+    char dbname[FN_HEADLEN+1];
+    dbname[FN_HEADLEN]= 0;
+    strnmov(dbname, ndb->getDatabaseName(), sizeof(dbname) - 1);
+    ndb->setDatabaseName("sys");
+    Ndb_table_guard ndbtab_g(ndb->getDictionary(), "SYSTAB_0");
+    const NdbDictionary::Table * tab = ndbtab_g.get_table();
+    if (tab)
+    {
+      no_replicas= ndbtab_g.get_table()->getReplicaCount();
+
+      /**
+       * Guess #threads
+       */
+      {
+        const Uint32 frags = tab->getFragmentCount();
+        Uint32 node = 0;
+        Uint32 cnt = 0;
+        for (Uint32 i = 0; i<frags; i++)
+        {
+          Uint32 replicas[4];
+          if (tab->getFragmentNodes(i, replicas, NDB_ARRAY_SIZE(replicas)))
+          {
+            if (node == replicas[0] || node == 0)
+            {
+              node = replicas[0];
+              cnt ++;
+            }
+          }
+        }
+        no_threads = cnt; // No of primary replica on 1-node
+      }
+    }
+    ndb->setDatabaseName(dbname);
+  }
+
+  const unsigned usable_nodes = no_replicas * no_nodegroups;
+  const uint max_replicas = 8 * usable_nodes * no_threads;
+
+  reported_frags = usable_nodes * no_threads; // Start with 1 frag per threads
+  Uint32 replicas = reported_frags * no_replicas;
+
+  /**
+   * Loop until requested replicas, and not exceed max-replicas
+   */
+  while (reported_frags < requested_frags &&
+         (replicas + usable_nodes * no_threads * no_replicas) <= max_replicas)
+  {
+    reported_frags += usable_nodes * no_threads;
+    replicas += usable_nodes * no_threads * no_replicas;
+  }
+
+  return (reported_frags < requested_frags);
 }
 
 
@@ -8905,6 +8983,7 @@ int ha_ndbcluster::create(const char *na
   size_t pack_length, length;
   uint i, pk_length= 0;
   uchar *data= NULL, *pack_data= NULL;
+  bool create_temporary= (create_info->options & HA_LEX_CREATE_TMP_TABLE);
   bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE);
   bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE);
   const char *tablespace= create_info->tablespace;
@@ -8913,10 +8992,24 @@ int ha_ndbcluster::create(const char *na
   bool ndb_sys_table= FALSE;
   partition_info *part_info;
   int result= 0;
+  NdbDictionary::ObjectId objId;
 
   DBUG_ENTER("ha_ndbcluster::create");
   DBUG_PRINT("enter", ("name: %s", name));
 
+  if (create_temporary)
+  {
+    /*
+      Ndb does not support temporary tables
+     */
+    my_errno= ER_ILLEGAL_HA_CREATE_OPTION;
+    DBUG_PRINT("info", ("Ndb doesn't support temporary tables"));
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                        ER_ILLEGAL_HA_CREATE_OPTION,
+                        "Ndb doesn't support temporary tables");
+    DBUG_RETURN(my_errno);
+  }
+
   DBUG_ASSERT(*fn_rext((char*)name) == 0);
   set_dbname(name);
   set_tabname(name);
@@ -8926,7 +9019,6 @@ int ha_ndbcluster::create(const char *na
   
   Ndb *ndb= get_ndb(thd);
   NDBDICT *dict= ndb->getDictionary();
-  Ndb_table_guard ndbtab_g(dict);
 
 #ifndef NDB_WITHOUT_TABLESPACE_IN_FRM
   DBUG_PRINT("info", ("Tablespace %s,%s", form->s->tablespace, create_info->tablespace));
@@ -8980,6 +9072,7 @@ int ha_ndbcluster::create(const char *na
 
   if (is_truncate)
   {
+    Ndb_table_guard ndbtab_g(dict);
     ndbtab_g.init(m_tabname);
     if (!(m_table= ndbtab_g.get_table()))
       ERR_RETURN(dict->getNdbError());
@@ -9007,7 +9100,9 @@ int ha_ndbcluster::create(const char *na
   {
     if (THDVAR(thd, table_temporary))
     {
+#ifdef DOES_NOT_WORK_CURRENTLY
       tab.setTemporary(TRUE);
+#endif
       tab.setLogging(FALSE);
     }
     else if (THDVAR(thd, table_no_logging))
@@ -9212,30 +9307,8 @@ int ha_ndbcluster::create(const char *na
       create_info->max_rows : 
       create_info->min_rows;
     uint no_fragments= get_no_fragments(rows);
-
-    uint no_nodes= g_ndb_cluster_connection->no_db_nodes();
-    {
-      /**
-       * Use SYSTAB_0 to guess #threads per node
-       */
-      ndb->setDatabaseName("sys");
-      Ndb_table_guard ndbtab_g(dict, "SYSTAB_0");
-      if (ndbtab_g.get_table())
-      {
-        Uint32 frags= ndbtab_g.get_table()->getFragmentCount();
-        if (frags > no_nodes)
-        {
-          /**
-           * And use this as argument adjusted_frag_count...
-           */
-          no_nodes= frags;
-        }
-      }
-      ndb->setDatabaseName(m_dbname);
-    }
-
     uint reported_frags= no_fragments;
-    if (adjusted_frag_count(no_fragments, no_nodes, reported_frags))
+    if (adjusted_frag_count(ndb, no_fragments, reported_frags))
     {
       push_warning(current_thd,
                    MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
@@ -9281,7 +9354,7 @@ int ha_ndbcluster::create(const char *na
   }
 
   // Create the table in NDB     
-  if (dict->createTable(tab) != 0) 
+  if (dict->createTable(tab, &objId) != 0)
   {
     const NdbError err= dict->getNdbError();
     set_ndb_err(thd, err);
@@ -9289,26 +9362,14 @@ int ha_ndbcluster::create(const char *na
     goto abort;
   }
 
-  ndbtab_g.init(m_tabname);
-  // temporary set m_table during create
-  // reset at return
-  m_table= ndbtab_g.get_table();
-  // TODO check also that we have the same frm...
-  if (!m_table)
-  {
-    /* purecov: begin deadcode */
-    const NdbError err= dict->getNdbError();
-    set_ndb_err(thd, err);
-    my_errno= ndb_to_mysql_error(&err);
-    goto abort;
-    /* purecov: end */
-  }
-
   DBUG_PRINT("info", ("Table %s/%s created successfully", 
                       m_dbname, m_tabname));
 
   // Create secondary indexes
+  tab.assignObjId(objId);
+  m_table= &tab;
   my_errno= create_indexes(thd, ndb, form);
+  m_table= 0;
 
   if (!my_errno)
   {
@@ -9344,6 +9405,13 @@ err_return:
     m_table= 0;
     ERR_RETURN(dict->getNdbError());
   }
+
+  /**
+   * createTable/index schema transaction OK
+   */
+  Ndb_table_guard ndbtab_g(dict, m_tabname);
+  m_table= ndbtab_g.get_table();
+
   if (my_errno)
   {
     /*
@@ -11102,11 +11170,18 @@ static void ndbcluster_drop_database(han
 int ndb_create_table_from_engine(THD *thd, const char *db,
                                  const char *table_name)
 {
+  // Copy db and table_name to stack buffers since functions used by
+  // ha_create_table_from_engine may convert to lowercase on some platforms
+  char db_buf[FN_REFLEN + 1];
+  char table_name_buf[FN_REFLEN + 1];
+  strnmov(db_buf, db, sizeof(db_buf));
+  strnmov(table_name_buf, table_name, sizeof(table_name_buf));
+
   LEX *old_lex= thd->lex, newlex;
   thd->lex= &newlex;
   newlex.current_select= NULL;
   lex_start(thd);
-  int res= ha_create_table_from_engine(thd, db, table_name);
+  int res= ha_create_table_from_engine(thd, db_buf, table_name_buf);
   thd->lex= old_lex;
   return res;
 }
@@ -12794,7 +12869,8 @@ struct ndb_table_statistics_row {
 
 int ha_ndbcluster::update_stats(THD *thd,
                                 bool do_read_stat,
-                                bool have_lock)
+                                bool have_lock,
+                                uint part_id)
 {
   struct Ndb_statistics stat;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -12808,7 +12884,7 @@ int ha_ndbcluster::update_stats(THD *thd
     }
     if (int err= ndb_get_table_statistics(thd, this, TRUE, ndb,
                                           m_ndb_record, &stat,
-                                          have_lock))
+                                          have_lock, part_id))
     {
       DBUG_RETURN(err);
     }
@@ -12834,21 +12910,34 @@ int ha_ndbcluster::update_stats(THD *thd
   stats.mean_rec_length= stat.row_size;
   stats.data_file_length= stat.fragment_memory;
   stats.records= stat.row_count + no_uncommitted_rows_count;
+  stats.max_data_file_length= stat.fragment_extent_space;
+  stats.delete_length= stat.fragment_extent_free_space;
+
   DBUG_PRINT("exit", ("stats.records: %d  "
                       "stat->row_count: %d  "
-                      "no_uncommitted_rows_count: %d",
+                      "no_uncommitted_rows_count: %d"
+                      "stat->fragment_extent_space: %u  "
+                      "stat->fragment_extent_free_space: %u",
                       (int)stats.records,
                       (int)stat.row_count,
-                      (int)no_uncommitted_rows_count));
+                      (int)no_uncommitted_rows_count,
+                      (uint)stat.fragment_extent_space,
+                      (uint)stat.fragment_extent_free_space));
   DBUG_RETURN(0);
 }
 
+/* If part_id contains a legal partition id, ndbstat returns the
+   partition-statistics pertaining to that partition only.
+   Otherwise, it returns the table-statistics,
+   which is an aggregate over all partitions of that table.
+ */
 static 
 int
 ndb_get_table_statistics(THD *thd, ha_ndbcluster* file, bool report_error, Ndb* ndb,
                          const NdbRecord *record,
                          struct Ndb_statistics * ndbstat,
-                         bool have_lock)
+                         bool have_lock,
+                         uint part_id)
 {
   Thd_ndb *thd_ndb= get_thd_ndb(current_thd);
   NdbTransaction* pTrans;
@@ -12857,12 +12946,11 @@ ndb_get_table_statistics(THD *thd, ha_nd
   int reterr= 0;
   int retry_sleep= 30; /* 30 milliseconds */
   const char *dummyRowPtr;
-  const Uint32 extraCols= 5;
-  NdbOperation::GetValueSpec extraGets[extraCols];
-  Uint64 rows, commits, fixed_mem, var_mem;
-  Uint32 size;
+  NdbOperation::GetValueSpec extraGets[8];
+  Uint64 rows, commits, fixed_mem, var_mem, ext_space, free_ext_space;
+  Uint32 size, fragid;
 #ifndef DBUG_OFF
-  char buff[22], buff2[22], buff3[22], buff4[22];
+  char buff[22], buff2[22], buff3[22], buff4[22], buff5[22], buff6[22];
 #endif
   DBUG_ENTER("ndb_get_table_statistics");
 
@@ -12883,6 +12971,12 @@ ndb_get_table_statistics(THD *thd, ha_nd
   extraGets[3].appStorage= &fixed_mem;
   extraGets[4].column= NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
   extraGets[4].appStorage= &var_mem;
+  extraGets[5].column= NdbDictionary::Column::FRAGMENT_EXTENT_SPACE;
+  extraGets[5].appStorage= &ext_space;
+  extraGets[6].column= NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE;
+  extraGets[6].appStorage= &free_ext_space;
+  extraGets[7].column= NdbDictionary::Column::FRAGMENT;
+  extraGets[7].appStorage= &fragid;
 
   const Uint32 codeWords= 1;
   Uint32 codeSpace[ codeWords ];
@@ -12905,6 +12999,8 @@ ndb_get_table_statistics(THD *thd, ha_nd
     Uint64 sum_commits= 0;
     Uint64 sum_row_size= 0;
     Uint64 sum_mem= 0;
+    Uint64 sum_ext_space= 0;
+    Uint64 sum_free_ext_space= 0;
     NdbScanOperation*pOp;
     int check;
 
@@ -12921,7 +13017,7 @@ ndb_get_table_statistics(THD *thd, ha_nd
     /* Set batch_size=1, as we need only one row per fragment. */
     options.batch= 1;
     options.extraGetValues= &extraGets[0];
-    options.numExtraGetValues= extraCols;
+    options.numExtraGetValues= sizeof(extraGets)/sizeof(extraGets[0]); 
     options.interpretedCode= &code;
 
     if ((pOp= pTrans->scanTable(record, NdbOperation::LM_CommittedRead,
@@ -12947,14 +13043,31 @@ ndb_get_table_statistics(THD *thd, ha_nd
     
     while ((check= pOp->nextResult(&dummyRowPtr, TRUE, TRUE)) == 0)
     {
-      DBUG_PRINT("info", ("nextResult rows: %d  commits: %d",
-                          (int)rows, (int)commits));
+      DBUG_PRINT("info", ("nextResult rows: %d  commits: %d"
+                          "fixed_mem_size %d var_mem_size %d "
+                          "fragmentid %d extent_space %d free_extent_space %d",
+                          (int)rows, (int)commits, (int)fixed_mem,
+                          (int)var_mem, (int)fragid, (int)ext_space,
+                          (int)free_ext_space));
+
+      if ((part_id != ~(uint)0) && fragid != part_id)
+      {
+        continue;
+      }
+
       sum_rows+= rows;
       sum_commits+= commits;
       if (sum_row_size < size)
         sum_row_size= size;
       sum_mem+= fixed_mem + var_mem;
       count++;
+      sum_ext_space += ext_space;
+      sum_free_ext_space += free_ext_space;
+
+      if ((part_id != ~(uint)0) && fragid == part_id)
+      {
+        break;
+      }
     }
     
     if (check == -1)
@@ -12971,13 +13084,19 @@ ndb_get_table_statistics(THD *thd, ha_nd
     ndbstat->commit_count= sum_commits;
     ndbstat->row_size= (ulong)sum_row_size;
     ndbstat->fragment_memory= sum_mem;
+    ndbstat->fragment_extent_space= sum_ext_space;
+    ndbstat->fragment_extent_free_space= sum_free_ext_space;
 
     DBUG_PRINT("exit", ("records: %s  commits: %s "
-                        "row_size: %s  mem: %s count: %u",
+                        "row_size: %s  mem: %s "
+                        "allocated: %s  free: %s "
+                        "count: %u",
 			llstr(sum_rows, buff),
                         llstr(sum_commits, buff2),
                         llstr(sum_row_size, buff3),
                         llstr(sum_mem, buff4),
+                        llstr(sum_ext_space, buff5),
+                        llstr(sum_free_ext_space, buff6),
                         count));
 
     DBUG_RETURN(0);
@@ -14295,39 +14414,38 @@ ndbcluster_show_status(handlerton *hton,
 
 int ha_ndbcluster::get_default_no_partitions(HA_CREATE_INFO *create_info)
 {
+  if (unlikely(g_ndb_cluster_connection->get_no_ready() <= 0))
+  {
+err:
+    my_error(HA_ERR_NO_CONNECTION, MYF(0));
+    return -1;
+  }
+
+  THD* thd = current_thd;
+  if (thd == 0)
+    goto err;
+  Thd_ndb * thd_ndb = get_thd_ndb(thd);
+  if (thd_ndb == 0)
+    goto err;
+
   ha_rows max_rows, min_rows;
   if (create_info)
   {
     max_rows= create_info->max_rows;
     min_rows= create_info->min_rows;
-    
-    /**
-     * we hate this method...just return 1??
-     */
-    return 1;
   }
   else
   {
     max_rows= table_share->max_rows;
     min_rows= table_share->min_rows;
   }
+  uint no_fragments= get_no_fragments(max_rows >= min_rows ?
+                                      max_rows : min_rows);
   uint reported_frags;
-  uint no_fragments=
-    get_no_fragments(max_rows >= min_rows ? max_rows : min_rows);
-  if (unlikely(g_ndb_cluster_connection->get_no_ready() <= 0))
-  {
-    my_error(HA_ERR_NO_CONNECTION, MYF(0));
-    return -1;
-  }
-  uint no_nodes= g_ndb_cluster_connection->no_db_nodes();
-
-  if (adjusted_frag_count(no_fragments, no_nodes, reported_frags))
-  {
-    push_warning(current_thd,
-                 MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
-    "Ndb might have problems storing the max amount of rows specified");
-  }
-  return (int)reported_frags;
+  adjusted_frag_count(thd_ndb->ndb,
+                      no_fragments,
+                      reported_frags);
+  return reported_frags;
 }
 
 uint32 ha_ndbcluster::calculate_key_hash_value(Field **field_array)

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2011-01-18 08:17:07 +0000
+++ b/sql/ha_ndbcluster.h	2011-02-02 15:16:35 +0000
@@ -174,6 +174,8 @@ struct Ndb_statistics {
   Uint64 commit_count;
   ulong row_size;
   Uint64 fragment_memory;
+  Uint64 fragment_extent_space; 
+  Uint64 fragment_extent_free_space;
 };
 
 typedef struct st_ndbcluster_share {
@@ -963,7 +965,8 @@ private:
   NdbIndexScanOperation *m_multi_cursor;
   Ndb *get_ndb(THD *thd);
 
-  int update_stats(THD *thd, bool do_read_stat, bool have_lock= FALSE);
+  int update_stats(THD *thd, bool do_read_stat, bool have_lock= FALSE,
+                   uint part_id= ~(uint)0);
 };
 
 int ndbcluster_discover(THD* thd, const char* dbname, const char* name,

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-01-14 14:37:28 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-01-28 08:13:59 +0000
@@ -1650,6 +1650,19 @@ struct Cluster_schema
   uint32 any_value;
 };
 
+static void
+print_could_not_discover_error(THD *thd,
+                               const Cluster_schema *schema)
+{
+  sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
+                  "binlog schema event '%s' from node %d. "
+                  "my_errno: %d",
+                   schema->db, schema->name, schema->query,
+                   schema->node_id, my_errno);
+  print_warning_list("NDB Binlog", thd_warn_list(thd));
+}
+
+
 /*
   Transfer schema table data into corresponding struct
 */
@@ -2803,12 +2816,7 @@ ndb_binlog_thread_handle_schema_event(TH
           }
           else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
-            sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
-                            "binlog schema event '%s' from node %d. "
-                            "my_errno: %d",
-                            schema->db, schema->name, schema->query,
-                            schema->node_id, my_errno);
-            print_warning_list("NDB Binlog", thd_warn_list(thd));
+            print_could_not_discover_error(thd, schema);
           }
           mysql_mutex_unlock(&LOCK_open);
           log_query= 1;
@@ -3181,11 +3189,7 @@ ndb_binlog_thread_handle_schema_event_po
           }
           else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
-            sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
-                            "binlog schema event '%s' from node %d. my_errno: %d",
-                            schema->db, schema->name, schema->query,
-                            schema->node_id, my_errno);
-            print_warning_list("NDB Binlog", thd_warn_list(thd));
+            print_could_not_discover_error(thd, schema);
           }
           mysql_mutex_unlock(&LOCK_open);
         }
@@ -3360,11 +3364,7 @@ ndb_binlog_thread_handle_schema_event_po
           }
           else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
           {
-            sql_print_error("NDB Binlog: Could not discover table '%s.%s' from "
-                            "binlog schema event '%s' from node %d. my_errno: %d",
-                            schema->db, schema->name, schema->query,
-                            schema->node_id, my_errno);
-            print_warning_list("NDB Binlog", thd_warn_list(thd));
+            print_could_not_discover_error(thd, schema);
           }
           mysql_mutex_unlock(&LOCK_open);
         }
@@ -3423,11 +3423,14 @@ struct ndb_binlog_index_row {
   struct ndb_binlog_index_row *next;
 };
 
+
 /*
-  Open the ndb_binlog_index table
+  Open the ndb_binlog_index table for writing
 */
-static int open_and_lock_ndb_binlog_index(THD *thd, TABLE_LIST *tables,
-                                          TABLE **ndb_binlog_index)
+static int
+ndb_binlog_index_table__open(THD *thd,
+                             TABLE_LIST *tables,
+                             TABLE **ndb_binlog_index)
 {
   const char *save_proc_info= thd->proc_info;
 
@@ -3455,12 +3458,13 @@ static int open_and_lock_ndb_binlog_inde
   return 0;
 }
 
+
 /*
-  Insert one row in the ndb_binlog_index
+  Write rows to the ndb_binlog_index table
 */
-
 static int
-ndb_add_ndb_binlog_index(THD *thd, ndb_binlog_index_row *row)
+ndb_binlog_index_table__write_rows(THD *thd,
+                                   ndb_binlog_index_row *row)
 {
   int error= 0;
   ndb_binlog_index_row *first= row;
@@ -3473,7 +3477,7 @@ ndb_add_ndb_binlog_index(THD *thd, ndb_b
   */
   tmp_disable_binlog(thd);
 
-  if (open_and_lock_ndb_binlog_index(thd, &binlog_tables, &ndb_binlog_index))
+  if (ndb_binlog_index_table__open(thd, &binlog_tables, &ndb_binlog_index))
   {
     sql_print_error("NDB Binlog: Unable to lock table ndb_binlog_index");
     error= -1;
@@ -6728,7 +6732,7 @@ restart_cluster_failure:
           DBUG_PRINT("info", ("COMMIT gci: %lu", (ulong) gci));
           if (opt_ndb_log_binlog_index)
           {
-            if (ndb_add_ndb_binlog_index(thd, rows))
+            if (ndb_binlog_index_table__write_rows(thd, rows))
             {
               /* 
                  Writing to ndb_binlog_index failed, check if we are
@@ -6740,7 +6744,7 @@ restart_cluster_failure:
                 volatile THD::killed_state killed= thd->killed;
                 /* We are cleaning up, allow for flushing last epoch */
                 thd->killed= THD::NOT_KILLED;
-                ndb_add_ndb_binlog_index(thd, rows);
+                ndb_binlog_index_table__write_rows(thd, rows);
                 /* Restore kill flag */
                 thd->killed= killed;
                 (void) mysql_mutex_unlock(&LOCK_thread_count);

=== modified file 'sql/ha_ndbcluster_tables.h'
--- a/sql/ha_ndbcluster_tables.h	2009-05-27 12:11:46 +0000
+++ b/sql/ha_ndbcluster_tables.h	2011-01-21 08:38:59 +0000
@@ -17,12 +17,9 @@
 */
 
 #define NDB_REP_DB      "mysql"
-#define OLD_NDB_REP_DB  "cluster"
 #define NDB_REP_TABLE   "ndb_binlog_index"
 #define NDB_APPLY_TABLE "ndb_apply_status"
-#define OLD_NDB_APPLY_TABLE "apply_status"
 #define NDB_SCHEMA_TABLE "ndb_schema"
-#define OLD_NDB_SCHEMA_TABLE "schema"
 #define NDB_REPLICATION_TABLE "ndb_replication"
 
 enum Ndb_binlog_type

=== modified file 'sql/ha_ndbinfo.h'
--- a/sql/ha_ndbinfo.h	2010-01-25 10:04:59 +0000
+++ b/sql/ha_ndbinfo.h	2011-02-01 14:58:21 +0000
@@ -72,6 +72,11 @@ public:
 
   bool get_error_message(int error, String *buf);
 
+  uint8 table_cache_type() {
+    // Don't put ndbinfo results in query cache
+    return HA_CACHE_TBL_NOCACHE;
+  }
+
 private:
   void unpack_record(uchar *dst_row);
 

=== modified file 'sql/rpl_injector.cc'
--- a/sql/rpl_injector.cc	2010-03-12 06:06:23 +0000
+++ b/sql/rpl_injector.cc	2011-02-01 14:58:55 +0000
@@ -93,6 +93,7 @@ int injector::transaction::commit()
    DBUG_RETURN(error);
 }
 
+#ifndef MCP_BUG58082
 int injector::transaction::rollback()
 {
    DBUG_ENTER("injector::transaction::rollback()");
@@ -100,6 +101,7 @@ int injector::transaction::rollback()
    end_trans(m_thd, ROLLBACK);
    DBUG_RETURN(0);
 }
+#endif
 
 int injector::transaction::use_table(server_id_type sid, table tbl)
 {

=== modified file 'sql/rpl_injector.h'
--- a/sql/rpl_injector.h	2009-05-26 18:53:34 +0000
+++ b/sql/rpl_injector.h	2011-02-01 14:58:55 +0000
@@ -212,6 +212,7 @@ public:
       */
       int commit();
 
+#ifndef MCP_BUG58082
       /*
         Rollback a transaction.
 
@@ -219,6 +220,7 @@ public:
         for example, releasing resource and unlocking files.
       */
       int rollback();
+#endif
 
       /*
         Get the position for the start of the transaction.

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-10-20 11:10:46 +0000
+++ b/sql/sql_class.cc	2011-02-02 09:15:56 +0000
@@ -2394,6 +2394,14 @@ bool select_max_min_finder_subselect::cm
 {
   Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0);
   double val1= cache->val_real(), val2= maxmin->val_real();
+#ifndef MCP_BUG56690
+  if (cache->null_value)
+    return false;
+  else if (maxmin->null_value)
+    return true;
+  else 
+    return (fmax) ? (val1 > val2) : (val1 < val2);
+#else
   if (fmax)
     return (cache->null_value && !maxmin->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
@@ -2401,12 +2409,21 @@ bool select_max_min_finder_subselect::cm
   return (maxmin->null_value && !cache->null_value) ||
     (!cache->null_value && !maxmin->null_value &&
      val1 < val2);
+#endif
 }
 
 bool select_max_min_finder_subselect::cmp_int()
 {
   Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0);
   longlong val1= cache->val_int(), val2= maxmin->val_int();
+#ifndef MCP_BUG56690
+  if (cache->null_value)
+    return false;
+  else if (maxmin->null_value)
+    return true;
+  else 
+    return (fmax) ? (val1 > val2) : (val1 < val2);
+#else
   if (fmax)
     return (cache->null_value && !maxmin->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
@@ -2414,6 +2431,7 @@ bool select_max_min_finder_subselect::cm
   return (maxmin->null_value && !cache->null_value) ||
     (!cache->null_value && !maxmin->null_value &&
      val1 < val2);
+#endif
 }
 
 bool select_max_min_finder_subselect::cmp_decimal()
@@ -2421,6 +2439,16 @@ bool select_max_min_finder_subselect::cm
   Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0);
   my_decimal cval, *cvalue= cache->val_decimal(&cval);
   my_decimal mval, *mvalue= maxmin->val_decimal(&mval);
+#ifndef MCP_BUG56690
+  if (cache->null_value)
+    return false;
+  else if (maxmin->null_value)
+    return true;
+  else 
+    return (fmax) 
+      ? (my_decimal_cmp(cvalue,mvalue) > 0)
+      : (my_decimal_cmp(cvalue,mvalue) < 0);
+#else
   if (fmax)
     return (cache->null_value && !maxmin->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
@@ -2428,6 +2456,7 @@ bool select_max_min_finder_subselect::cm
   return (maxmin->null_value && !cache->null_value) ||
     (!cache->null_value && !maxmin->null_value &&
      my_decimal_cmp(cvalue,mvalue) < 0);
+#endif
 }
 
 bool select_max_min_finder_subselect::cmp_str()
@@ -2440,6 +2469,16 @@ bool select_max_min_finder_subselect::cm
   */
   val1= cache->val_str(&buf1);
   val2= maxmin->val_str(&buf1);
+#ifndef MCP_BUG56690
+  if (cache->null_value)
+    return false;
+  else if (maxmin->null_value)
+    return true;
+  else 
+    return (fmax) 
+      ? (sortcmp(val1, val2, cache->collation.collation) > 0)
+      : (sortcmp(val1, val2, cache->collation.collation) < 0);
+#else
   if (fmax)
     return (cache->null_value && !maxmin->null_value) ||
       (!cache->null_value && !maxmin->null_value &&
@@ -2447,6 +2486,7 @@ bool select_max_min_finder_subselect::cm
   return (maxmin->null_value && !cache->null_value) ||
     (!cache->null_value && !maxmin->null_value &&
      sortcmp(val1, val2, cache->collation.collation) < 0);
+#endif
 }
 
 bool select_exists_subselect::send_data(List<Item> &items)

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-10-29 20:45:08 +0000
+++ b/sql/sql_class.h	2011-02-02 15:16:35 +0000
@@ -2835,6 +2835,9 @@ public:
   {}
   void cleanup();
   bool send_data(List<Item> &items);
+#ifndef MCP_BUG56690
+private:
+#endif
   bool cmp_real();
   bool cmp_int();
   bool cmp_decimal();

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-01-17 12:08:49 +0000
+++ b/sql/sql_select.cc	2011-02-02 15:16:35 +0000
@@ -11703,18 +11703,44 @@ evaluate_join_record(JOIN *join, JOIN_TA
       first_unmatched->found= 1;
       for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++)
       {
-        if (tab->table->reginfo.not_exists_optimize)
-          rc= NESTED_LOOP_NO_MORE_ROWS;
-
         /* Check all predicates that has just been activated. */
         /*
           Actually all predicates non-guarded by first_unmatched->found
           will be re-evaluated again. It could be fixed, but, probably,
           it's not worth doing now.
         */
+#ifndef MCP_BUG58490
+        /*
+          not_exists_optimize has been created from a
+          select_cond containing 'is_null'. This 'is_null'
+          predicate is still present on any 'tab' with
+          'not_exists_optimize'. Furthermore, the usual rules
+          for condition guards also applies for
+          'not_exists_optimize' -> When 'is_null==false' we
+          know all cond. guards are open and we can apply
+          the 'not_exists_optimize'.
+        */
+        DBUG_ASSERT(!(tab->table->reginfo.not_exists_optimize &&
+                     !tab->select_cond));
+#endif
+
         if (tab->select_cond && !tab->select_cond->val_int())
         {
           /* The condition attached to table tab is false */
+
+#ifndef MCP_BUG58490
+          if (tab->table->reginfo.not_exists_optimize)
+          {
+            /*
+              When not_exists_optimize is set: No need to further
+              explore more rows of 'tab' for this partial result.
+              Any found 'tab' matches are known to evaluate to 'false'.
+              Returning .._NO_MORE_ROWS will skip rem. 'tab' rows.
+            */
+            return NESTED_LOOP_NO_MORE_ROWS;
+          }
+#endif
+
           if (tab == join_tab)
             found= 0;
           else

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-10-12 14:53:28 +0000
+++ b/sql/sql_table.cc	2011-01-25 10:07:17 +0000
@@ -5402,9 +5402,9 @@ bool mysql_create_like_table(THD* thd, T
   err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
   VOID(pthread_mutex_unlock(&LOCK_open));
 
-  if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
+  if (!err && create_info->options & HA_LEX_CREATE_TMP_TABLE)
   {
-    if (err || !open_temporary_table(thd, dst_path, db, table_name, 1,
+    if (!open_temporary_table(thd, dst_path, db, table_name, 1,
                                      OTM_OPEN))
     {
       (void) rm_temporary_table(create_info->db_type,

=== modified file 'storage/ndb/docs/doxygen/Doxyfile.mgmapi'
--- a/storage/ndb/docs/doxygen/Doxyfile.mgmapi	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/docs/doxygen/Doxyfile.mgmapi	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # Doxyfile 1.2.12
 
 # This file describes the settings to be used by the documentation system

=== modified file 'storage/ndb/docs/doxygen/Doxyfile.ndb'
--- a/storage/ndb/docs/doxygen/Doxyfile.ndb	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/docs/doxygen/Doxyfile.ndb	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # Doxyfile 1.2.14
 
 # This file describes the settings to be used by the documentation system

=== modified file 'storage/ndb/docs/doxygen/Doxyfile.ndbapi'
--- a/storage/ndb/docs/doxygen/Doxyfile.ndbapi	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/docs/doxygen/Doxyfile.ndbapi	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # Doxyfile 1.2.12
 
 # This file describes the settings to be used by the documentation system

=== modified file 'storage/ndb/docs/doxygen/Doxyfile.odbc'
--- a/storage/ndb/docs/doxygen/Doxyfile.odbc	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/docs/doxygen/Doxyfile.odbc	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # Doxyfile 1.2.14
 
 # This file describes the settings to be used by the documentation system

=== modified file 'storage/ndb/docs/doxygen/postdoxy.pl'
--- a/storage/ndb/docs/doxygen/postdoxy.pl	2008-11-14 16:29:38 +0000
+++ b/storage/ndb/docs/doxygen/postdoxy.pl	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 #
 #  Written by Lars Thalmann, lars@stripped, 2003.
 #

=== modified file 'storage/ndb/docs/doxygen/predoxy.pl'
--- a/storage/ndb/docs/doxygen/predoxy.pl	2010-02-11 10:55:30 +0000
+++ b/storage/ndb/docs/doxygen/predoxy.pl	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2003, 2005 MySQL AB, 2010 Sun Microsystems, Inc.
+#
+# 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
+
 #
 #  Written by Lars Thalmann, lars@stripped, 2003.
 #
@@ -21,7 +36,7 @@ print OUTFILE "Documentation generated "
     " from mysql source files.";
 print OUTFILE<<EOT;
 <br>
-&copy; 2003-2004 MySQL AB
+&copy; 2003, 2005 MySQL AB, 2010 Sun Microsystems, Inc.
 <br>
 </center>
 </small></address>

=== modified file 'storage/ndb/include/CMakeLists.txt'
--- a/storage/ndb/include/CMakeLists.txt	2010-08-04 14:00:24 +0000
+++ b/storage/ndb/include/CMakeLists.txt	2011-01-26 08:45:32 +0000
@@ -26,29 +26,49 @@ CONFIGURE_FILE(ndb_types.h.in
                @ONLY)
 
 #
+# Read a value for variable from ndb_configure.m4
+#
+MACRO(NDB_GET_CONFIG_VALUE keyword var)
+ IF(NOT ${var})
+   # Read the line which contains the keyword
+   FILE (STRINGS ${NDB_SOURCE_DIR}/ndb_configure.m4 str
+         REGEX "^[ ]*${keyword}=")
+   IF(str)
+     # Remove the keyword=
+     STRING(REPLACE "${keyword}=" "" str ${str})
+     # Remove whitespace
+     STRING(REGEX REPLACE "[ ].*" "" str "${str}")
+     SET(${var} ${str})
+   ENDIF()
+ ENDIF()
+ENDMACRO()
+
+#
 # Read ndb_configure.m4 and extract the NDB_VERSION_XX=YY variables
 #
-FILE(READ "${CMAKE_SOURCE_DIR}/storage/ndb/ndb_configure.m4" CONFIGURE_IN)
 
-# NDB_VERSION_MAJOR
-STRING(REGEX REPLACE ".*NDB_VERSION_MAJOR=([0-9]+).*"
-        "\\1" PARSE_NDB_VERSION_MAJOR "${CONFIGURE_IN}")
-SET(NDB_VERSION_MAJOR "${PARSE_NDB_VERSION_MAJOR}" CACHE STRING "NDB Major Version" FORCE)
-
-# NDB_VERSION_MINOR
-STRING(REGEX REPLACE ".*NDB_VERSION_MINOR=([0-9]+).*"
-        "\\1" PARSE_NDB_VERSION_MINOR "${CONFIGURE_IN}")
-SET(NDB_VERSION_MINOR "${PARSE_NDB_VERSION_MINOR}" CACHE STRING "NDB Minor Version" FORCE)
-
-# NDB_VERSION_BUILD
-STRING(REGEX REPLACE ".*NDB_VERSION_BUILD=([0-9]+).*"
-        "\\1" PARSE_NDB_VERSION_BUILD "${CONFIGURE_IN}")
-SET(NDB_VERSION_BUILD "${PARSE_NDB_VERSION_BUILD}" CACHE STRING "NDB Build Version" FORCE)
-
-# NDB_VERSION_STATUS               
-STRING(REGEX REPLACE ".*NDB_VERSION_STATUS=\"([^\"]+)\".*"
-        "\\1" PARSE_NDB_VERSION_STATUS "${CONFIGURE_IN}")
-SET(NDB_VERSION_STATUS "${NDB_VERSION_STATUS}" CACHE STRING "NDB Status Version" FORCE)
+NDB_GET_CONFIG_VALUE(NDB_VERSION_MAJOR major)
+SET(NDB_VERSION_MAJOR "${major}" CACHE INTERNAL "NDB Major Version" FORCE)
+
+NDB_GET_CONFIG_VALUE(NDB_VERSION_MINOR minor)
+SET(NDB_VERSION_MINOR "${minor}" CACHE INTERNAL "NDB Minor Version" FORCE)
+
+NDB_GET_CONFIG_VALUE(NDB_VERSION_BUILD build)
+SET(NDB_VERSION_BUILD "${build}" CACHE INTERNAL "NDB Build Version" FORCE)
+
+NDB_GET_CONFIG_VALUE(NDB_VERSION_STATUS status)
+# Trim surrounding "'s from status
+STRING(REGEX REPLACE "\"" "" status "${status}")
+SET(NDB_VERSION_STATUS "${status}" CACHE INTERNAL "NDB Status Version" FORCE)
+
+IF(NOT DEFINED NDB_VERSION_MAJOR OR
+   NOT DEFINED NDB_VERSION_MINOR OR
+   NOT DEFINED NDB_VERSION_BUILD)
+  MESSAGE(STATUS "NDB_VERSION_MAJOR: ${NDB_VERSION_MAJOR}")
+  MESSAGE(STATUS "NDB_VERSION_MINOR: ${NDB_VERSION_MINOR}")
+  MESSAGE(STATUS "NDB_VERSION_BUILD: ${NDB_VERSION_BUILD}")
+  MESSAGE(FATAL_ERROR "Couldn't parse version numbers from ndb_configure.m4")
+ENDIF()
 
 # Create ndb_version.h
 CONFIGURE_FILE(ndb_version.h.in

=== modified file 'storage/ndb/include/kernel/signaldata/ConfigChange.hpp'
--- a/storage/ndb/include/kernel/signaldata/ConfigChange.hpp	2010-09-21 06:04:04 +0000
+++ b/storage/ndb/include/kernel/signaldata/ConfigChange.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 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

=== modified file 'storage/ndb/include/kernel/signaldata/GCP.hpp'
--- a/storage/ndb/include/kernel/signaldata/GCP.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/include/kernel/signaldata/GCP.hpp	2011-01-28 13:54:32 +0000
@@ -55,7 +55,8 @@ struct GCPCommit // Distr. DIH-DIH
 
 struct GCPNoMoreTrans // Local DIH/TC
 {
-  STATIC_CONST( SignalLength = 3 );
+  STATIC_CONST( SignalLength = 4 );
+  Uint32 senderRef;
   Uint32 senderData;
   Uint32 gci_hi;
   Uint32 gci_lo;

=== modified file 'storage/ndb/include/mgmcommon/IPCConfig.hpp'
--- a/storage/ndb/include/mgmcommon/IPCConfig.hpp	2010-12-15 06:07:35 +0000
+++ b/storage/ndb/include/mgmcommon/IPCConfig.hpp	2011-01-30 23:13:49 +0000
@@ -1,6 +1,5 @@
 /* 
-   Copyright (C) 2003-2008 MySQL AB, Sun Microsystems Inc.
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 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

=== modified file 'storage/ndb/include/ndb_version.h.in'
--- a/storage/ndb/include/ndb_version.h.in	2011-01-26 08:51:30 +0000
+++ b/storage/ndb/include/ndb_version.h.in	2011-02-02 15:16:35 +0000
@@ -557,4 +557,22 @@ ndbd_fail_rep_source_node(Uint32 x)
   }
 }
 
+
+#define NDBD_SYNC_REQ_SUPPORT_70 NDB_MAKE_VERSION(7,0,20)
+#define NDBD_SYNC_REQ_SUPPORT_71 NDB_MAKE_VERSION(7,1,9)
+
+static
+inline
+int
+ndbd_sync_req_support(Uint32 x)
+{
+  const Uint32 major = (x >> 16) & 0xFF;
+  const Uint32 minor = (x >>  8) & 0xFF;
+
+  if (major == 7 && minor == 0)
+    return x >= NDBD_SYNC_REQ_SUPPORT_70;
+
+  return x >= NDBD_SYNC_REQ_SUPPORT_71;
+}
+
 #endif

=== modified file 'storage/ndb/include/ndbapi/NdbDictionary.hpp'
--- a/storage/ndb/include/ndbapi/NdbDictionary.hpp	2010-10-15 14:42:00 +0000
+++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp	2011-02-02 15:16:35 +0000
@@ -1047,6 +1047,14 @@ public:
      *   passing NULL pointer will equal to bitmap with all columns set
      */
     int checkColumns(const Uint32* bitmap, unsigned len_in_bytes) const;
+
+    /**
+     * Set tableId,tableVersion on a table...
+     *   this is a "work-around" since createIndex can't (currently)
+     *   accept an ObjectId instead of table-object in createIndex
+     *   this as way way too much stuff is pushed into NdbDictInterface
+     */
+    void assignObjId(const ObjectId &);
 #endif
 
     // these 2 are not de-doxygenated
@@ -2217,6 +2225,14 @@ public:
     int createTable(const Table &table);
 
     /**
+     * Create defined table given defined Table instance
+     *   return ObjectId
+     * @param table Table to create
+     * @return 0 if successful otherwise -1.
+     */
+    int createTable(const Table &table, ObjectId * objid);
+
+    /**
      * Start table optimization given defined table object
      * @param t Object of table to optimize
      * @param Pre-allocated OptimizeTableHandle

=== modified file 'storage/ndb/include/ndbapi/ndb_cluster_connection.hpp'
--- a/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	2010-11-15 09:23:10 +0000
+++ b/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	2011-01-28 11:26:27 +0000
@@ -177,6 +177,7 @@ public:
   void set_optimized_node_selection(int val);
 
   unsigned no_db_nodes();
+  unsigned max_nodegroup();
   unsigned node_id();
   unsigned get_connect_count() const;
 

=== modified file 'storage/ndb/include/portlib/NdbDir.hpp'
--- a/storage/ndb/include/portlib/NdbDir.hpp	2010-11-18 10:03:45 +0000
+++ b/storage/ndb/include/portlib/NdbDir.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 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

=== modified file 'storage/ndb/include/portlib/NdbMutex.h'
--- a/storage/ndb/include/portlib/NdbMutex.h	2009-12-17 00:05:47 +0000
+++ b/storage/ndb/include/portlib/NdbMutex.h	2011-01-26 08:34:31 +0000
@@ -30,7 +30,25 @@ extern "C" {
 #else
 #include <pthread.h>
 #endif
+#ifndef NDB_MUTEX_STAT
 typedef pthread_mutex_t NdbMutex;
+#else
+typedef struct {
+  pthread_mutex_t mutex;
+  unsigned cnt_lock;
+  unsigned cnt_lock_contention;
+  unsigned cnt_trylock_ok;
+  unsigned cnt_trylock_nok;
+  unsigned long long min_lock_wait_time_ns;
+  unsigned long long sum_lock_wait_time_ns;
+  unsigned long long max_lock_wait_time_ns;
+  unsigned long long min_hold_time_ns;
+  unsigned long long sum_hold_time_ns;
+  unsigned long long max_hold_time_ns;
+  unsigned long long lock_start_time_ns;
+  char name[32];
+} NdbMutex;
+#endif
 
 /**
  * Create a mutex
@@ -40,6 +58,7 @@ typedef pthread_mutex_t NdbMutex;
  * returnvalue: pointer to the mutex structure
  */
 NdbMutex* NdbMutex_Create(void);
+NdbMutex* NdbMutex_CreateWithName(const char * name);
 
 /**
  * Initialize a mutex created with file-storage or on the stack
@@ -48,6 +67,7 @@ NdbMutex* NdbMutex_Create(void);
  * * returnvalue: 0 = succeeded, -1 = failed
  */
 int NdbMutex_Init(NdbMutex* p_mutex);
+int NdbMutex_InitWithName(NdbMutex* p_mutex, const char * name);
 
 /**
  * Destroy a mutex

=== modified file 'storage/ndb/include/portlib/ndb_daemon.h'
--- a/storage/ndb/include/portlib/ndb_daemon.h	2010-06-16 12:06:41 +0000
+++ b/storage/ndb/include/portlib/ndb_daemon.h	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/include/util/HashMap.hpp'
--- a/storage/ndb/include/util/HashMap.hpp	2010-09-21 07:36:08 +0000
+++ b/storage/ndb/include/util/HashMap.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Sun Microsystems Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/ndbjtie/Makefile.defaults'
--- a/storage/ndb/ndbjtie/Makefile.defaults	2009-06-20 21:40:43 +0000
+++ b/storage/ndb/ndbjtie/Makefile.defaults	2011-01-30 20:42:21 +0000
@@ -1,3 +1,17 @@
+# Copyright 2009 Sun Microsystems, Inc.
+#
+# 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
 #------------------------------------------------------------------------------
 
 # Default Variables Section:

=== modified file 'storage/ndb/ndbjtie/env.properties'
--- a/storage/ndb/ndbjtie/env.properties	2009-06-19 04:54:13 +0000
+++ b/storage/ndb/ndbjtie/env.properties	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright 2009 Sun Microsystems, Inc.
+#
+# 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
+
 # ----------------------------------------------------------------------
 
 #

=== modified file 'storage/ndb/ndbjtie/src/jtie/jtie/Wrapper.java'
--- a/storage/ndb/ndbjtie/src/jtie/jtie/Wrapper.java	2009-06-19 04:54:13 +0000
+++ b/storage/ndb/ndbjtie/src/jtie/jtie/Wrapper.java	2011-01-30 20:42:21 +0000
@@ -1,4 +1,22 @@
 /*
+   Copyright 2009 Sun Microsystems, Inc.
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
+
+/*
  * Wrapper.java
  */
 

=== modified file 'storage/ndb/src/common/debugger/SignalLoggerManager.cpp'
--- a/storage/ndb/src/common/debugger/SignalLoggerManager.cpp	2011-01-06 21:19:05 +0000
+++ b/storage/ndb/src/common/debugger/SignalLoggerManager.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/common/debugger/signaldata/CreateTrigImpl.cpp'
--- a/storage/ndb/src/common/debugger/signaldata/CreateTrigImpl.cpp	2010-05-03 04:49:08 +0000
+++ b/storage/ndb/src/common/debugger/signaldata/CreateTrigImpl.cpp	2011-01-30 23:13:49 +0000
@@ -2,8 +2,7 @@
 
    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; either version 2 of the License, or
-   (at your option) any later version.
+   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

=== modified file 'storage/ndb/src/common/logger/message.h'
--- a/storage/ndb/src/common/logger/message.h	2010-04-07 09:14:43 +0000
+++ b/storage/ndb/src/common/logger/message.h	2011-01-30 23:13:49 +0000
@@ -1,4 +1,21 @@
 /*
+   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
+*/
+
+/*
   To change or add messages ndbd or ndb_mgmd writes to the Windows
   error log, run
    mc.exe message.mc

=== modified file 'storage/ndb/src/common/mgmcommon/IPCConfig.cpp'
--- a/storage/ndb/src/common/mgmcommon/IPCConfig.cpp	2010-12-15 06:07:35 +0000
+++ b/storage/ndb/src/common/mgmcommon/IPCConfig.cpp	2011-01-30 23:13:49 +0000
@@ -1,6 +1,5 @@
 /* 
-   Copyright (C) 2003-2008 MySQL AB, Sun Microsystems Inc.
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 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

=== modified file 'storage/ndb/src/common/portlib/NdbCondition.c'
--- a/storage/ndb/src/common/portlib/NdbCondition.c	2010-09-22 11:52:37 +0000
+++ b/storage/ndb/src/common/portlib/NdbCondition.c	2011-01-26 08:34:31 +0000
@@ -127,7 +127,11 @@ NdbCondition_Wait(struct NdbCondition* p
   if (p_cond == NULL || p_mutex == NULL)
     return 1;
   
+#ifdef NDB_MUTEX_STAT
+  result = pthread_cond_wait(&p_cond->cond, &p_mutex->mutex);
+#else
   result = pthread_cond_wait(&p_cond->cond, p_mutex);
+#endif
   
   return result;
 }
@@ -182,13 +186,14 @@ NdbCondition_WaitTimeoutAbs(struct NdbCo
 {
 #ifdef NDB_WIN
   struct timespec tmp = *abstime;
+  abstime = &tmp;
 #endif
 
   if (p_cond == NULL || p_mutex == NULL)
     return 1;
 
-#ifdef NDB_WIN
-  return pthread_cond_timedwait(&p_cond->cond, p_mutex, &tmp);
+#ifdef NDB_MUTEX_STAT
+  return pthread_cond_timedwait(&p_cond->cond, &p_mutex->mutex, abstime);
 #else
   return pthread_cond_timedwait(&p_cond->cond, p_mutex, abstime);
 #endif

=== modified file 'storage/ndb/src/common/portlib/NdbDir.cpp'
--- a/storage/ndb/src/common/portlib/NdbDir.cpp	2010-11-30 07:47:55 +0000
+++ b/storage/ndb/src/common/portlib/NdbDir.cpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 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

=== modified file 'storage/ndb/src/common/portlib/NdbMutex.c'
--- a/storage/ndb/src/common/portlib/NdbMutex.c	2011-01-09 16:31:17 +0000
+++ b/storage/ndb/src/common/portlib/NdbMutex.c	2011-01-26 08:34:31 +0000
@@ -22,7 +22,16 @@
 #include <NdbMutex.h>
 #include <NdbMem.h>
 
-NdbMutex* NdbMutex_Create(void)
+#ifdef NDB_MUTEX_STAT
+static FILE * statout = 0;
+#endif
+
+NdbMutex* NdbMutex_Create()
+{
+  return NdbMutex_CreateWithName(0);
+}
+
+NdbMutex* NdbMutex_CreateWithName(const char * name)
 {
   NdbMutex* pNdbMutex;
   int result;
@@ -32,7 +41,7 @@ NdbMutex* NdbMutex_Create(void)
   if (pNdbMutex == NULL)
     return NULL;
 
-  result = NdbMutex_Init(pNdbMutex);
+  result = NdbMutex_InitWithName(pNdbMutex, name);
   if (result == 0)
   {
     return pNdbMutex;
@@ -43,9 +52,39 @@ NdbMutex* NdbMutex_Create(void)
 
 int NdbMutex_Init(NdbMutex* pNdbMutex)
 {
+  return NdbMutex_InitWithName(pNdbMutex, 0);
+}
+
+int NdbMutex_InitWithName(NdbMutex* pNdbMutex, const char * name)
+{
   int result;
+  pthread_mutex_t * p;
   DBUG_ENTER("NdbMutex_Init");
-  
+
+#ifdef NDB_MUTEX_STAT
+  bzero(pNdbMutex, sizeof(NdbMutex));
+  pNdbMutex->min_lock_wait_time_ns = ~(Uint64)0;
+  pNdbMutex->min_hold_time_ns = ~(Uint64)0;
+  p = &pNdbMutex->mutex;
+  if (name == 0)
+  {
+    snprintf(pNdbMutex->name, sizeof(pNdbMutex->name), "%p",
+             pNdbMutex);
+  }
+  else
+  {
+    snprintf(pNdbMutex->name, sizeof(pNdbMutex->name), "%p:%s",
+             pNdbMutex, name);
+  }
+  if (getenv("NDB_MUTEX_STAT") != 0)
+  {
+    statout = stdout;
+  }
+#else
+  p = pNdbMutex;
+  (void)name;
+#endif
+
 #if defined(VM_TRACE) && \
   defined(HAVE_PTHREAD_MUTEXATTR_INIT) && \
   defined(HAVE_PTHREAD_MUTEXATTR_SETTYPE)
@@ -53,11 +92,11 @@ int NdbMutex_Init(NdbMutex* pNdbMutex)
   pthread_mutexattr_t t;
   pthread_mutexattr_init(&t);
   pthread_mutexattr_settype(&t, PTHREAD_MUTEX_ERRORCHECK);
-  result = pthread_mutex_init(pNdbMutex, &t);
+  result = pthread_mutex_init(p, &t);
   assert(result == 0);
   pthread_mutexattr_destroy(&t);
 #else
-  result = pthread_mutex_init(pNdbMutex, 0);
+  result = pthread_mutex_init(p, 0);
 #endif
   DBUG_RETURN(result);
 }
@@ -69,13 +108,66 @@ int NdbMutex_Destroy(NdbMutex* p_mutex)
   if (p_mutex == NULL)
     return -1;
 
+#ifdef NDB_MUTEX_STAT
+  result = pthread_mutex_destroy(&p_mutex->mutex);
+#else
   result = pthread_mutex_destroy(p_mutex);
+#endif
 
   NdbMem_Free(p_mutex);
 
   return result;
 }
 
+#ifdef NDB_MUTEX_STAT
+static
+inline
+Uint64
+now()
+{
+  struct timespec ts;
+  clock_gettime(CLOCK_MONOTONIC, &ts);
+  return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
+}
+
+static
+void
+dumpstat(NdbMutex* p)
+{
+  if (statout != 0)
+  {
+    fprintf(statout,
+            "%s : "
+            " lock [ cnt: %u con: %u wait: [ min: %llu avg: %llu max: %llu ] ]"
+            " trylock [ ok: %u nok: %u ]"
+            " hold: [ min: %llu avg: %llu max: %llu ]\n",
+            p->name,
+            p->cnt_lock,
+            p->cnt_lock_contention,
+            p->min_lock_wait_time_ns,
+            p->cnt_lock_contention ?
+            p->sum_lock_wait_time_ns / p->cnt_lock_contention : 0,
+            p->max_lock_wait_time_ns,
+            p->cnt_trylock_ok,
+            p->cnt_trylock_nok,
+            p->min_hold_time_ns,
+            (p->cnt_lock + p->cnt_trylock_ok) ?
+            p->sum_hold_time_ns / (p->cnt_lock + p->cnt_trylock_ok) : 0,
+            p->max_hold_time_ns);
+  }
+  p->cnt_lock = 0;
+  p->cnt_lock_contention = 0;
+  p->cnt_trylock_ok = 0;
+  p->cnt_trylock_nok = 0;
+  p->min_lock_wait_time_ns = ~(Uint64)0;
+  p->sum_lock_wait_time_ns = 0;
+  p->max_lock_wait_time_ns = 0;
+  p->min_hold_time_ns = ~(Uint64)0;
+  p->sum_hold_time_ns = 0;
+  p->max_hold_time_ns = 0;
+}
+
+#endif
 
 int NdbMutex_Lock(NdbMutex* p_mutex)
 {
@@ -84,7 +176,33 @@ int NdbMutex_Lock(NdbMutex* p_mutex)
   if (p_mutex == NULL)
     return -1;
 
+#ifdef NDB_MUTEX_STAT
+  {
+    Uint64 stop;
+    if ((result = pthread_mutex_trylock(&p_mutex->mutex)) == 0)
+    {
+      stop = now();
+    }
+    else
+    {
+      Uint64 start = now();
+      assert(result == EBUSY);
+      result = pthread_mutex_lock(&p_mutex->mutex);
+      stop = now();
+      p_mutex->cnt_lock_contention++;
+      Uint64 t = (stop - start);
+      p_mutex->sum_lock_wait_time_ns += t;
+      if (t < p_mutex->min_lock_wait_time_ns)
+        p_mutex->min_lock_wait_time_ns = t;
+      if (t > p_mutex->max_lock_wait_time_ns)
+        p_mutex->max_lock_wait_time_ns = t;
+    }
+    p_mutex->cnt_lock++;
+    p_mutex->lock_start_time_ns = stop;
+  }
+#else
   result = pthread_mutex_lock(p_mutex);
+#endif
   assert(result == 0);
 
   return result;
@@ -98,7 +216,26 @@ int NdbMutex_Unlock(NdbMutex* p_mutex)
   if (p_mutex == NULL)
     return -1;
 
+#ifdef NDB_MUTEX_STAT
+  {
+    Uint64 stop = now() - p_mutex->lock_start_time_ns;
+    p_mutex->sum_hold_time_ns += stop;
+    if (stop < p_mutex->min_hold_time_ns)
+      p_mutex->min_hold_time_ns = stop;
+    if (stop > p_mutex->max_hold_time_ns)
+      p_mutex->max_hold_time_ns = stop;
+    result = pthread_mutex_unlock(&p_mutex->mutex);
+    if (((p_mutex->sum_hold_time_ns + p_mutex->sum_lock_wait_time_ns)
+         >= 3*1000000000ULL) ||
+        p_mutex->cnt_lock >= 16384 ||
+        p_mutex->cnt_trylock_ok >= 16384)
+    {
+      dumpstat(p_mutex);
+    }
+  }
+#else
   result = pthread_mutex_unlock(p_mutex);
+#endif
   assert(result == 0);
 
   return result;
@@ -107,12 +244,26 @@ int NdbMutex_Unlock(NdbMutex* p_mutex)
 
 int NdbMutex_Trylock(NdbMutex* p_mutex)
 {
-  int result = -1;
+  int result;
+
+  if (p_mutex == NULL)
+    return -1;
 
-  if (p_mutex != NULL) {
-    result = pthread_mutex_trylock(p_mutex);
-    assert(result == 0 || result == EBUSY);
+#ifdef NDB_MUTEX_STAT
+  result = pthread_mutex_trylock(&p_mutex->mutex);
+  if (result == 0)
+  {
+    p_mutex->cnt_trylock_ok++;
+    p_mutex->lock_start_time_ns = now();
+  }
+  else
+  {
+    __sync_fetch_and_add(&p_mutex->cnt_trylock_nok, 1);
   }
+#else
+  result = pthread_mutex_trylock(p_mutex);
+#endif
+  assert(result == 0 || result == EBUSY);
 
   return result;
 }

=== modified file 'storage/ndb/src/common/portlib/ndb_daemon.cc'
--- a/storage/ndb/src/common/portlib/ndb_daemon.cc	2010-11-17 10:20:39 +0000
+++ b/storage/ndb/src/common/portlib/ndb_daemon.cc	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/src/common/util/ndb_opts.c'
--- a/storage/ndb/src/common/util/ndb_opts.c	2010-11-17 10:01:47 +0000
+++ b/storage/ndb/src/common/util/ndb_opts.c	2011-01-30 23:13:49 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (c) 2008, 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
+*/
+
 #define OPTEXPORT
 #include <ndb_opts.h>
 

=== modified file 'storage/ndb/src/common/util/require.c'
--- a/storage/ndb/src/common/util/require.c	2009-12-03 11:39:48 +0000
+++ b/storage/ndb/src/common/util/require.c	2011-01-30 23:13:49 +0000
@@ -1,3 +1,21 @@
+/*
+   Copyright 2009 Sun Microsystems, Inc.
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
+
 #include <ndb_global.h>
 
 void require_failed(int exitcode, RequirePrinter printer,

=== modified file 'storage/ndb/src/kernel/CMakeLists.txt'
--- a/storage/ndb/src/kernel/CMakeLists.txt	2010-11-15 10:26:48 +0000
+++ b/storage/ndb/src/kernel/CMakeLists.txt	2011-02-02 15:16:35 +0000
@@ -53,14 +53,16 @@ IF(WIN32)
     ${CMAKE_SOURCE_DIR}/storage/ndb/src/common/logger/msg00001.bin)
 ENDIF()
 
-ADD_EXECUTABLE(ndbd
-  main.cpp ndbd.cpp angel.cpp SimBlockList.cpp ${NDBD_EXTRA_SRC})
+MYSQL_ADD_EXECUTABLE(ndbd
+  main.cpp ndbd.cpp angel.cpp SimBlockList.cpp ${NDBD_EXTRA_SRC}
+  DESTINATION ${INSTALL_SBINDIR}
+  COMPONENT ClusterDataNode)
 TARGET_LINK_LIBRARIES(ndbd ${NDBD_LIBS} ndbsched ${LIBDL})
-INSTALL(TARGETS ndbd DESTINATION libexec)
 
 IF(NDB_BUILD_NDBMTD)
-  ADD_EXECUTABLE(ndbmtd
-    main.cpp ndbd.cpp angel.cpp SimBlockList.cpp ${NDBD_EXTRA_SRC})
+  MYSQL_ADD_EXECUTABLE(ndbmtd
+    main.cpp ndbd.cpp angel.cpp SimBlockList.cpp ${NDBD_EXTRA_SRC}
+    DESTINATION ${INSTALL_SBINDIR}
+    COMPONENT ClusterDataNode)
   TARGET_LINK_LIBRARIES(ndbmtd ${NDBD_LIBS} ndbsched_mt ${LIBDL})
-  INSTALL(TARGETS ndbmtd DESTINATION libexec)
 ENDIF()

=== modified file 'storage/ndb/src/kernel/angel.cpp'
--- a/storage/ndb/src/kernel/angel.cpp	2010-11-03 13:59:57 +0000
+++ b/storage/ndb/src/kernel/angel.cpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/src/kernel/angel.hpp'
--- a/storage/ndb/src/kernel/angel.hpp	2010-11-03 11:09:03 +0000
+++ b/storage/ndb/src/kernel/angel.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/src/kernel/blocks/CMakeLists.txt'
--- a/storage/ndb/src/kernel/blocks/CMakeLists.txt	2010-11-10 08:01:00 +0000
+++ b/storage/ndb/src/kernel/blocks/CMakeLists.txt	2011-02-02 15:16:35 +0000
@@ -73,9 +73,9 @@ ADD_LIBRARY(ndbblocks STATIC
     dbtup/DbtupClient.cpp
     ${EXTRA_SRC})
 
-ADD_EXECUTABLE(ndb_print_file
-    print_file.cpp
-    diskpage.cpp
-    dbtup/tuppage.cpp
-)
+MYSQL_ADD_EXECUTABLE(ndb_print_file
+  print_file.cpp
+  diskpage.cpp
+  dbtup/tuppage.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_print_file ndbclient)

=== modified file 'storage/ndb/src/kernel/blocks/ERROR_codes.txt'
--- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt	2011-01-17 12:08:49 +0000
+++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt	2011-02-02 15:16:35 +0000
@@ -1,3 +1,18 @@
+# Copyright (c) 2003, 2011, 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
+
 Next QMGR 938
 Next NDBCNTR 1002
 Next NDBFS 2000

=== modified file 'storage/ndb/src/kernel/blocks/backup/CMakeLists.txt'
--- a/storage/ndb/src/kernel/blocks/backup/CMakeLists.txt	2010-11-26 10:42:53 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -13,6 +13,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-ADD_EXECUTABLE(ndb_print_backup_file read.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_print_backup_file
+  read.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_print_backup_file
     ndbtrace ndblogger ndbgeneral ndbportlib)

=== modified file 'storage/ndb/src/kernel/blocks/dbdict/CMakeLists.txt'
--- a/storage/ndb/src/kernel/blocks/dbdict/CMakeLists.txt	2010-11-26 10:42:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -13,7 +13,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-ADD_EXECUTABLE(ndb_print_schema_file
-               printSchemaFile.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_print_schema_file
+  printSchemaFile.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_print_schema_file
     ndbtrace ndblogger ndbgeneral ndbportlib)

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/CMakeLists.txt'
--- a/storage/ndb/src/kernel/blocks/dbdih/CMakeLists.txt	2010-11-26 10:42:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -14,6 +14,8 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-ADD_EXECUTABLE(ndb_print_sys_file printSysfile.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_print_sys_file
+  printSysfile.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_print_sys_file
     ndbtrace ndblogger ndbgeneral ndbportlib)

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2010-11-25 14:42:27 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2011-02-02 15:16:35 +0000
@@ -5374,6 +5374,7 @@ void Dbdih::checkGcpOutstanding(Signal* 
     }
      
     GCPNoMoreTrans* req = (GCPNoMoreTrans*)signal->getDataPtrSend();
+    req->senderRef = reference();
     req->senderData = m_micro_gcp.m_master_ref;
     req->gci_hi = Uint32(m_micro_gcp.m_old_gci >> 32);
     req->gci_lo = Uint32(m_micro_gcp.m_old_gci);
@@ -5632,6 +5633,7 @@ void Dbdih::execMASTER_GCPREQ(Signal* si
 
     {
       GCPNoMoreTrans* req2 = (GCPNoMoreTrans*)signal->getDataPtrSend();
+      req2->senderRef = reference();
       req2->senderData = m_micro_gcp.m_master_ref;
       req2->gci_hi = (Uint32)(m_micro_gcp.m_old_gci >> 32);
       req2->gci_lo = (Uint32)(m_micro_gcp.m_old_gci & 0xFFFFFFFF);
@@ -9953,6 +9955,7 @@ void Dbdih::execGCP_COMMIT(Signal* signa
   emptyverificbuffer(signal, true);
 
   GCPNoMoreTrans* req2 = (GCPNoMoreTrans*)signal->getDataPtrSend();
+  req2->senderRef = reference();
   req2->senderData = calcDihBlockRef(masterNodeId);
   req2->gci_hi = (Uint32)(m_micro_gcp.m_old_gci >> 32);
   req2->gci_lo = (Uint32)(m_micro_gcp.m_old_gci & 0xFFFFFFFF);

=== modified file 'storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.hpp'
--- a/storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.hpp	2010-01-15 11:15:33 +0000
+++ b/storage/ndb/src/kernel/blocks/dbinfo/Dbinfo.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2008 MySQL AB, 2009-2010 Sun Microsystems Inc.
+/* Copyright 2008-2010 Sun Microsystems, Inc.
    All rights reserved. Use is subject to license terms.
 
    This program is free software; you can redistribute it and/or modify

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/CMakeLists.txt'
--- a/storage/ndb/src/kernel/blocks/dblqh/CMakeLists.txt	2010-11-26 10:42:53 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -14,8 +14,9 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-ADD_EXECUTABLE(ndb_redo_log_reader
-    redoLogReader/records.cpp
-    redoLogReader/reader.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_redo_log_reader
+  redoLogReader/records.cpp
+  redoLogReader/reader.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_redo_log_reader
     ndbtrace ndblogger ndbgeneral ndbportlib)

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2011-01-21 13:56:43 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2011-01-26 08:51:30 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2011-02-02 15:16:35 +0000
@@ -2061,6 +2061,7 @@ private:
   /**************************************************************************/
 
   Uint32 c_gcp_ref;
+  Uint32 c_gcp_data;
 
   Uint32 c_sttor_ref;
 

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2011-01-26 08:51:30 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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
@@ -7842,7 +7841,8 @@ void Dbtc::execGCP_NOMORETRANS(Signal* s
 {
   jamEntry();
   GCPNoMoreTrans* req = (GCPNoMoreTrans*)signal->getDataPtr();
-  c_gcp_ref = req->senderData;
+  c_gcp_ref = req->senderRef;
+  c_gcp_data = req->senderData;
   Uint32 gci_lo = req->gci_lo;
   Uint32 gci_hi = req->gci_hi;
   tcheckGcpId = gci_lo | (Uint64(gci_hi) << 32);
@@ -11716,10 +11716,10 @@ void Dbtc::sendScanTabConf(Signal* signa
 void Dbtc::gcpTcfinished(Signal* signal, Uint64 gci)
 {
   GCPTCFinished* conf = (GCPTCFinished*)signal->getDataPtrSend();
-  conf->senderData = c_gcp_ref;
+  conf->senderData = c_gcp_data;
   conf->gci_hi = Uint32(gci >> 32);
   conf->gci_lo = Uint32(gci);
-  sendSignal(cdihblockref, GSN_GCP_TCFINISHED, signal, 
+  sendSignal(c_gcp_ref, GSN_GCP_TCFINISHED, signal,
              GCPTCFinished::SignalLength, JBB);
 }//Dbtc::gcpTcfinished()
 

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2011-01-06 21:19:05 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp	2011-01-03 15:08:41 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupDebug.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2011-01-17 12:08:49 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp	2011-01-03 15:08:41 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp	2011-01-06 21:19:05 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupStoredProcDef.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/test_dynbm.c'
--- a/storage/ndb/src/kernel/blocks/dbtup/test_dynbm.c	2007-04-03 12:49:05 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/test_dynbm.c	2011-01-30 20:42:21 +0000
@@ -1,3 +1,21 @@
+/*
+   Copyright (C) 2007 MySQL AB
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

=== modified file 'storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp	2010-09-24 18:19:07 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtux/DbtuxBuild.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,19 @@
+/*
+   Copyright (c) 2009, 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
+*/
 
 #include "Dbtux.hpp"
 

=== modified file 'storage/ndb/src/kernel/blocks/lgman.cpp'
--- a/storage/ndb/src/kernel/blocks/lgman.cpp	2011-01-15 06:29:18 +0000
+++ b/storage/ndb/src/kernel/blocks/lgman.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2005, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/tsman.cpp'
--- a/storage/ndb/src/kernel/blocks/tsman.cpp	2011-01-15 06:29:18 +0000
+++ b/storage/ndb/src/kernel/blocks/tsman.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2005, 2011, 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

=== modified file 'storage/ndb/src/kernel/blocks/tsman.hpp'
--- a/storage/ndb/src/kernel/blocks/tsman.hpp	2011-01-15 06:29:18 +0000
+++ b/storage/ndb/src/kernel/blocks/tsman.hpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2005, 2011, 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

=== modified file 'storage/ndb/src/kernel/ndbd.cpp'
--- a/storage/ndb/src/kernel/ndbd.cpp	2010-12-20 10:33:24 +0000
+++ b/storage/ndb/src/kernel/ndbd.cpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/src/kernel/ndbd.hpp'
--- a/storage/ndb/src/kernel/ndbd.hpp	2010-05-05 15:27:29 +0000
+++ b/storage/ndb/src/kernel/ndbd.hpp	2011-01-30 23:13:49 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2009, 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

=== modified file 'storage/ndb/src/kernel/vm/SimulatedBlock.hpp'
--- a/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2011-01-06 21:19:05 +0000
+++ b/storage/ndb/src/kernel/vm/SimulatedBlock.hpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/kernel/vm/dummy_mt.cpp'
--- a/storage/ndb/src/kernel/vm/dummy_mt.cpp	2008-01-01 12:45:11 +0000
+++ b/storage/ndb/src/kernel/vm/dummy_mt.cpp	2011-01-30 23:13:49 +0000
@@ -1,3 +1,21 @@
+/*
+   Copyright (C) 2008 MySQL AB
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
+
 #include "FastScheduler.hpp"
 #include "RefConvert.hpp"
 

=== modified file 'storage/ndb/src/kernel/vm/dummy_nonmt.cpp'
--- a/storage/ndb/src/kernel/vm/dummy_nonmt.cpp	2009-01-23 14:21:31 +0000
+++ b/storage/ndb/src/kernel/vm/dummy_nonmt.cpp	2011-01-30 23:13:49 +0000
@@ -1,3 +1,21 @@
+/*
+   Copyright (C) 2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
+
 #include <assert.h>
 #include <ndb_types.h>
 

=== modified file 'storage/ndb/src/libndb.ver.in'
--- a/storage/ndb/src/libndb.ver.in	2007-01-19 00:31:43 +0000
+++ b/storage/ndb/src/libndb.ver.in	2011-01-30 20:42:21 +0000
@@ -1,2 +1,17 @@
+# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 libndbclient_@NDB_SHARED_LIB_MAJOR_VERSION@ { global: *; };
 

=== modified file 'storage/ndb/src/mgmclient/CMakeLists.txt'
--- a/storage/ndb/src/mgmclient/CMakeLists.txt	2010-11-10 09:42:49 +0000
+++ b/storage/ndb/src/mgmclient/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -18,8 +18,9 @@ INCLUDE_DIRECTORIES(${NDB_SOURCE_DIR}/sr
 ADD_LIBRARY(ndbmgmclient STATIC
             CommandInterpreter.cpp)
 
-ADD_EXECUTABLE(ndb_mgm
-               main.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_mgm
+  main.cpp
+  COMPONENT ClusterManagementClient)
 
 TARGET_LINK_LIBRARIES(ndb_mgm
                ndbmgmclient
@@ -34,5 +35,3 @@ TARGET_LINK_LIBRARIES(ndb_mgm
 IF(UNIX)
   TARGET_LINK_LIBRARIES(ndb_mgm ${READLINE_LIBRARY})
 ENDIF(UNIX)
-
-INSTALL(TARGETS ndb_mgm DESTINATION bin)

=== modified file 'storage/ndb/src/mgmclient/CommandInterpreter.cpp'
--- a/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2010-11-28 11:34:01 +0000
+++ b/storage/ndb/src/mgmclient/CommandInterpreter.cpp	2011-01-30 23:13:49 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB, 2010 Sun Microsystems, Inc.
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 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

=== modified file 'storage/ndb/src/mgmsrv/CMakeLists.txt'
--- a/storage/ndb/src/mgmsrv/CMakeLists.txt	2010-11-11 15:08:52 +0000
+++ b/storage/ndb/src/mgmsrv/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -48,15 +48,16 @@ IF(WIN32)
     ${CMAKE_SOURCE_DIR}/storage/ndb/src/common/logger/msg00001.bin)
 ENDIF()
 
-ADD_EXECUTABLE(ndb_mgmd
-  MgmtSrvr.cpp main.cpp Services.cpp ConfigManager.cpp ${NDB_MGMD_EXTRA_SRC})
+MYSQL_ADD_EXECUTABLE(ndb_mgmd
+  MgmtSrvr.cpp main.cpp Services.cpp ConfigManager.cpp
+  ${NDB_MGMD_EXTRA_SRC}
+  DESTINATION ${INSTALL_SBINDIR}
+  COMPONENT ClusterManagementServer)
 TARGET_LINK_LIBRARIES(ndb_mgmd ndbconf ndbclient ndbmgmclient)
 IF(UNIX)
   TARGET_LINK_LIBRARIES(ndb_mgmd ${READLINE_LIBRARY})
 ENDIF(UNIX)
 
-INSTALL(TARGETS ndb_mgmd DESTINATION libexec)
-
 ADD_EXECUTABLE(MgmConfig-t
                testConfig.cpp)
 TARGET_LINK_LIBRARIES(MgmConfig-t

=== modified file 'storage/ndb/src/mgmsrv/ConfigManager.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigManager.cpp	2011-01-18 09:52:49 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigManager.cpp	2011-01-31 17:37:07 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 2011, 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

=== modified file 'storage/ndb/src/mgmsrv/ConfigManager.hpp'
--- a/storage/ndb/src/mgmsrv/ConfigManager.hpp	2011-01-18 09:52:49 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigManager.hpp	2011-01-31 17:37:07 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2008, 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

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2011-01-18 09:52:49 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2011-02-02 14:43:21 +0000
@@ -3807,6 +3807,13 @@ MgmtSrvr::show_variables(NdbOut& out)
 void
 MgmtSrvr::make_sync_req(SignalSender& ss, Uint32 nodeId)
 {
+  const trp_node node = ss.getNodeInfo(nodeId);
+  if (!ndbd_sync_req_support(node.m_info.m_version))
+  {
+    /* The node hasn't got SYNC_REQ support */
+    return;
+  }
+
   /**
    * This subroutine is used to make a async request(error insert/dump)
    *   "more" syncronous, i.e increasing the likelyhood that

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.cpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.cpp	2011-01-19 18:41:30 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp	2011-01-25 12:22:49 +0000
@@ -296,7 +296,6 @@ ClusterMgr::startup()
   Node & cm_node = theNodes[nodeId];
   trp_node & theNode = cm_node;
   assert(theNode.defined);
-  assert(theNode.is_connected() == false);
 
   lock();
   theFacade.doConnect(nodeId);

=== modified file 'storage/ndb/src/ndbapi/NdbDictionary.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionary.cpp	2010-10-04 14:44:27 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp	2011-02-02 15:16:35 +0000
@@ -551,6 +551,7 @@ NdbDictionary::Table::addColumn(const Co
   {
     return -1;
   }
+  col->m_column_no = m_impl.m_columns.size() - 1;
   return 0;
 }
 
@@ -995,6 +996,14 @@ NdbDictionary::Table::getPartitionId(Uin
   }
 }
 
+void
+NdbDictionary::Table::assignObjId(const NdbDictionary::ObjectId& _objId)
+{
+  const NdbDictObjectImpl& objId = NdbDictObjectImpl::getImpl(_objId);
+  m_impl.m_id = objId.m_id;
+  m_impl.m_version = objId.m_version;
+}
+
 /*****************************************************************
  * Index facade
  */
@@ -2083,12 +2092,23 @@ NdbDictionary::Dictionary::~Dictionary()
 int 
 NdbDictionary::Dictionary::createTable(const Table & t)
 {
+  return createTable(t, 0);
+}
+
+int
+NdbDictionary::Dictionary::createTable(const Table & t, ObjectId * objId)
+{
   int ret;
+  ObjectId tmp;
+  if (objId == 0)
+    objId = &tmp;
+
   if (likely(! is_ndb_blob_table(t.getName())))
   {
     DO_TRANS(
       ret,
-      m_impl.createTable(NdbTableImpl::getImpl(t))
+      m_impl.createTable(NdbTableImpl::getImpl(t),
+                         NdbDictObjectImpl::getImpl( *objId))
     );
   }
   else

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2011-01-12 08:04:39 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2011-01-27 13:23:07 +0000
@@ -2879,7 +2879,7 @@ NdbDictInterface::parseTableInfo(NdbTabl
  * Create table and alter table
  */
 int
-NdbDictionaryImpl::createTable(NdbTableImpl &t)
+NdbDictionaryImpl::createTable(NdbTableImpl &t, NdbDictObjectImpl & objid)
 { 
   DBUG_ENTER("NdbDictionaryImpl::createTable");
 
@@ -2910,6 +2910,8 @@ NdbDictionaryImpl::createTable(NdbTableI
   Uint32* data = (Uint32*)m_receiver.m_buffer.get_data();
   t.m_id = data[0];
   t.m_version = data[1];
+  objid.m_id = data[0];
+  objid.m_version = data[1];
 
   // update table def from DICT - by-pass cache
   NdbTableImpl* t2 =
@@ -3014,7 +3016,8 @@ NdbDictionaryImpl::createBlobTables(cons
       assert(bc != NULL);
       bc->setStorageType(d);
     }
-    if (createTable(bt) != 0) {
+    NdbDictionary::ObjectId objId; // ignore objid
+    if (createTable(bt, NdbDictObjectImpl::getImpl(objId)) != 0) {
       DBUG_RETURN(-1);
     }
   }

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2010-11-09 20:40:03 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2011-01-27 13:23:07 +0000
@@ -817,7 +817,7 @@ public:
   bool setTransporter(class Ndb * ndb, class TransporterFacade * tf);
   bool setTransporter(class TransporterFacade * tf);
 
-  int createTable(NdbTableImpl &t);
+  int createTable(NdbTableImpl &t, NdbDictObjectImpl &);
   int optimizeTable(const NdbTableImpl &t,
                     NdbOptimizeTableHandleImpl &h);
   int optimizeIndex(const NdbIndexImpl &index,

=== modified file 'storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2011-01-10 11:22:17 +0000
+++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2011-01-28 11:27:55 +0000
@@ -595,10 +595,19 @@ NdbEventOperationImpl::execute_nolock()
     int res = myDict->beginSchemaTrans();
     if (res != 0)
     {
-      m_error.code= myDict->getNdbError().code;
-      DBUG_RETURN(-1);
+      switch(myDict->getNdbError().code){
+      case 711:
+        // ignore;
+        break;
+      default:
+        m_error.code= myDict->getNdbError().code;
+        DBUG_RETURN(-1);
+      }
+    }
+    else
+    {
+      schemaTrans = true;
     }
-    schemaTrans = true;
   }
 
   if (theFirstPkAttrs[0] == NULL && 

=== modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2011-01-06 21:19:05 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2011-02-02 15:16:35 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2011-01-21 13:56:43 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2011-02-02 15:16:35 +0000
@@ -541,7 +541,7 @@ TransporterFacade::TransporterFacade(Glo
   m_globalDictCache(cache)
 {
   DBUG_ENTER("TransporterFacade::TransporterFacade");
-  theMutexPtr = NdbMutex_Create();
+  theMutexPtr = NdbMutex_CreateWithName("TTFM");
   sendPerformedLastInterval = 0;
 
   for (int i = 0; i < NO_API_FIXED_BLOCKS; i++)

=== modified file 'storage/ndb/src/ndbapi/ndb_cluster_connection.cpp'
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2010-12-02 11:02:29 +0000
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2011-01-28 11:26:27 +0000
@@ -229,6 +229,38 @@ Ndb_cluster_connection::node_id()
   return m_impl.m_transporter_facade->ownId();
 }
 
+unsigned
+Ndb_cluster_connection::max_nodegroup()
+{
+  TransporterFacade *tp = m_impl.m_transporter_facade;
+  if (tp == 0 || tp->ownId() == 0)
+    return 0;
+
+  Bitmask<MAX_NDB_NODES> ng;
+  tp->lock_mutex();
+  for(unsigned i= 0; i < no_db_nodes(); i++)
+  {
+    //************************************************
+    // If any node is answering, ndb is answering
+    //************************************************
+    trp_node n = tp->theClusterMgr->getNodeInfo(m_impl.m_all_nodes[i].id);
+    if (n.is_confirmed() && n.m_state.nodeGroup <= MAX_NDB_NODES)
+      ng.set(n.m_state.nodeGroup);
+  }
+  tp->unlock_mutex();
+
+  if (ng.isclear())
+    return 0;
+
+  Uint32 n = ng.find_first();
+  Uint32 m;
+  do
+  {
+    m = n;
+  } while ((n = ng.find(n+1)) != ng.NotFound);
+
+  return m;
+}
 
 int Ndb_cluster_connection::get_no_ready()
 {

=== modified file 'storage/ndb/src/ndbapi/trp_client.cpp'
--- a/storage/ndb/src/ndbapi/trp_client.cpp	2011-01-12 08:04:39 +0000
+++ b/storage/ndb/src/ndbapi/trp_client.cpp	2011-01-31 17:37:07 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (c) 2011, 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
+*/
+
 #include "trp_client.hpp"
 #include "TransporterFacade.hpp"
 
@@ -112,6 +129,12 @@ trp_client::do_forceSend(int val)
   }
 }
 
+int
+trp_client::safe_sendSignal(const NdbApiSignal* signal, Uint32 nodeId)
+{
+  return m_facade->m_poll_owner->raw_sendSignal(signal, nodeId);
+}
+
 #include "NdbImpl.hpp"
 
 PollGuard::PollGuard(NdbImpl& impl)

=== modified file 'storage/ndb/src/ndbapi/trp_client.hpp'
--- a/storage/ndb/src/ndbapi/trp_client.hpp	2011-01-12 08:04:39 +0000
+++ b/storage/ndb/src/ndbapi/trp_client.hpp	2011-01-21 18:31:51 +0000
@@ -180,11 +180,4 @@ trp_client::raw_sendFragmentedSignal(con
   return m_facade->sendFragmentedSignal(signal, nodeId, ptr, secs);
 }
 
-inline
-int
-trp_client::safe_sendSignal(const NdbApiSignal* signal, Uint32 nodeId)
-{
-  return m_facade->m_poll_owner->raw_sendSignal(signal, nodeId);
-}
-
 #endif

=== modified file 'storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp'
--- a/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp	2011-01-16 06:24:02 +0000
+++ b/storage/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2005, 2011, 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

=== modified file 'storage/ndb/test/ndbapi/slow_select.cpp'
--- a/storage/ndb/test/ndbapi/slow_select.cpp	2009-12-04 05:53:03 +0000
+++ b/storage/ndb/test/ndbapi/slow_select.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (C) 2004, 2005 MySQL AB, 2009 Sun Microsystems, Inc.
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
 
 #include <ndb_global.h>
 #include <NdbApi.hpp>

=== modified file 'storage/ndb/test/ndbapi/testBasic.cpp'
--- a/storage/ndb/test/ndbapi/testBasic.cpp	2011-01-14 12:05:51 +0000
+++ b/storage/ndb/test/ndbapi/testBasic.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/test/ndbapi/testBitfield.cpp'
--- a/storage/ndb/test/ndbapi/testBitfield.cpp	2010-11-28 11:34:01 +0000
+++ b/storage/ndb/test/ndbapi/testBitfield.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,19 @@
+/*
+   Copyright (c) 2004, 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
+*/
 
 #include <ndb_global.h>
 #include <ndb_opts.h>

=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp	2011-01-03 18:10:25 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp	2011-01-30 20:56:00 +0000
@@ -1,6 +1,5 @@
 /*
-   Copyright (C) 2003 MySQL AB
-    All rights reserved. Use is subject to license terms.
+   Copyright (c) 2003, 2011, 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

=== modified file 'storage/ndb/test/ndbapi/testLcp.cpp'
--- a/storage/ndb/test/ndbapi/testLcp.cpp	2010-04-13 16:01:38 +0000
+++ b/storage/ndb/test/ndbapi/testLcp.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (C) 2004, 2005 MySQL AB, 2009 Sun Microsystems, Inc.
+    All rights reserved. Use is subject to license terms.
+
+   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
+*/
 
 #include <NDBT.hpp>
 #include <NdbApi.hpp>

=== modified file 'storage/ndb/test/run-test/16node-tests.txt'
--- a/storage/ndb/test/run-test/16node-tests.txt	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/16node-tests.txt	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # BASIC FUNCTIONALITY
 max-time: 500
 cmd: testBasic

=== modified file 'storage/ndb/test/run-test/CMakeLists.txt'
--- a/storage/ndb/test/run-test/CMakeLists.txt	2010-11-17 11:35:04 +0000
+++ b/storage/ndb/test/run-test/CMakeLists.txt	2011-01-30 23:13:49 +0000
@@ -1,5 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems
-#  All rights reserved. Use is subject to license terms.
+# Copyright (c) 2009, 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

=== modified file 'storage/ndb/test/run-test/atrt-analyze-result.sh'
--- a/storage/ndb/test/run-test/atrt-analyze-result.sh	2008-08-24 18:38:25 +0000
+++ b/storage/ndb/test/run-test/atrt-analyze-result.sh	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2003, 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 cores=`find result -name 'core*'`
 if [ "$cores" ]
 then

=== modified file 'storage/ndb/test/run-test/atrt-backtrace.sh'
--- a/storage/ndb/test/run-test/atrt-backtrace.sh	2010-04-16 12:25:53 +0000
+++ b/storage/ndb/test/run-test/atrt-backtrace.sh	2011-01-30 20:56:00 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # Does not work on Windows (gcc only)
 if uname | grep -iq cygwin
 then

=== modified file 'storage/ndb/test/run-test/atrt-gather-result.sh'
--- a/storage/ndb/test/run-test/atrt-gather-result.sh	2010-04-28 08:10:55 +0000
+++ b/storage/ndb/test/run-test/atrt-gather-result.sh	2011-01-30 23:13:49 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (c) 2003, 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
+
 set -e
 
 mkdir -p result

=== modified file 'storage/ndb/test/run-test/atrt-mysql-test-run'
--- a/storage/ndb/test/run-test/atrt-mysql-test-run	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/atrt-mysql-test-run	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2004, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 set -x
 p=`pwd`
 cd $MYSQL_BASE_DIR/mysql-test 

=== modified file 'storage/ndb/test/run-test/atrt-mysqltest'
--- a/storage/ndb/test/run-test/atrt-mysqltest	2010-08-02 11:36:25 +0000
+++ b/storage/ndb/test/run-test/atrt-mysqltest	2011-01-30 20:42:21 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# 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
+
 #
 # Use like this in the ATRT test file:
 #

=== modified file 'storage/ndb/test/run-test/atrt-setup.sh'
--- a/storage/ndb/test/run-test/atrt-setup.sh	2010-04-30 09:47:32 +0000
+++ b/storage/ndb/test/run-test/atrt-setup.sh	2011-01-30 20:56:00 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 MACHINE=$1
 LOCAL_DIR=$2
 REMOTE_DIR=$3

=== modified file 'storage/ndb/test/run-test/atrt-testBackup'
--- a/storage/ndb/test/run-test/atrt-testBackup	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/atrt-testBackup	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2004, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 PATH=$PATH:$MYSQL_BASE_DIR/bin
 export PATH
 

=== modified file 'storage/ndb/test/run-test/autotest-boot.sh'
--- a/storage/ndb/test/run-test/autotest-boot.sh	2010-05-26 10:49:22 +0000
+++ b/storage/ndb/test/run-test/autotest-boot.sh	2011-01-30 23:13:49 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# Copyright (c) 2007, 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
+
 #############################################################
 # This script created by Jonas does the following	    #
 # Cleans up clones and pevious builds, pulls new clones,    #

=== modified file 'storage/ndb/test/run-test/autotest-run.sh'
--- a/storage/ndb/test/run-test/autotest-run.sh	2010-04-28 08:10:55 +0000
+++ b/storage/ndb/test/run-test/autotest-run.sh	2011-01-30 23:13:49 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# Copyright (c) 2007, 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
+
 #############################################################
 # This script created by Jonas does the following	    #
 # Cleans up clones and pevious builds, pulls new clones,    #

=== modified file 'storage/ndb/test/run-test/basic.txt'
--- a/storage/ndb/test/run-test/basic.txt	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/basic.txt	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2004, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # BASIC FUNCTIONALITY
 max-time: 500
 cmd: testBasic

=== modified file 'storage/ndb/test/run-test/check-tests.sh'
--- a/storage/ndb/test/run-test/check-tests.sh	2010-12-13 13:20:16 +0000
+++ b/storage/ndb/test/run-test/check-tests.sh	2011-01-30 23:13:49 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (c) 2009, 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
+
 set -e
 
 files="daily-basic-tests.txt daily-devel-tests.txt upgrade-tests.txt"

=== modified file 'storage/ndb/test/run-test/create_mtr_suites.pl'
--- a/storage/ndb/test/run-test/create_mtr_suites.pl	2009-03-13 13:34:10 +0000
+++ b/storage/ndb/test/run-test/create_mtr_suites.pl	2011-01-30 23:13:49 +0000
@@ -1,6 +1,22 @@
 #!/usr/bin/perl
 # -*- cperl -*-
 
+# Copyright 2009 Sun Microsystems, Inc.
+#  All rights reserved. Use is subject to license terms.
+#
+# 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
+
 use strict;
 use warnings;
 use IO::File;

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2011-01-17 12:08:49 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2011-02-02 15:16:35 +0000
@@ -1,3 +1,17 @@
+# Copyright (c) 2004, 2011, 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
 max-time: 600
 cmd: atrt-testBackup
 args: -n NFMaster T1

=== modified file 'storage/ndb/test/run-test/daily-devel-tests.txt'
--- a/storage/ndb/test/run-test/daily-devel-tests.txt	2010-06-21 08:51:07 +0000
+++ b/storage/ndb/test/run-test/daily-devel-tests.txt	2011-02-01 08:36:25 +0000
@@ -1,3 +1,17 @@
+# Copyright (c) 2004, 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
 #
 # BACKUP
 #

=== modified file 'storage/ndb/test/run-test/files.cpp'
--- a/storage/ndb/test/run-test/files.cpp	2010-10-29 20:51:26 +0000
+++ b/storage/ndb/test/run-test/files.cpp	2011-02-02 15:16:35 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (c) 2007, 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
+*/
+
 #include "atrt.hpp"
 #include <portlib/NdbDir.hpp>
 #include <portlib/NdbSleep.h>

=== modified file 'storage/ndb/test/run-test/make-config.sh'
--- a/storage/ndb/test/run-test/make-config.sh	2005-11-22 17:05:10 +0000
+++ b/storage/ndb/test/run-test/make-config.sh	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 baseport=""
 basedir=""
 proc_no=1

=== modified file 'storage/ndb/test/run-test/make-html-reports.sh'
--- a/storage/ndb/test/run-test/make-html-reports.sh	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/make-html-reports.sh	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/bin/sh
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 src_dir=$1
 run=$2
 date=$3

=== modified file 'storage/ndb/test/run-test/make-index.sh'
--- a/storage/ndb/test/run-test/make-index.sh	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/test/run-test/make-index.sh	2011-01-30 20:42:21 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # NAME
 #   make-index.sh
 #

=== modified file 'storage/ndb/test/run-test/ndb-autotest.sh'
--- a/storage/ndb/test/run-test/ndb-autotest.sh	2006-08-21 13:34:29 +0000
+++ b/storage/ndb/test/run-test/ndb-autotest.sh	2011-01-30 20:42:21 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# Copyright (C) 2005, 2006 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 #############################################################
 # This script created by Jonas does the following	    #
 # Cleans up clones and pevious builds, pulls new clones,    #

=== modified file 'storage/ndb/test/run-test/setup.cpp'
--- a/storage/ndb/test/run-test/setup.cpp	2010-11-17 10:01:47 +0000
+++ b/storage/ndb/test/run-test/setup.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (c) 2007, 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
+*/
+
 #include "atrt.hpp"
 #include <ndb_global.h>
 #include <util/ndb_opts.h>

=== modified file 'storage/ndb/test/run-test/upgrade-boot.sh'
--- a/storage/ndb/test/run-test/upgrade-boot.sh	2007-08-31 14:12:51 +0000
+++ b/storage/ndb/test/run-test/upgrade-boot.sh	2011-01-30 20:42:21 +0000
@@ -1,4 +1,20 @@
 #!/bin/sh
+
+# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 #############################################################
 # This script created by Jonas does the following	    #
 # Cleans up clones and pevious builds, pulls new clones,    #

=== modified file 'storage/ndb/test/sql/BANK.sql'
--- a/storage/ndb/test/sql/BANK.sql	2005-09-15 10:53:59 +0000
+++ b/storage/ndb/test/sql/BANK.sql	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+-- Copyright (C) 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 CREATE DATABASE IF NOT EXISTS BANK default charset=latin1 default collate=latin1_bin;
 USE BANK;
 DROP TABLE IF EXISTS GL;

=== modified file 'storage/ndb/test/sql/T1.sql'
--- a/storage/ndb/test/sql/T1.sql	2005-09-15 10:53:59 +0000
+++ b/storage/ndb/test/sql/T1.sql	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+-- Copyright (C) 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 create database if not exists TEST_DB;
 use TEST_DB;
 drop table if exists T1;

=== modified file 'storage/ndb/test/sql/test_create_drop.pl'
--- a/storage/ndb/test/sql/test_create_drop.pl	2005-10-07 07:29:55 +0000
+++ b/storage/ndb/test/sql/test_create_drop.pl	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 use strict;
 use IO::Socket;
 use DBI;

=== modified file 'storage/ndb/test/sql/test_range_bounds.pl'
--- a/storage/ndb/test/sql/test_range_bounds.pl	2005-10-07 07:29:55 +0000
+++ b/storage/ndb/test/sql/test_range_bounds.pl	2011-01-30 20:42:21 +0000
@@ -1,3 +1,18 @@
+# Copyright (C) 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 #
 # test range scan bounds
 # give option --all to test all cases

=== modified file 'storage/ndb/test/tools/log_listner.cpp'
--- a/storage/ndb/test/tools/log_listner.cpp	2010-08-11 10:21:17 +0000
+++ b/storage/ndb/test/tools/log_listner.cpp	2011-01-30 20:56:00 +0000
@@ -1,3 +1,20 @@
+/*
+   Copyright (c) 2007, 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
+*/
+
 #include <mgmapi.h>
 #include <ndb_global.h>
 #include <ndb_opts.h>

=== modified file 'storage/ndb/tools/CMakeLists.txt'
--- a/storage/ndb/tools/CMakeLists.txt	2010-11-15 14:18:10 +0000
+++ b/storage/ndb/tools/CMakeLists.txt	2011-01-26 08:54:07 +0000
@@ -18,30 +18,58 @@ INCLUDE(${CMAKE_SOURCE_DIR}/storage/ndb/
 INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}/storage/ndb/src/ndbapi)
 
-ADD_EXECUTABLE(ndb_waiter waiter.cpp)
+MYSQL_ADD_EXECUTABLE(ndb_waiter
+  waiter.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_waiter ndbportlib ndbNDBT)
-ADD_EXECUTABLE(ndb_drop_table drop_tab.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_drop_table
+  drop_tab.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_drop_table ndbNDBT ndbgeneral)
-ADD_EXECUTABLE(ndb_delete_all delete_all.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_delete_all
+  delete_all.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_delete_all ndbNDBT)
-ADD_EXECUTABLE(ndb_desc desc.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_desc
+  desc.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_desc ndbNDBT)
-ADD_EXECUTABLE(ndb_drop_index drop_index.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_drop_index
+  drop_index.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_drop_index ndbNDBT)
-ADD_EXECUTABLE(ndb_show_tables listTables.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_show_tables
+  listTables.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_show_tables ndbclient ndbNDBT)
-ADD_EXECUTABLE(ndb_select_all select_all.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_select_all
+  select_all.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_select_all ndbNDBT)
-ADD_EXECUTABLE(ndb_select_count select_count.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_select_count
+  select_count.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_select_count ndbNDBT)
-ADD_EXECUTABLE(ndb_restore
-               restore/restore_main.cpp
-               restore/consumer.cpp
-               restore/consumer_restore.cpp
-               restore/consumer_printer.cpp
-               restore/Restore.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_restore
+  restore/restore_main.cpp
+  restore/consumer.cpp
+  restore/consumer_restore.cpp
+  restore/consumer_printer.cpp
+  restore/Restore.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_restore ndbNDBT ndbgeneral)
-ADD_EXECUTABLE(ndb_config ndb_config.cpp)
+
+MYSQL_ADD_EXECUTABLE(ndb_config
+  ndb_config.cpp
+  COMPONENT ClusterTools)
 TARGET_LINK_LIBRARIES(ndb_config ndbmgmclient ndbconf)
 
 SET(options "-I${CMAKE_SOURCE_DIR}/storage/ndb/src/mgmapi")

=== modified file 'storage/ndb/tools/clean-links.sh'
--- a/storage/ndb/tools/clean-links.sh	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/tools/clean-links.sh	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #! /bin/sh
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # 1 - Dir
 # 2 - Link dst
 

=== modified file 'storage/ndb/tools/make-errors.pl'
--- a/storage/ndb/tools/make-errors.pl	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/tools/make-errors.pl	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #! /usr/local/bin/perl
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 use strict;
 use Getopt::Long;
 use XML::Parser;

=== modified file 'storage/ndb/tools/make-links.sh'
--- a/storage/ndb/tools/make-links.sh	2005-04-27 01:19:54 +0000
+++ b/storage/ndb/tools/make-links.sh	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #! /bin/sh
 
+# Copyright (C) 2003, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
 # 1 - Link top src
 # 2 - Link dst
 

=== modified file 'storage/ndb/tools/ndb_error_reporter'
--- a/storage/ndb/tools/ndb_error_reporter	2009-02-12 08:29:00 +0000
+++ b/storage/ndb/tools/ndb_error_reporter	2011-01-30 20:42:21 +0000
@@ -1,5 +1,20 @@
 #!/usr/bin/perl -w
 
+# Copyright (C) 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
+#
+# 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
+
 use strict;
 
 if(@ARGV < 1)

=== modified file 'storage/ndb/tools/restore/Restore.cpp'
--- a/storage/ndb/tools/restore/Restore.cpp	2010-12-03 09:36:45 +0000
+++ b/storage/ndb/tools/restore/Restore.cpp	2011-01-21 08:38:59 +0000
@@ -507,6 +507,10 @@ end:
   return true;
 }
 
+#define OLD_NDB_REP_DB  "cluster"
+#define OLD_NDB_APPLY_TABLE "apply_status"
+#define OLD_NDB_SCHEMA_TABLE "schema"
+
 bool
 RestoreMetaData::markSysTables()
 {

=== modified file 'storage/ndb/tools/restore/consumer_restore.cpp'
--- a/storage/ndb/tools/restore/consumer_restore.cpp	2011-01-17 13:17:32 +0000
+++ b/storage/ndb/tools/restore/consumer_restore.cpp	2011-02-02 07:16:41 +0000
@@ -22,6 +22,7 @@
 #include <my_sys.h>
 #include <NdbSleep.h>
 #include <NdbTick.h>
+#include <Properties.hpp>
 
 #include <ndb_internal.hpp>
 #include <ndb_logevent.h>
@@ -41,6 +42,8 @@ extern BaseString g_options;
 extern unsigned int opt_no_binlog;
 extern bool ga_skip_broken_objects;
 
+extern Properties g_rewrite_databases;
+
 bool BackupRestore::m_preserve_trailing_spaces = false;
 
 const PromotionRules 
@@ -267,6 +270,40 @@ match_blob(const char * name){
   return -1;
 }
 
+/**
+ * Extracts the database, schema, and table name from an internal table name;
+ * prints an error message and returns false in case of a format violation.
+ */
+static
+bool
+dissect_table_name(const char * qualified_table_name,
+                   BaseString & db_name,
+                   BaseString & schema_name,
+                   BaseString & table_name) {
+  Vector<BaseString> split;
+  BaseString tmp(qualified_table_name);
+  if (tmp.split(split, "/") != 3) {
+    err << "Invalid table name format `" << qualified_table_name
+        << "`" << endl;
+    return false;
+  }
+  db_name = split[0];
+  schema_name = split[1];
+  table_name = split[2];
+  return true;
+}
+
+/**
+ * Assigns the new name for a database, if and only if to be rewritten.
+ */
+static
+void
+check_rewrite_database(BaseString & db_name) {
+  const char * new_db_name;
+  if (g_rewrite_databases.get(db_name.c_str(), &new_db_name))
+    db_name.assign(new_db_name);
+}
+
 const NdbDictionary::Table*
 BackupRestore::get_table(const NdbDictionary::Table* tab){
   if(m_cache.m_old_table == tab)
@@ -348,29 +385,31 @@ BackupRestore::rebuild_indexes(const Tab
   if (m_index_per_table.size() <= id)
     return true;
 
-  BaseString tmp(tablename);
-  Vector<BaseString> split;
-  if (tmp.split(split, "/") != 3)
-  {
-    err << "Invalid table name format " << tablename << endl;
+  BaseString db_name, schema_name, table_name;
+  if (!dissect_table_name(tablename, db_name, schema_name, table_name)) {
     return false;
   }
-  m_ndb->setDatabaseName(split[0].c_str());
-  m_ndb->setSchemaName(split[1].c_str());
+  check_rewrite_database(db_name);
+
+  m_ndb->setDatabaseName(db_name.c_str());
+  m_ndb->setSchemaName(schema_name.c_str());
   NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
 
   Vector<NdbDictionary::Index*> & indexes = m_index_per_table[id];
   for(size_t i = 0; i<indexes.size(); i++)
   {
-    NdbDictionary::Index * idx = indexes[i];
+    const NdbDictionary::Index * const idx = indexes[i];
+    const char * const idx_name = idx->getName();
+    const char * const tab_name = idx->getTable();
     Uint64 start = NdbTick_CurrentMillisecond();
-    info << "Rebuilding index " << idx->getName() << " on table "
-        << tab->getName() << " ..." << flush;
-    if (dict->createIndex(* idx, 1) != 0)
+    info << "Rebuilding index `" << idx_name << "` on table `"
+      << tab_name << "` ..." << flush;
+    if ((dict->getIndex(idx_name, tab_name) == NULL)
+        && (dict->createIndex(* idx, 1) != 0))
     {
       info << "FAIL!" << endl;
-      err << "Rebuilding index " << idx->getName() << " on table "
-        << tab->getName() <<" failed: ";
+      err << "Rebuilding index `" << idx_name << "` on table `"
+        << tab_name <<"` failed: ";
       err << dict->getNdbError() << endl;
 
       return false;
@@ -1217,19 +1256,19 @@ BackupRestore::table_compatible_check(co
     return true;
   }
 
-  BaseString tmp(tablename);
-  Vector<BaseString> split;
-  if(tmp.split(split, "/") != 3){
-    err << "Invalid table name format " << tablename << endl;
+  BaseString db_name, schema_name, table_name;
+  if (!dissect_table_name(tablename, db_name, schema_name, table_name)) {
     return false;
   }
-  m_ndb->setDatabaseName(split[0].c_str());
-  m_ndb->setSchemaName(split[1].c_str());
+  check_rewrite_database(db_name);
+
+  m_ndb->setDatabaseName(db_name.c_str());
+  m_ndb->setSchemaName(schema_name.c_str());
 
   NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
-  const NdbDictionary::Table* tab = dict->getTable(split[2].c_str());
+  const NdbDictionary::Table* tab = dict->getTable(table_name.c_str());
   if(tab == 0){
-    err << "Unable to find table: " << split[2].c_str() << endl;
+    err << "Unable to find table: " << table_name << endl;
     return false;
   }
 
@@ -1428,18 +1467,18 @@ BackupRestore::createSystable(const Tabl
     return true;
   }
 
-  BaseString tmp(tablename);
-  Vector<BaseString> split;
-  if(tmp.split(split, "/") != 3){
-    err << "Invalid table name format " << tablename << endl;
+  BaseString db_name, schema_name, table_name;
+  if (!dissect_table_name(tablename, db_name, schema_name, table_name)) {
     return false;
   }
+  // do not rewrite database for system tables:
+  // check_rewrite_database(db_name);
 
-  m_ndb->setDatabaseName(split[0].c_str());
-  m_ndb->setSchemaName(split[1].c_str());
+  m_ndb->setDatabaseName(db_name.c_str());
+  m_ndb->setSchemaName(schema_name.c_str());
 
   NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
-  if( dict->getTable(split[2].c_str()) != NULL ){
+  if( dict->getTable(table_name.c_str()) != NULL ){
     return true;
   }
   return table(tables);
@@ -1464,22 +1503,21 @@ BackupRestore::table(const TableS & tabl
     return true;
   }
   
-  BaseString tmp(name);
-  Vector<BaseString> split;
-  if(tmp.split(split, "/") != 3){
-    err << "Invalid table name format `" << name << "`" << endl;
+  BaseString db_name, schema_name, table_name;
+  if (!dissect_table_name(name, db_name, schema_name, table_name)) {
     return false;
   }
+  check_rewrite_database(db_name);
 
-  m_ndb->setDatabaseName(split[0].c_str());
-  m_ndb->setSchemaName(split[1].c_str());
+  m_ndb->setDatabaseName(db_name.c_str());
+  m_ndb->setSchemaName(schema_name.c_str());
   
   NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
   if(m_restore_meta)
   {
     NdbDictionary::Table copy(*table.m_dictTable);
 
-    copy.setName(split[2].c_str());
+    copy.setName(table_name.c_str());
     Uint32 id;
     if (copy.getTablespace(&id))
     {
@@ -1598,9 +1636,9 @@ BackupRestore::table(const TableS & tabl
          << table.getTableName() << "`" << endl;
   }  
   
-  const NdbDictionary::Table* tab = dict->getTable(split[2].c_str());
+  const NdbDictionary::Table* tab = dict->getTable(table_name.c_str());
   if(tab == 0){
-    err << "Unable to find table: `" << split[2].c_str() << "`" << endl;
+    err << "Unable to find table: `" << table_name << "`" << endl;
     return false;
   }
   if(m_restore_meta)
@@ -1609,9 +1647,9 @@ BackupRestore::table(const TableS & tabl
     {
       // a MySQL Server table is restored, thus an event should be created
       BaseString event_name("REPL$");
-      event_name.append(split[0].c_str());
+      event_name.append(db_name.c_str());
       event_name.append("/");
-      event_name.append(split[2].c_str());
+      event_name.append(table_name.c_str());
 
       NdbDictionary::Event my_event(event_name.c_str());
       my_event.setTable(*tab);
@@ -1642,7 +1680,7 @@ BackupRestore::table(const TableS & tabl
 	}
 	err << "Create table event for " << table.getTableName() << " failed: "
 	    << dict->getNdbError() << endl;
-	dict->dropTable(split[2].c_str());
+	dict->dropTable(table_name.c_str());
 	return false;
       }
       info.setLevel(254);
@@ -1667,23 +1705,19 @@ BackupRestore::endOfTables(){
   for(size_t i = 0; i<m_indexes.size(); i++){
     NdbTableImpl & indtab = NdbTableImpl::getImpl(* m_indexes[i]);
 
-    Vector<BaseString> split;
-    {
-      BaseString tmp(indtab.m_primaryTable.c_str());
-      if (tmp.split(split, "/") != 3)
-      {
-        err << "Invalid table name format `" << indtab.m_primaryTable.c_str()
-            << "`" << endl;
-        return false;
-      }
+    BaseString db_name, schema_name, table_name;
+    if (!dissect_table_name(indtab.m_primaryTable.c_str(),
+                            db_name, schema_name, table_name)) {
+      return false;
     }
-    
-    m_ndb->setDatabaseName(split[0].c_str());
-    m_ndb->setSchemaName(split[1].c_str());
-    
-    const NdbDictionary::Table * prim = dict->getTable(split[2].c_str());
+    check_rewrite_database(db_name);
+
+    m_ndb->setDatabaseName(db_name.c_str());
+    m_ndb->setSchemaName(schema_name.c_str());
+
+    const NdbDictionary::Table * prim = dict->getTable(table_name.c_str());
     if(prim == 0){
-      err << "Unable to find base table `" << split[2].c_str() 
+      err << "Unable to find base table `" << table_name
 	  << "` for index `"
 	  << indtab.getName() << "`" << endl;
       if (ga_skip_broken_objects)
@@ -1706,7 +1740,7 @@ BackupRestore::endOfTables(){
     if(NdbDictInterface::create_index_obj_from_table(&idx, &indtab, &base))
     {
       err << "Failed to create index `" << split_idx[3]
-	  << "` on " << split[2].c_str() << endl;
+	  << "` on " << table_name << endl;
 	return false;
     }
     idx->setName(split_idx[3].c_str());
@@ -1716,13 +1750,13 @@ BackupRestore::endOfTables(){
       {
         delete idx;
         err << "Failed to create index `" << split_idx[3].c_str()
-            << "` on `" << split[2].c_str() << "`" << endl
+            << "` on `" << table_name << "`" << endl
             << dict->getNdbError() << endl;
 
         return false;
       }
       info << "Successfully created index `" << split_idx[3].c_str()
-          << "` on `" << split[2].c_str() << "`" << endl;
+          << "` on `" << table_name << "`" << endl;
     }
     else if (m_disable_indexes)
     {
@@ -1730,7 +1764,7 @@ BackupRestore::endOfTables(){
       if (res == 0)
       {
         info << "Dropped index `" << split_idx[3].c_str()
-            << "` on `" << split[2].c_str() << "`" << endl;
+            << "` on `" << table_name << "`" << endl;
       }
     }
     Uint32 id = prim->getObjectId();

=== modified file 'storage/ndb/tools/restore/restore_main.cpp'
--- a/storage/ndb/tools/restore/restore_main.cpp	2010-12-03 09:36:45 +0000
+++ b/storage/ndb/tools/restore/restore_main.cpp	2011-02-02 07:16:41 +0000
@@ -19,6 +19,7 @@
 #include <ndb_global.h>
 #include <ndb_opts.h>
 #include <Vector.hpp>
+#include <Properties.hpp>
 #include <ndb_limits.h>
 #include <NdbTCP.h>
 #include <NdbMem.h>
@@ -63,6 +64,7 @@ Vector<BaseString> g_databases;
 Vector<BaseString> g_tables;
 Vector<BaseString> g_include_tables, g_exclude_tables;
 Vector<BaseString> g_include_databases, g_exclude_databases;
+Properties g_rewrite_databases;
 NdbRecordPrintFormat g_ndbrecord_print_format;
 unsigned int opt_no_binlog;
 
@@ -77,6 +79,8 @@ public:
 Vector<class RestoreOption *> g_include_exclude;
 static void save_include_exclude(int optid, char * argument);
 
+static inline void parse_rewrite_database(char * argument);
+
 /**
  * print and restore flags
  */
@@ -106,7 +110,8 @@ enum ndb_restore_options {
   OPT_INCLUDE_TABLES,
   OPT_EXCLUDE_TABLES,
   OPT_INCLUDE_DATABASES,
-  OPT_EXCLUDE_DATABASES
+  OPT_EXCLUDE_DATABASES,
+  OPT_REWRITE_DATABASE
 };
 static const char *opt_fields_enclosed_by= NULL;
 static const char *opt_fields_terminated_by= NULL;
@@ -119,6 +124,7 @@ static const char *opt_exclude_tables= N
 static const char *opt_include_tables= NULL;
 static const char *opt_exclude_databases= NULL;
 static const char *opt_include_databases= NULL;
+static const char *opt_rewrite_database= NULL;
 
 static struct my_option my_long_options[] =
 {
@@ -247,6 +253,11 @@ static struct my_option my_long_options[
     "Comma separated list of databases to not restore. Example: db1,db3",
     (uchar**) &opt_exclude_databases, (uchar**) &opt_exclude_databases, 0,
     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+  { "rewrite-database", OPT_REWRITE_DATABASE,
+    "A pair 'source,dest' of database names from/into which to restore. "
+    "Example: --rewrite-database=oldDb,newDb",
+    (uchar**) &opt_rewrite_database, (uchar**) &opt_rewrite_database, 0,
+    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
   { "include-tables", OPT_INCLUDE_TABLES, "Comma separated list of tables to "
     "restore. Table name should include database name. Example: db1.t1,db3.t1", 
     (uchar**) &opt_include_tables, (uchar**) &opt_include_tables, 0,
@@ -449,6 +460,9 @@ get_one_option(int optid, const struct m
   case OPT_EXCLUDE_TABLES:
     save_include_exclude(optid, argument);
     break;
+  case OPT_REWRITE_DATABASE:
+    parse_rewrite_database(argument);
+    break;
   }
   return 0;
 }
@@ -710,6 +724,20 @@ o verify nodegroup mapping
     info << endl;
   }
   
+  if (opt_rewrite_database)
+  {
+    info << "Rewriting databases:";
+    Properties::Iterator it(&g_rewrite_databases);
+    const char * src;
+    for (src = it.first(); src != NULL; src = it.next()) {
+      const char * dst = NULL;
+      bool r = g_rewrite_databases.get(src, &dst);
+      assert(r && (dst != NULL));
+      info << " (" << src << "->" << dst << ")";
+    }
+    info << endl;
+  }
+
   if (opt_include_tables)
   {
     processTableList(opt_include_tables, g_include_tables);
@@ -840,6 +868,27 @@ getTableName(const TableS* table)
   return table_name;
 }
 
+static void parse_rewrite_database(char * argument)
+{
+  const BaseString arg(argument);
+  Vector<BaseString> args;
+  unsigned int n = arg.split(args, ",");
+  if ((n == 2)
+      && (args[0].length() > 0)
+      && (args[1].length() > 0)) {
+    const BaseString src = args[0];
+    const BaseString dst = args[1];
+    const bool replace = true;
+    bool r = g_rewrite_databases.put(src.c_str(), dst.c_str(), replace);
+    assert(r);
+    return; // ok
+  }
+
+  info << "argument `" << arg.c_str()
+       << "` is not a pair 'a,b' of non-empty names." << endl;
+  exit(NDBT_ProgramExit(NDBT_WRONGARGS));
+}
+
 static void save_include_exclude(int optid, char * argument)
 {
   BaseString arg = argument;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3414 to 3415) Ole John Aske2 Feb