#At file:///home/marty/MySQL/mysql-5.1-telco-6.2/
2997 Martin Skold 2009-09-17
bug#42614 Mysql auto locate databases can overwrite frm data: checking for local tables in ndbcluster_discover, added test case
modified:
mysql-test/suite/ndb/r/ndb_multi.result
mysql-test/suite/ndb/t/ndb_multi.test
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_binlog.h
=== modified file 'mysql-test/suite/ndb/r/ndb_multi.result'
--- a/mysql-test/suite/ndb/r/ndb_multi.result 2007-11-12 10:42:37 +0000
+++ b/mysql-test/suite/ndb/r/ndb_multi.result 2009-09-17 13:53:38 +0000
@@ -143,3 +143,39 @@ show tables like '%$%';
Tables_in_test (%$%)
show tables like '%$%';
Tables_in_test (%$%)
+create table t1(s char(1)) engine = myisam;
+insert into t1 values ("a"),("b"),("c");
+create table t1(s char(1)) engine = ndb;
+insert into t1 values ("d"),("e"),("f");
+Restarting mysqld
+use test;
+select * from t1 order by s;
+s
+a
+b
+c
+select * from t1 order by s;
+s
+d
+e
+f
+drop table t1;
+select * from t1 order by s;
+s
+a
+b
+c
+create table t1(s char(1)) engine = ndb;
+insert into t1 values ("g"),("h"),("i");
+show tables;
+Tables_in_test
+t1
+Warnings:
+Warning 1050 Local table test.t1 shadows ndb table
+select * from t1 order by s;
+s
+a
+b
+c
+drop table t1;
+drop table t1;
=== modified file 'mysql-test/suite/ndb/t/ndb_multi.test'
--- a/mysql-test/suite/ndb/t/ndb_multi.test 2007-11-12 10:42:37 +0000
+++ b/mysql-test/suite/ndb/t/ndb_multi.test 2009-09-17 13:53:38 +0000
@@ -152,3 +152,39 @@ show tables like '%$%';
connection server1;
show tables like '%$%';
+
+#
+# Bug #42614 Mysql auto locate databases can overwrite frm data.
+#
+connection server1;
+create table t1(s char(1)) engine = myisam;
+insert into t1 values ("a"),("b"),("c");
+connection server2;
+create table t1(s char(1)) engine = ndb;
+insert into t1 values ("d"),("e"),("f");
+connection server1;
+## Restart mysqld nodes
+--echo Restarting mysqld
+let $mysqld_name=mysqld.1.1;
+--source include/restart_mysqld.inc
+use test;
+select * from t1 order by s;
+connection server2;
+select * from t1 order by s;
+drop table t1;
+connection server1;
+select * from t1 order by s;
+connection server2;
+create table t1(s char(1)) engine = ndb;
+insert into t1 values ("g"),("h"),("i");
+connection server1;
+show tables;
+select * from t1 order by s;
+
+#
+# Clean-up
+#
+connection server1;
+drop table t1;
+connection server2;
+drop table t1;
\ No newline at end of file
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-09-15 12:26:48 +0000
+++ b/sql/ha_ndbcluster.cc 2009-09-17 13:53:38 +0000
@@ -7063,7 +7063,17 @@ int ndbcluster_discover(handlerton *hton
goto err;
}
}
-
+#ifdef HAVE_NDB_BINLOG
+ if (ndbcluster_check_if_local_table(db, name))
+ {
+ DBUG_PRINT("info", ("ndbcluster_discover: Skipping locally defined table '%s.%s'",
+ db, name));
+ sql_print_error("ndbcluster_discover: Skipping locally defined table '%s.%s'",
+ db, name);
+ error= 1;
+ goto err;
+ }
+#endif
*frmlen= len;
*frmblob= data;
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2009-09-11 10:34:36 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2009-09-17 13:53:38 +0000
@@ -150,12 +150,6 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema
static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
bool have_lock);
-/*
- Helper functions
-*/
-static bool ndbcluster_check_if_local_table(const char *dbname, const char *tabname);
-static bool ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname);
-
#ifndef DBUG_OFF
/* purecov: begin deadcode */
static void print_records(TABLE *table, const uchar *record)
@@ -3282,7 +3276,7 @@ void set_binlog_flags(NDB_SHARE *share)
set_binlog_full(share);
}
-static bool
+bool
ndbcluster_check_if_local_table(const char *dbname, const char *tabname)
{
char key[FN_REFLEN + 1];
@@ -3304,7 +3298,7 @@ ndbcluster_check_if_local_table(const ch
DBUG_RETURN(false);
}
-static bool
+bool
ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname)
{
DBUG_ENTER("ndbcluster_check_if_local_tables_in_db");
=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h 2009-05-26 18:53:34 +0000
+++ b/sql/ha_ndbcluster_binlog.h 2009-09-17 13:53:38 +0000
@@ -274,6 +274,14 @@ inline void free_share(NDB_SHARE **share
void set_binlog_flags(NDB_SHARE *share);
+/*
+ Helper functions
+*/
+bool
+ndbcluster_check_if_local_table(const char *dbname, const char *tabname);
+bool
+ndbcluster_check_if_local_tables_in_db(THD *thd, const char *dbname);
+
inline
Thd_ndb *
get_thd_ndb(THD *thd)
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2997) Bug#42614 | Martin Skold | 17 Sep |