List:Commits« Previous MessageNext Message »
From:Martin Skold Date:August 7 2008 1:51pm
Subject:bzr commit into mysql-5.1-telco-6.3 branch (Martin.Skold:2650) Bug#36658
View as plain text  
#At file:///home/marty/MySQL/mysql-5.1-telco-6.3/

 2650 Martin Skold	2008-08-07 [merge]
      Merge
modified:
  mysql-test/suite/ndb/r/ndb_multi_row.result
  mysql-test/suite/ndb/r/ndb_trigger.result
  mysql-test/suite/ndb/t/ndb_trigger.test
  mysql-test/suite/ndb_binlog/r/ndb_binlog_ddl_multi.result
  mysql-test/suite/ndb_binlog/r/ndb_binlog_log_bin.result
  sql/ha_ndbcluster.cc
  sql/ha_ndbcluster_binlog.cc
  storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp
  storage/ndb/include/ndbapi/NdbOperation.hpp
  storage/ndb/include/ndbapi/NdbTransaction.hpp

=== modified file 'mysql-test/suite/ndb/r/ndb_multi_row.result'
--- a/mysql-test/suite/ndb/r/ndb_multi_row.result	2007-11-01 14:08:00 +0000
+++ b/mysql-test/suite/ndb/r/ndb_multi_row.result	2008-08-07 05:29:44 +0000
@@ -63,6 +63,6 @@ t4
 drop table t1, t2, t3, t4;
 drop table if exists t1, t3, t4;
 Warnings:
-Error	155	Table 'test.t1' doesn't exist
-Error	155	Table 'test.t3' doesn't exist
-Error	155	Table 'test.t4' doesn't exist
+Note	1051	Unknown table 't1'
+Note	1051	Unknown table 't3'
+Note	1051	Unknown table 't4'

=== modified file 'mysql-test/suite/ndb/r/ndb_trigger.result'
--- a/mysql-test/suite/ndb/r/ndb_trigger.result	2007-07-04 20:38:53 +0000
+++ b/mysql-test/suite/ndb/r/ndb_trigger.result	2008-08-07 05:29:44 +0000
@@ -1,4 +1,7 @@
 drop table if exists t1, t2, t3, t4, t5;
+flush status;
+drop table if exists t1, t2, t3, t4, t5;
+flush status;
 create table t1 (id int primary key, a int not null, b decimal (63,30) default 0)
engine=ndb;
 create table t2 (op char(1), a int not null, b decimal (63,30)) engine=ndb;
 create table t3  engine=ndb select 1 as i;
@@ -312,4 +315,29 @@ id	xy
 DROP TRIGGER t1_delete;
 DROP TRIGGER t4_delete;
 DROP TABLE t1, t2, t3, t4, t5;
+create table t1(a int, b varchar(10), c date) engine=ndb;
+CREATE TRIGGER trg1 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN
+SET new.c = date(now());
+End //
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+trigger_name	event_object_table
+trg1	t1
+CREATE TRIGGER trg1 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN
+SET new.c = date(now());
+End //
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+trigger_name	event_object_table
+trg1	t1
+rename table t1 to t2;
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+trigger_name	event_object_table
+trg1	t2
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+trigger_name	event_object_table
+trg1	t2
+drop table t2;
 End of 5.1 tests

=== modified file 'mysql-test/suite/ndb/t/ndb_trigger.test'
--- a/mysql-test/suite/ndb/t/ndb_trigger.test	2007-11-29 10:29:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_trigger.test	2008-08-07 11:51:34 +0000
@@ -1,5 +1,6 @@
 # Tests which involve triggers and NDB storage engine
---source include/have_ndb.inc
+--source include/have_multi_ndb.inc
+--source include/not_embedded.inc
 
 # 
 # Test for bug#18437 "Wrong values inserted with a before update
@@ -13,7 +14,12 @@
 #
 
 --disable_warnings
+connection server2;
 drop table if exists t1, t2, t3, t4, t5;
+flush status;
+connection server1;
+drop table if exists t1, t2, t3, t4, t5;
+flush status;
 --enable_warnings
 
 create table t1 (id int primary key, a int not null, b decimal (63,30) default 0)
engine=ndb;
@@ -217,4 +223,39 @@ DROP TRIGGER t1_delete;
 DROP TRIGGER t4_delete;
 DROP TABLE t1, t2, t3, t4, t5;
 
