summaryrefslogtreecommitdiff
path: root/mysql-test/suite/ndb_team
diff options
context:
space:
mode:
authorunknown <tomas@whalegate.ndb.mysql.com>2007-09-05 19:13:36 +0200
committerunknown <tomas@whalegate.ndb.mysql.com>2007-09-05 19:13:36 +0200
commit91f14cdb2b0e34a5923e345619f390021739fbd0 (patch)
tree097ca47343e0d4c1539f450058c1805352c6b783 /mysql-test/suite/ndb_team
parent4a3825c4de3c306f4bfb33a43d323856921d9501 (diff)
downloadmariadb-git-91f14cdb2b0e34a5923e345619f390021739fbd0.tar.gz
moving these tests to suite ndb_team
mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt: Rename: mysql-test/suite/ndb/t/ndb_autodiscover2-master.opt -> mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt mysql-test/suite/ndb_team/t/ndb_autodiscover2.test: Rename: mysql-test/suite/ndb/t/ndb_autodiscover2.test -> mysql-test/suite/ndb_team/t/ndb_autodiscover2.test mysql-test/suite/ndb_team/t/ndb_autodiscover.test: Rename: mysql-test/suite/ndb/t/ndb_autodiscover.test -> mysql-test/suite/ndb_team/t/ndb_autodiscover.test mysql-test/suite/ndb_team/t/ndb_autodiscover3.test: Rename: mysql-test/suite/ndb/t/ndb_autodiscover3.test -> mysql-test/suite/ndb_team/t/ndb_autodiscover3.test mysql-test/suite/ndb_team/r/ndb_autodiscover.result: Rename: mysql-test/suite/ndb/r/ndb_autodiscover.result -> mysql-test/suite/ndb_team/r/ndb_autodiscover.result mysql-test/suite/ndb_team/r/ndb_autodiscover2.result: Rename: mysql-test/suite/ndb/r/ndb_autodiscover2.result -> mysql-test/suite/ndb_team/r/ndb_autodiscover2.result mysql-test/suite/ndb_team/r/ndb_autodiscover3.result: Rename: mysql-test/suite/ndb/r/ndb_autodiscover3.result -> mysql-test/suite/ndb_team/r/ndb_autodiscover3.result mysql-test/suite/ndb_team/t/disabled.def: BitKeeper file /home/tomas/mysql-5.1-new-ndb/mysql-test/suite/ndb_team/t/disabled.def
Diffstat (limited to 'mysql-test/suite/ndb_team')
-rw-r--r--mysql-test/suite/ndb_team/r/ndb_autodiscover.result397
-rw-r--r--mysql-test/suite/ndb_team/r/ndb_autodiscover2.result13
-rw-r--r--mysql-test/suite/ndb_team/r/ndb_autodiscover3.result53
-rw-r--r--mysql-test/suite/ndb_team/t/disabled.def17
-rw-r--r--mysql-test/suite/ndb_team/t/ndb_autodiscover.test548
-rw-r--r--mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt1
-rw-r--r--mysql-test/suite/ndb_team/t/ndb_autodiscover2.test21
-rw-r--r--mysql-test/suite/ndb_team/t/ndb_autodiscover3.test104
8 files changed, 1154 insertions, 0 deletions
diff --git a/mysql-test/suite/ndb_team/r/ndb_autodiscover.result b/mysql-test/suite/ndb_team/r/ndb_autodiscover.result
new file mode 100644
index 00000000000..487f52f6427
--- /dev/null
+++ b/mysql-test/suite/ndb_team/r/ndb_autodiscover.result
@@ -0,0 +1,397 @@
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+flush status;
+create table t1(
+id int not null primary key,
+name char(20)
+) engine=ndb;
+insert into t1 values(1, "Autodiscover");
+flush tables;
+select * from t1;
+id name
+1 Autodiscover
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 1
+flush tables;
+insert into t1 values (2, "Auto 2");
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 2
+insert into t1 values (3, "Discover 3");
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 2
+flush tables;
+select * from t1 order by id;
+id name
+1 Autodiscover
+2 Auto 2
+3 Discover 3
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 3
+flush tables;
+update t1 set name="Autodiscover" where id = 2;
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 4
+select * from t1 order by id;
+id name
+1 Autodiscover
+2 Autodiscover
+3 Discover 3
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 4
+flush tables;
+delete from t1 where id = 3;
+select * from t1 order by id;
+id name
+1 Autodiscover
+2 Autodiscover
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 5
+drop table t1;
+flush status;
+create table t2(
+id int not null primary key,
+name char(22)
+) engine=ndb;
+insert into t2 values (1, "Discoverer");
+select * from t2;
+id name
+1 Discoverer
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+flush tables;
+select * from t2;
+id name
+1 Discoverer
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 1
+drop table t2;
+flush status;
+create table t3(
+id int not null primary key,
+name char(255)
+) engine=ndb;
+insert into t3 values (1, "Explorer");
+select * from t3;
+id name
+1 Explorer
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+flush tables;
+create table t3(
+id int not null primary key,
+name char(20), a int, b float, c char(24)
+) engine=ndb;
+ERROR 42S01: Table 't3' already exists
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+create table IF NOT EXISTS t3(
+id int not null primary key,
+id2 int not null,
+name char(20)
+) engine=ndb;
+Warnings:
+Note 1050 Table 't3' already exists
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `id` int(11) NOT NULL,
+ `name` char(255) default NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY ()
+select * from t3;
+id name
+1 Explorer
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 1
+drop table t3;
+flush status;
+create table t7(
+id int not null primary key,
+name char(255)
+) engine=ndb;
+create table t6(
+id int not null primary key,
+name char(255)
+) engine=MyISAM;
+insert into t7 values (1, "Explorer");
+insert into t6 values (2, "MyISAM table");
+select * from t7;
+id name
+1 Explorer
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+flush tables;
+show tables from test;
+Tables_in_test
+t6
+t7
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 1
+flush tables;
+show table status;
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
+t6 MyISAM 10 Fixed 1 # # # # 0 NULL # # NULL # NULL #
+t7 NDBCLUSTER 10 Fixed 1 # # # # 0 NULL # # NULL # NULL #
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 2
+drop table t6, t7;
+flush status;
+create table t4(
+id int not null primary key,
+name char(27)
+) engine=ndb;
+insert into t4 values (1, "Automatic");
+select * from t4;
+id name
+1 Automatic
+select * from t4;
+ERROR 42S02: Table 'test.t4' doesn't exist
+select * from t4;
+ERROR 42S02: Table 'test.t4' doesn't exist
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+drop table t4;
+ERROR 42S02: Unknown table 't4'
+create table t4(
+id int not null primary key,
+name char(27)
+) engine=ndb;
+insert into t4 values (1, "Automatic");
+select * from t4;
+id name
+1 Automatic
+select * from t4;
+ERROR 42S02: Table 'test.t4' doesn't exist
+drop table if exists t4;
+Warnings:
+Error 155 Table 'test.t4' doesn't exist
+drop table t5;
+ERROR 42S02: Unknown table 't5'
+drop table if exists t5;
+Warnings:
+Note 1051 Unknown table 't5'
+flush status;
+create table t4(
+id int not null primary key,
+id2 int,
+name char(27)
+) engine=ndb;
+insert into t4 values (1, 76, "Automatic2");
+select * from t4;
+id id2 name
+1 76 Automatic2
+flush tables;
+SHOW TABLES;
+Tables_in_test
+select * from t4;
+ERROR 42S02: Table 'test.t4' doesn't exist
+flush status;
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=myisam;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+create table t5(id int, d char(56)) engine=ndbcluster;
+create table t6(id int) engine=ndbcluster;
+create table t7(id int) engine=ndbcluster;
+create table t8(id int, e char(34)) engine=myisam;
+create table t9(id int) engine=myisam;
+insert into t2 values (2, "myisam table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t5 values (5, "ndb table 5");
+insert into t6 values (6);
+insert into t8 values (8, "myisam table 8");
+insert into t9 values (9);
+SHOW TABLES;
+Tables_in_test
+t1
+t2
+t4
+t8
+t9
+t7
+t6
+select * from t6;
+id
+6
+select * from t7;
+id
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 2
+drop table t1, t2, t4, t6, t7, t8, t9;
+flush status;
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=myisam;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+create table t5(id int, d char(56)) engine=ndbcluster;
+create table t6(id int) engine=ndbcluster;
+create table t7(id int) engine=ndbcluster;
+create table t8(id int, e char(34)) engine=myisam;
+create table t9(id int) engine=myisam;
+insert into t2 values (2, "myisam table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t5 values (5, "ndb table 5");
+insert into t6 values (6);
+insert into t8 values (8, "myisam table 8");
+insert into t9 values (9);
+SHOW TABLES LIKE 't6';
+Tables_in_test (t6)
+t6
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 1
+create table t3(a int);
+ERROR 42S01: Table 't3' already exists
+create table t5(a int);
+ERROR 42S01: Table 't5' already exists
+SHOW TABLES LIKE 't%';
+Tables_in_test (t%)
+t1
+t2
+t4
+t6
+t8
+t9
+t7
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 2
+drop table t1, t2, t4, t6, t7, t8, t9;
+flush status;
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=ndbcluster;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+insert into t1 values (1);
+insert into t2 values (2, "table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t4 values (4);
+flush tables;
+select * from t1, t2, t3, t4;
+id id b id c id
+1 2 table 2 3 ndb table 3 4
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 3
+drop table t1, t2, t3, t4;
+flush status;
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+create table t5(
+id int not null primary key,
+name char(200)
+) engine=ndb;
+insert into t5 values (1, "Magnus");
+select * from t5;
+id name
+1 Magnus
+ALTER TABLE t5 ADD COLUMN adress char(255) FIRST;
+select * from t5;
+adress id name
+NULL 1 Magnus
+insert into t5 values
+("Adress for record 2", 2, "Carl-Gustav"),
+("Adress for record 3", 3, "Karl-Emil");
+update t5 set name="Bertil" where id = 2;
+select * from t5 order by id;
+adress id name
+NULL 1 Magnus
+Adress for record 2 2 Bertil
+Adress for record 3 3 Karl-Emil
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+drop table t5;
+flush status;
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+create table t6(
+id int not null primary key,
+name char(20)
+) engine=ndb;
+insert into t6 values (1, "Magnus");
+select * from t6;
+id name
+1 Magnus
+ALTER TABLE t6 ADD COLUMN adress char(255) FIRST;
+select * from t6;
+adress id name
+NULL 1 Magnus
+insert into t6 values
+("Adress for record 2", 2, "Carl-Gustav"),
+("Adress for record 3", 3, "Karl-Emil");
+update t6 set name="Bertil" where id = 2;
+select * from t6 order by id;
+adress id name
+NULL 1 Magnus
+Adress for record 2 2 Bertil
+Adress for record 3 3 Karl-Emil
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+drop table t6;
+show tables;
+Tables_in_test
+create table t1 (a int,b longblob) engine=ndb;
+show tables;
+Tables_in_test
+t1
+create database test2;
+use test2;
+show tables;
+Tables_in_test2
+select * from t1;
+ERROR 42S02: Table 'test2.t1' doesn't exist
+create table t2 (b int,c longblob) engine=ndb;
+use test;
+select * from t1;
+a b
+show tables;
+Tables_in_test
+t1
+drop table t1;
+use test2;
+drop table t2;
+drop database test2;
+use test;
+drop database if exists test_only_ndb_tables;
+create database test_only_ndb_tables;
+use test_only_ndb_tables;
+create table t1 (a int primary key) engine=ndb;
+select * from t1;
+a
+select * from t1;
+ERROR HY000: Can't lock file (errno: 157)
+use test;
+drop database test_only_ndb_tables;
+CREATE TABLE t9 (
+a int NOT NULL PRIMARY KEY,
+b int
+) engine=ndb;
+insert t9 values(1, 2), (2,3), (3, 4), (4, 5);
+create table t10 (
+a int not null primary key,
+b blob
+) engine=ndb;
+insert into t10 values (1, 'kalle');
diff --git a/mysql-test/suite/ndb_team/r/ndb_autodiscover2.result b/mysql-test/suite/ndb_team/r/ndb_autodiscover2.result
new file mode 100644
index 00000000000..269888e0820
--- /dev/null
+++ b/mysql-test/suite/ndb_team/r/ndb_autodiscover2.result
@@ -0,0 +1,13 @@
+select * from t9 order by a;
+a b
+1 2
+2 3
+3 4
+4 5
+show status like 'handler_discover%';
+Variable_name Value
+Handler_discover 0
+drop table t9;
+select * from t10;
+ERROR HY000: Got error 4263 'Invalid blob attributes or invalid blob parts table' from NDBCLUSTER
+drop table t10;
diff --git a/mysql-test/suite/ndb_team/r/ndb_autodiscover3.result b/mysql-test/suite/ndb_team/r/ndb_autodiscover3.result
new file mode 100644
index 00000000000..86495ebb3eb
--- /dev/null
+++ b/mysql-test/suite/ndb_team/r/ndb_autodiscover3.result
@@ -0,0 +1,53 @@
+drop table if exists t1, t2;
+create table t1 (a int key) engine=ndbcluster;
+begin;
+insert into t1 values (1);
+insert into t1 values (2);
+ERROR HY000: Got temporary error 4025 'Node failure caused abort of transaction' from NDBCLUSTER
+commit;
+ERROR HY000: Got error 4350 'Transaction already aborted' from NDBCLUSTER
+drop table t1;
+create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster;
+insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1);
+select * from t2 order by a limit 3;
+a b
+1 1
+2 1
+3 1
+select * from t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+show tables like 't2';
+Tables_in_test (t2)
+reset master;
+create table t2 (a int key) engine=ndbcluster;
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+select * from t2 order by a limit 3;
+a
+1
+2
+3
+select * from t2 order by a limit 3;
+a
+1
+2
+3
+reset master;
+select * from t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+show tables like 't2';
+Tables_in_test (t2)
+reset master;
+create table t2 (a int key) engine=ndbcluster;
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+select * from t2 order by a limit 3;
+a
+1
+2
+3
+select * from t2 order by a limit 3;
+a
+1
+2
+3
+reset master;
+drop table t2;
diff --git a/mysql-test/suite/ndb_team/t/disabled.def b/mysql-test/suite/ndb_team/t/disabled.def
new file mode 100644
index 00000000000..8ff2d29147d
--- /dev/null
+++ b/mysql-test/suite/ndb_team/t/disabled.def
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# List the test cases that are to be disabled temporarily.
+#
+# Separate the test case name and the comment with ':'.
+#
+# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+# Do not use any TAB characters for whitespace.
+#
+##############################################################################
+ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
+ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog
+
+# the below testcase have been reworked to avoid the bug, test contains comment, keep bug open
+#ndb_autodiscover3 : bug#21806
+#ndb_autodiscover3 : Bug#20872 2007-07-15 ingo master*.err: miscellaneous error messages
diff --git a/mysql-test/suite/ndb_team/t/ndb_autodiscover.test b/mysql-test/suite/ndb_team/t/ndb_autodiscover.test
new file mode 100644
index 00000000000..06d47693c10
--- /dev/null
+++ b/mysql-test/suite/ndb_team/t/ndb_autodiscover.test
@@ -0,0 +1,548 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+--enable_warnings
+
+################################################
+# Test that a table that does not exist as a
+# frm file on disk can be "discovered" from a
+# connected NDB Cluster
+#
+
+flush status;
+
+#
+# Test discover + SELECT
+#
+
+create table t1(
+ id int not null primary key,
+ name char(20)
+) engine=ndb;
+
+insert into t1 values(1, "Autodiscover");
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+select * from t1;
+show status like 'handler_discover%';
+
+#
+# Test discover + INSERT
+#
+
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+insert into t1 values (2, "Auto 2");
+show status like 'handler_discover%';
+insert into t1 values (3, "Discover 3");
+show status like 'handler_discover%';
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+select * from t1 order by id;
+show status like 'handler_discover%';
+
+#
+# Test discover + UPDATE
+#
+
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+update t1 set name="Autodiscover" where id = 2;
+show status like 'handler_discover%';
+select * from t1 order by id;
+show status like 'handler_discover%';
+
+#
+# Test discover + DELETE
+#
+
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+delete from t1 where id = 3;
+select * from t1 order by id;
+show status like 'handler_discover%';
+
+drop table t1;
+
+
+
+######################################################
+# Test that a table that is outdated on disk
+# can be "discovered" from a connected NDB Cluster
+#
+
+flush status;
+
+create table t2(
+ id int not null primary key,
+ name char(22)
+) engine=ndb;
+insert into t2 values (1, "Discoverer");
+select * from t2;
+show status like 'handler_discover%';
+flush tables;
+
+# Modify the frm file on disk
+system echo "blaj" >> $MYSQLTEST_VARDIR/master-data/test/t2.frm ;
+select * from t2;
+
+show status like 'handler_discover%';
+
+drop table t2;
+
+
+##################################################
+# Test that a table that already exists in NDB
+# is only discovered if CREATE TABLE IF NOT EXISTS
+# is used
+#
+
+flush status;
+
+create table t3(
+ id int not null primary key,
+ name char(255)
+) engine=ndb;
+insert into t3 values (1, "Explorer");
+select * from t3;
+show status like 'handler_discover%';
+flush tables;
+
+# Remove the frm file from disk
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
+
+--error 1050
+create table t3(
+ id int not null primary key,
+ name char(20), a int, b float, c char(24)
+) engine=ndb;
+
+# The table shall not have been discovered since
+# IF NOT EXISTS wasn't specified
+
+show status like 'handler_discover%';
+
+# now it should be discovered
+create table IF NOT EXISTS t3(
+ id int not null primary key,
+ id2 int not null,
+ name char(20)
+) engine=ndb;
+
+# NOTE! the table called t3 have now been updated to
+# use the same frm as in NDB, thus it's not certain that
+# the table schema is the same as was stated in the
+# CREATE TABLE statement above
+
+show status like 'handler_discover%';
+
+SHOW CREATE TABLE t3;
+
+select * from t3;
+show status like 'handler_discover%';
+
+drop table t3;
+
+##################################################
+# Test that a table that already exists in NDB
+# is discovered when SHOW TABLES
+# is used
+#
+
+flush status;
+
+create table t7(
+ id int not null primary key,
+ name char(255)
+) engine=ndb;
+create table t6(
+ id int not null primary key,
+ name char(255)
+) engine=MyISAM;
+insert into t7 values (1, "Explorer");
+insert into t6 values (2, "MyISAM table");
+select * from t7;
+show status like 'handler_discover%';
+
+# Remove the frm file from disk
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
+
+show tables from test;
+show status like 'handler_discover%';
+
+# Remove the frm file from disk again
+flush tables;
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
+
+--replace_column 6 # 7 # 8 # 9 # 12 # 13 # 15 # 18 #
+show table status;
+show status like 'handler_discover%';
+
+drop table t6, t7;
+
+
+#######################################################
+# Test that a table that has been dropped from NDB
+# but still exists on disk, get a consistent error message
+# saying "No such table existed"
+#
+
+flush status;
+
+create table t4(
+ id int not null primary key,
+ name char(27)
+) engine=ndb;
+insert into t4 values (1, "Automatic");
+select * from t4;
+
+# Remove the table from NDB
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ;
+
+#
+# Test that correct error is returned
+--error 1146
+select * from t4;
+--error 1146
+select * from t4;
+
+show status like 'handler_discover%';
+--error 1051
+drop table t4;
+
+create table t4(
+ id int not null primary key,
+ name char(27)
+) engine=ndb;
+insert into t4 values (1, "Automatic");
+select * from t4;
+
+# Remove the table from NDB
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ;
+
+--error 1146
+select * from t4;
+
+drop table if exists t4;
+
+# Test that dropping a table that does not exists
+# on disk or in NDB gives same result as above
+--error 1051
+drop table t5;
+drop table if exists t5;
+
+
+#######################################################
+# Test that a table that has been dropped from NDB
+# but still exists on disk is deleted from disk
+# when SHOW TABLES is called
+#
+
+flush status;
+
+create table t4(
+ id int not null primary key,
+ id2 int,
+ name char(27)
+) engine=ndb;
+insert into t4 values (1, 76, "Automatic2");
+select * from t4;
+flush tables;
+
+# Remove the table from NDB
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t4 >> $NDB_TOOLS_OUTPUT ;
+
+SHOW TABLES;
+
+--error 1146
+select * from t4;
+
+#######################################################
+# Test SHOW TABLES ability to detect new and delete old
+# tables. Test all at once using many tables
+#
+
+flush status;
+
+# Create tables
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=myisam;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+create table t5(id int, d char(56)) engine=ndbcluster;
+create table t6(id int) engine=ndbcluster;
+create table t7(id int) engine=ndbcluster;
+create table t8(id int, e char(34)) engine=myisam;
+create table t9(id int) engine=myisam;
+
+# Populate tables
+insert into t2 values (2, "myisam table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t5 values (5, "ndb table 5");
+insert into t6 values (6);
+insert into t8 values (8, "myisam table 8");
+insert into t9 values (9);
+
+# Remove t3, t5 from NDB
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 >> $NDB_TOOLS_OUTPUT ;
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 >> $NDB_TOOLS_OUTPUT ;
+# Remove t6, t7 from disk
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
+
+SHOW TABLES;
+
+select * from t6;
+select * from t7;
+
+show status like 'handler_discover%';
+
+drop table t1, t2, t4, t6, t7, t8, t9;
+
+#######################################################
+# Test SHOW TABLES LIKE ability to detect new and delete old
+# tables. Test all at once using many tables.
+#
+
+flush status;
+
+# Create tables
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=myisam;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+create table t5(id int, d char(56)) engine=ndbcluster;
+create table t6(id int) engine=ndbcluster;
+create table t7(id int) engine=ndbcluster;
+create table t8(id int, e char(34)) engine=myisam;
+create table t9(id int) engine=myisam;
+
+# Populate tables
+insert into t2 values (2, "myisam table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t5 values (5, "ndb table 5");
+insert into t6 values (6);
+insert into t8 values (8, "myisam table 8");
+insert into t9 values (9);
+
+# Remove t3, t5 from NDB
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t3 > /dev/null ;
+system exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test t5 > /dev/null ;
+# Remove t6, t7 from disk
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t6.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t7.frm
+
+
+SHOW TABLES LIKE 't6';
+
+show status like 'handler_discover%';
+
+# Check that t3 or t5 can't be created
+# frm files for these tables is stilll on disk
+--error 1050
+create table t3(a int);
+--error 1050
+create table t5(a int);
+
+SHOW TABLES LIKE 't%';
+
+show status like 'handler_discover%';
+
+drop table t1, t2, t4, t6, t7, t8, t9;
+
+
+
+######################################################
+# Test that several tables can be discovered when
+# one statement access several table at once.
+#
+
+flush status;
+
+# Create tables
+create table t1(id int) engine=ndbcluster;
+create table t2(id int, b char(255)) engine=ndbcluster;
+create table t3(id int, c char(255)) engine=ndbcluster;
+create table t4(id int) engine=myisam;
+
+# Populate tables
+insert into t1 values (1);
+insert into t2 values (2, "table 2");
+insert into t3 values (3, "ndb table 3");
+insert into t4 values (4);
+
+# Remove t1, t2, t3 from disk
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t2.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t3.frm
+flush tables;
+
+# Select from the table which only exists in NDB.
+select * from t1, t2, t3, t4;
+
+# 3 table should have been discovered
+show status like 'handler_discover%';
+
+drop table t1, t2, t3, t4;
+
+
+#########################################################
+# Test that a table that has been changed in NDB
+# since it's been opened will be refreshed and discovered
+# again
+#
+
+flush status;
+
+show status like 'handler_discover%';
+
+create table t5(
+ id int not null primary key,
+ name char(200)
+) engine=ndb;
+insert into t5 values (1, "Magnus");
+select * from t5;
+
+ALTER TABLE t5 ADD COLUMN adress char(255) FIRST;
+
+select * from t5;
+
+insert into t5 values
+ ("Adress for record 2", 2, "Carl-Gustav"),
+ ("Adress for record 3", 3, "Karl-Emil");
+update t5 set name="Bertil" where id = 2;
+select * from t5 order by id;
+
+show status like 'handler_discover%';
+
+drop table t5;
+
+
+################################################################
+# Test that a table that has been changed with ALTER TABLE
+# can be used from the same thread
+#
+
+flush status;
+
+show status like 'handler_discover%';
+
+create table t6(
+ id int not null primary key,
+ name char(20)
+) engine=ndb;
+insert into t6 values (1, "Magnus");
+select * from t6;
+
+ALTER TABLE t6 ADD COLUMN adress char(255) FIRST;
+
+select * from t6;
+insert into t6 values
+ ("Adress for record 2", 2, "Carl-Gustav"),
+ ("Adress for record 3", 3, "Karl-Emil");
+update t6 set name="Bertil" where id = 2;
+select * from t6 order by id;
+
+show status like 'handler_discover%';
+
+drop table t6;
+
+#####################################################
+# Test that only tables in the current database shows
+# up in SHOW TABLES
+#
+
+show tables;
+
+create table t1 (a int,b longblob) engine=ndb;
+show tables;
+create database test2;
+use test2;
+show tables;
+--error 1146
+select * from t1;
+create table t2 (b int,c longblob) engine=ndb;
+use test;
+select * from t1;
+show tables;
+drop table t1;
+use test2;
+drop table t2;
+drop database test2;
+use test;
+
+#########################################################
+# Bug#8035
+# mysqld would segfault on second select * before bug was fixed
+#
+--disable_warnings
+drop database if exists test_only_ndb_tables;
+--enable_warnings
+create database test_only_ndb_tables;
+use test_only_ndb_tables;
+create table t1 (a int primary key) engine=ndb;
+select * from t1;
+--exec $NDB_MGM --no-defaults -e "all restart -n" > /dev/null
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults --not-started > /dev/null
+--error 1015
+select * from t1;
+--exec $NDB_MGM --no-defaults -e "all start" > /dev/null
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults > /dev/null
+use test;
+drop database test_only_ndb_tables;
+
+#####################################################
+# Test that it's not possible to create tables
+# with same name as NDB internal tables
+# This will also test that it's not possible to create
+# a table with tha same name as a table that can't be
+# discovered( for example a table created via NDBAPI)
+
+# Test disabled since it doesn't work on case insensitive systems
+#--error 1050
+#CREATE TABLE sys.SYSTAB_0 (a int);
+#--error 1105
+#select * from sys.SYSTAB_0;
+
+#CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int);
+#show warnings;
+#--error 1105
+#select * from sys.SYSTAB_0;
+
+#--error 1051
+#drop table sys.SYSTAB_0;
+#drop table IF EXISTS sys.SYSTAB_0;
+
+######################################################
+# Note! This should always be the last step in this
+# file, the table t9 will be used and dropped
+# by ndb_autodiscover2
+#
+
+CREATE TABLE t9 (
+ a int NOT NULL PRIMARY KEY,
+ b int
+) engine=ndb;
+
+insert t9 values(1, 2), (2,3), (3, 4), (4, 5);
+
+#Don't drop the table, instead remove the frm file
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t9.frm
+
+# Now leave test case, when ndb_autodiscover2 will run, this
+# MySQL Server will have been restarted because it has a
+# ndb_autodiscover2-master.opt file.
+
+create table t10 (
+ a int not null primary key,
+ b blob
+) engine=ndb;
+
+insert into t10 values (1, 'kalle');
+
+--exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB | while read a b c d e f g; do echo $g; done` >> $NDB_TOOLS_OUTPUT 2>&1 || true
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt b/mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt
new file mode 100644
index 00000000000..e0d075c3fbd
--- /dev/null
+++ b/mysql-test/suite/ndb_team/t/ndb_autodiscover2-master.opt
@@ -0,0 +1 @@
+--skip-external-locking
diff --git a/mysql-test/suite/ndb_team/t/ndb_autodiscover2.test b/mysql-test/suite/ndb_team/t/ndb_autodiscover2.test
new file mode 100644
index 00000000000..ebe14696cd2
--- /dev/null
+++ b/mysql-test/suite/ndb_team/t/ndb_autodiscover2.test
@@ -0,0 +1,21 @@
+-- source include/have_ndb.inc
+-- source include/not_embedded.inc
+
+#
+# Simple test to show use of discover when the server has been restarted
+# The previous step has simply removed the frm file
+# from disk, but left the table in NDB
+#
+--sleep 3
+select * from t9 order by a;
+
+# handler_discover should be 1
+show status like 'handler_discover%';
+
+drop table t9;
+
+--error 1296
+select * from t10;
+drop table t10;
+
+# End of 4.1 tests
diff --git a/mysql-test/suite/ndb_team/t/ndb_autodiscover3.test b/mysql-test/suite/ndb_team/t/ndb_autodiscover3.test
new file mode 100644
index 00000000000..10416aee11f
--- /dev/null
+++ b/mysql-test/suite/ndb_team/t/ndb_autodiscover3.test
@@ -0,0 +1,104 @@
+-- source include/have_multi_ndb.inc
+-- source include/ndb_default_cluster.inc
+-- source include/not_embedded.inc
+
+# see bug#21563
+-- source include/have_binlog_format_mixed_or_row.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,);
+connect (con2,127.0.0.1,root,,test,$MASTER_MYPORT1,);
+
+# Workaround for Bug#27644
+# ndb: connecting api node/mysqld may "steal" node_id from running mysqld
+# - let ndb_waiter use a fixed node id so "steal" cannot happen
+--let connect_str = "nodeid=6;$NDB_CONNECTSTRING"
+
+#
+# Transaction ongoing while cluster is restarted
+#
+--connection server1
+create table t1 (a int key) engine=ndbcluster;
+
+begin;
+insert into t1 values (1);
+
+--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
+# Wait for mysqld to reconnect and exit from readonly mode
+--disable_query_log
+--connection con1
+--source include/ndb_not_readonly.inc
+--connection con2
+--source include/ndb_not_readonly.inc
+--enable_query_log
+
+--connection server1
+--error 1297
+insert into t1 values (2);
+--error 1296
+commit;
+
+drop table t1;
+
+#
+# Stale cache after restart -i
+#
+--connection server1
+create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster;
+insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1);
+select * from t2 order by a limit 3;
+
+--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
+# to ensure mysqld has connected again, and recreated system tables
+--disable_query_log
+--connection con1
+--source include/ndb_not_readonly.inc
+--connection con2
+--source include/ndb_not_readonly.inc
+--enable_query_log
+
+--connection server2
+--error ER_NO_SUCH_TABLE
+select * from t2;
+show tables like 't2';
+reset master;
+create table t2 (a int key) engine=ndbcluster;
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+select * from t2 order by a limit 3;
+
+# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried
+--connection server1
+select * from t2 order by a limit 3;
+reset master;
+
+--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
+--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
+# to ensure mysqld has connected again, and recreated system tables
+--disable_query_log
+--connection con1
+--source include/ndb_not_readonly.inc
+--connection con2
+--source include/ndb_not_readonly.inc
+--enable_query_log
+
+--connection server1
+--error ER_NO_SUCH_TABLE
+select * from t2;
+show tables like 't2';
+reset master;
+create table t2 (a int key) engine=ndbcluster;
+insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+select * from t2 order by a limit 3;
+
+# server 2 should have a stale cache, but with right frm, transaction need not be retried
+--connection server2
+select * from t2 order by a limit 3;
+reset master;
+
+drop table t2;
+# End of 4.1 tests