+# Test for bug#36658
+# Verify that rename table
+# doesn't remove triggers
+
+connection server1;
+create table t1(a int, b varchar(10), c date) engine=ndb;
+delimiter //;
+CREATE TRIGGER trg1 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN
+   SET new.c = date(now());
+End //
+delimiter ;//
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+
+connection server2;
+delimiter //;
+CREATE TRIGGER trg1 BEFORE UPDATE ON t1 FOR EACH ROW BEGIN
+   SET new.c = date(now());
+End //
+delimiter ;//
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+
+connection server1;
+rename table t1 to t2;
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+
+connection server2;
+select trigger_name,event_object_table from information_schema.triggers where
+trigger_name='trg1';
+
+connection server1;
+drop table t2;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_ddl_multi.result'
--- a/mysql-test/suite/ndb_binlog/r/ndb_binlog_ddl_multi.result	2008-02-25 13:50:20 +0000
+++ b/mysql-test/suite/ndb_binlog/r/ndb_binlog_ddl_multi.result	2008-08-07 05:29:44 +0000
@@ -33,11 +33,11 @@ drop table mysqltest.t1;
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	102	#	ALTER DATABASE mysqltest CHARACTER SET latin1
-master-bin.000001	#	Query	102	#	use `mysqltest`; drop table `t1`
+master-bin.000001	#	Query	102	#	use `mysqltest`; drop table `mysqltest`.`t1`
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	102	#	ALTER DATABASE mysqltest CHARACTER SET latin1
-master-bin.000001	#	Query	102	#	use `mysqltest`; drop table `t1`
+master-bin.000001	#	Query	102	#	use `mysqltest`; drop table `mysqltest`.`t1`
 reset master;
 reset master;
 use test;
@@ -161,10 +161,10 @@ Log_name	Pos	Event_type	Server_id	End_lo
 master-bin1.000001	#	Query	1	#	use `test`; create table t1 (a int key) engine=ndb
 master-bin1.000001	#	Query	1	#	use `test`; create table t2 (a int key) engine=ndb
 master-bin1.000001	#	Query	1	#	use `test`; create table t3 (a int key) engine=ndb
-master-bin1.000001	#	Query	1	#	use `test`; rename table `test.t3` to `test.t4`
-master-bin1.000001	#	Query	1	#	use `test`; rename table `test.t2` to `test.t3`
-master-bin1.000001	#	Query	1	#	use `test`; rename table `test.t1` to `test.t2`
-master-bin1.000001	#	Query	1	#	use `test`; rename table `test.t4` to `test.t1`
+master-bin1.000001	#	Query	1	#	use `test`; rename table `test`.`t3` to `test`.`t4`
+master-bin1.000001	#	Query	1	#	use `test`; rename table `test`.`t2` to `test`.`t3`
+master-bin1.000001	#	Query	1	#	use `test`; rename table `test`.`t1` to `test`.`t2`
+master-bin1.000001	#	Query	1	#	use `test`; rename table `test`.`t4` to `test`.`t1`
 drop table t1;
 drop table t2;
 drop table t3;
@@ -188,7 +188,7 @@ master-bin1.000001	#	Table_map	102	#	tab
 master-bin1.000001	#	Write_rows	102	#	table_id: #
 master-bin1.000001	#	Write_rows	102	#	table_id: # flags: STMT_END_F
 master-bin1.000001	#	Query	102	#	COMMIT
-master-bin1.000001	#	Query	1	#	use `test`; rename table `test.t1` to `test.t2`
+master-bin1.000001	#	Query	1	#	use `test`; rename table `test`.`t1` to `test`.`t2`
 master-bin1.000001	#	Query	102	#	BEGIN
 master-bin1.000001	#	Table_map	102	#	table_id: # (test.t2)
 master-bin1.000001	#	Table_map	102	#	table_id: # (mysql.ndb_apply_status)

=== modified file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_log_bin.result'
--- a/mysql-test/suite/ndb_binlog/r/ndb_binlog_log_bin.result	2008-06-19 07:18:42 +0000
+++ b/mysql-test/suite/ndb_binlog/r/ndb_binlog_log_bin.result	2008-08-07 05:29:44 +0000
@@ -53,8 +53,8 @@ use mysqltest;
 insert into t2 values (1,1);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin1.000001	#	Query	1	#	use `mysqltest`; drop table `t1`
-master-bin1.000001	#	Query	1	#	use `mysqltest`; drop table `t2`
+master-bin1.000001	#	Query	1	#	use `mysqltest`; drop table `mysqltest`.`t1`
+master-bin1.000001	#	Query	1	#	use `mysqltest`; drop table `mysqltest`.`t2`
 master-bin1.000001	#	Query	1	#	use `mysqltest`; create table t1 (d int key, e int)
engine=ndb
 master-bin1.000001	#	Query	1	#	use `mysqltest`; create table t2 (d int key, e int)
engine=ndb
 master-bin1.000001	#	Query	102	#	BEGIN

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2008-06-30 12:31:26 +0000
+++ b/sql/ha_ndbcluster.cc	2008-08-07 11:51:34 +0000
@@ -158,6 +158,7 @@ static uchar *ndbcluster_get_key(NDB_SHA
 static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*,
                                     const NdbRecord *, struct Ndb_statistics *);
 
+THD *injector_thd= 0;
 
 // Util thread variables
 pthread_t ndb_util_thread;
@@ -6860,6 +6861,17 @@ int ha_ndbcluster::rename_table(const ch
 
   DBUG_ENTER("ha_ndbcluster::rename_table");
   DBUG_PRINT("info", ("Renaming %s to %s", from, to));
+
+  if (thd == injector_thd)
+  {
+    /*
+      Table was renamed remotely is already
+      renamed inside ndb.
+      Just rename .ndb file.
+     */
+    DBUG_RETURN(handler::rename_table(from, to));
+  }
+
   set_dbname(from, old_dbname);
   set_dbname(to, new_dbname);
   set_tabname(from);
@@ -6930,7 +6942,7 @@ int ha_ndbcluster::rename_table(const ch
     }
     ERR_RETURN(ndb_error);
   }
-  
+
   // Rename .ndb file
   if ((result= handler::rename_table(from, to)))
   {
@@ -7228,6 +7240,17 @@ int ha_ndbcluster::delete_table(const ch
   int error= 0;
   DBUG_ENTER("ha_ndbcluster::delete_table");
   DBUG_PRINT("enter", ("name: %s", name));
+
+  if (thd == injector_thd)
+  {
+    /*
+      Table was dropped remotely is already
+      dropped inside ndb.
+      Just drop local files.
+     */
+    DBUG_RETURN(handler::delete_table(name));
+  }
+
   set_dbname(name);
   set_tabname(name);
 

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2008-06-18 13:49:43 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2008-08-07 11:51:34 +0000
@@ -71,7 +71,7 @@ my_bool ndb_binlog_is_ready= FALSE;
   Has one sole purpose, for setting the in_use table member variable
   in get_share(...)
 */
-THD *injector_thd= 0;
+extern THD * injector_thd; // Declared in ha_ndbcluster.cc
 
 /*
   Global reference to ndb injector thd object.
@@ -1307,8 +1307,9 @@ int ndbcluster_log_schema_op(THD *thd,
       DBUG_RETURN(0);
     /* redo the drop table query as is may contain several tables */
     query= tmp_buf2;
-    query_length= (uint) (strxmov(tmp_buf2, "drop table `",
-                                  table_name, "`", NullS) - tmp_buf2);
+    query_length= (uint) (strxmov(tmp_buf2, "drop table ",
+                                  "`", db, "`", ".",
+                                  "`", table_name, "`", NullS) - tmp_buf2);
     type_str= "drop table";
     break;
   case SOT_RENAME_TABLE_PREPARE:
@@ -1318,9 +1319,11 @@ int ndbcluster_log_schema_op(THD *thd,
   case SOT_RENAME_TABLE:
     /* redo the rename table query as is may contain several tables */
     query= tmp_buf2;
-    query_length= (uint) (strxmov(tmp_buf2, "rename table `",
-                                  db, ".", table_name, "` to `",
-                                  new_db, ".", new_table_name, "`", NullS) - tmp_buf2);
+    query_length= (uint) (strxmov(tmp_buf2, "rename table ",
+                                  "`", db, "`", ".",
+                                  "`", table_name, "` to ",
+                                  "`", new_db, "`", ".",
+                                  "`", new_table_name, "`", NullS) - tmp_buf2);
     type_str= "rename table";
     break;
   case SOT_CREATE_TABLE:
@@ -1863,17 +1866,53 @@ ndb_binlog_thread_handle_schema_event(TH
       if (schema->node_id != node_id)
       {
         int log_query= 0, post_epoch_unlock= 0;
+        char errmsg[MYSQL_ERRMSG_SIZE];
+
         switch (schema_type)
         {
-        case SOT_DROP_TABLE:
-          // fall through
         case SOT_RENAME_TABLE:
           // fall through
         case SOT_RENAME_TABLE_NEW:
-          post_epoch_log_list->push_back(schema, mem_root);
-          /* acknowledge this query _after_ epoch completion */
-          post_epoch_unlock= 1;
-          break;
+        {
+          uint end= snprintf(&errmsg[0], MYSQL_ERRMSG_SIZE,
+                             "NDB Binlog: Skipping renaming locally defined table '%s.%s'
from binlog schema event '%s' from node %d. ",
+                             schema->db, schema->name, schema->query,
+                             schema->node_id);
+          
+          errmsg[end]= '\0';
+        }
+        // fall through
+        case SOT_DROP_TABLE:
+          if (schema_type == SOT_DROP_TABLE)
+          {
+            uint end= snprintf(&errmsg[0], MYSQL_ERRMSG_SIZE,
+                               "NDB Binlog: Skipping dropping locally defined table
'%s.%s' from binlog schema event '%s' from node %d. ",
+                               schema->db, schema->name, schema->query,
+                               schema->node_id);
+            errmsg[end]= '\0';
+          }
+          if (! ndbcluster_check_if_local_table(schema->db, schema->name))
+          {
+            const int no_print_error[1]=
+              {ER_BAD_TABLE_ERROR}; /* ignore missing table */
+            run_query(thd, schema->query,
+                      schema->query + schema->query_length,
+                      no_print_error, //   /* don't print error */
+                      TRUE); //  /* don't binlog the query */
+
+            /* binlog dropping table after any table operations */
+            post_epoch_log_list->push_back(schema, mem_root);
+            /* acknowledge this query _after_ epoch completion */
+            post_epoch_unlock= 1;
+          }
+          else
+          {
+            /* Tables exists as a local table, leave it */
+            DBUG_PRINT("info", ((const char *) errmsg));
+            sql_print_error((const char *) errmsg);
+            log_query= 1;
+          }
+          // Fall through
 	case SOT_TRUNCATE_TABLE:
         {
           char key[FN_REFLEN];
@@ -1909,6 +1948,8 @@ ndb_binlog_thread_handle_schema_event(TH
             free_share(&share);
           }
         }
+        if (schema_type != SOT_TRUNCATE_TABLE)
+          break;
         // fall through
         case SOT_CREATE_TABLE:
           pthread_mutex_lock(&LOCK_open);

=== modified file 'storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp'
--- a/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp	2008-08-07 01:34:35 +0000
+++ b/storage/ndb/include/ndbapi/NdbIndexScanOperation.hpp	2008-08-07 06:24:52 +0000
@@ -307,16 +307,18 @@ private:
 inline
 int
 NdbIndexScanOperation::setBound(const char* attr, int type, const void* value,
-                                __attribute__((__unused__))Uint32 len)
+                                Uint32 len)
 {
+  (void)len;  // unused
   return setBound(attr, type, value);
 }
 
 inline
 int
 NdbIndexScanOperation::setBound(Uint32 anAttrId, int type, const void* value,
-                                __attribute__((__unused__))Uint32 len)
+                                Uint32 len)
 {
+  (void)len;  // unused
   return setBound(anAttrId, type, value);
 }
 

=== modified file 'storage/ndb/include/ndbapi/NdbOperation.hpp'
--- a/storage/ndb/include/ndbapi/NdbOperation.hpp	2008-08-07 01:36:57 +0000
+++ b/storage/ndb/include/ndbapi/NdbOperation.hpp	2008-08-07 11:51:34 +0000
@@ -1580,8 +1580,9 @@ NdbOperation::NdbCon(NdbTransaction* aNd
 inline
 int
 NdbOperation::equal(const char* anAttrName, const char* aValue,
-                    __attribute__((__unused__))Uint32 len)
+                    Uint32 len)
 {
+  (void)len;   // unused
   return equal(anAttrName, aValue);
 }
 
@@ -1616,8 +1617,9 @@ NdbOperation::equal(const char* anAttrNa
 inline
 int
 NdbOperation::equal(Uint32 anAttrId, const char* aValue,
-                    __attribute__((__unused__))Uint32 len)
+                    Uint32 len)
 {
+  (void)len;   // unused
   return equal(anAttrId, aValue);
 }
 
@@ -1652,8 +1654,9 @@ NdbOperation::equal(Uint32 anAttrId, Uin
 inline
 int
 NdbOperation::setValue(const char* anAttrName, const char* aValue,
-                       __attribute__((__unused__))Uint32 len)
+                       Uint32 len)
 {
+  (void)len;   // unused
   return setValue(anAttrName, aValue);
 }
 
@@ -1702,8 +1705,9 @@ NdbOperation::setValue(const char* anAtt
 inline
 int
 NdbOperation::setValue(Uint32 anAttrId, const char* aValue,
-                       __attribute__((__unused__))Uint32 len)
+                       Uint32 len)
 {
+  (void)len;   // unused
   return setValue(anAttrId, aValue);
 }
 

=== modified file 'storage/ndb/include/ndbapi/NdbTransaction.hpp'
--- a/storage/ndb/include/ndbapi/NdbTransaction.hpp	2008-08-07 01:34:35 +0000
+++ b/storage/ndb/include/ndbapi/NdbTransaction.hpp	2008-08-07 06:24:52 +0000
@@ -1091,8 +1091,9 @@ NdbTransaction::get_send_size()
 
 inline
 void
-NdbTransaction::set_send_size(__attribute__((__unused__))Uint32 send_size)
+NdbTransaction::set_send_size(Uint32 send_size)
 {
+  (void)send_size; //unused
   return;
 }
 

Thread
bzr commit into mysql-5.1-telco-6.3 branch (Martin.Skold:2650) Bug#36658Martin Skold7 Aug