List:Commits« Previous MessageNext Message »
From:Luis Soares Date:December 10 2010 3:01pm
Subject:bzr commit into mysql-trunk-bugfixing branch (luis.soares:3420)
View as plain text  
#At file:///home/lsoares/Workspace/bzr/work/bugfixing/37656/push/mysql-trunk-bugfixing/ based on revid:dmitry.shulga@stripped

 3420 Luis Soares	2010-12-10 [merge]
      Automerged bzr bundle from bug report into latest 
      mysql-trunk-bugfixing.

    added:
      mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test
      mysql-test/suite/rpl/r/rpl_lcase_tblnames_rewrite_db.result
      mysql-test/suite/rpl/r/rpl_row_lcase_tblnames.result
      mysql-test/suite/rpl/r/rpl_stm_lcase_tblnames.result
      mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db-slave.opt
      mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db.test
      mysql-test/suite/rpl/t/rpl_row_lcase_tblnames-slave.opt
      mysql-test/suite/rpl/t/rpl_row_lcase_tblnames.test
      mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames-slave.opt
      mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames.test
    modified:
      sql/log_event.cc
=== added file 'mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test'
--- a/mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_lower_case_table_names.test	2010-03-02 16:45:06 +0000
@@ -0,0 +1,144 @@
+# BUG#37656
+#
+#  This test aims at checking whether lower_case_table_names=1 option works
+#  for database names and table names.
+#
+#  This test checks the following (when lower_case_table_names=1 is set on slave):
+#    (i) creating a database on upper case on master results in lower case
+#        database name on slave
+#   (ii) creating tables with upper case names on master results in lower case
+#        table names on slave
+#  (iii) loading data infile into capitalized table name on master replicates to
+#        lower case table name on slave
+#   (iv) Propagating changes from upper case table names on into correspondent 
+#        lower case table names on slave works.
+
+
+# setup: create database and tables
+-- echo ******** [ MASTER ] ********
+-- let $dbname_upper= BUG_37656
+-- let $dbname_lower= `SELECT LOWER('$dbname_upper')`
+-- eval CREATE DATABASE $dbname_upper
+-- eval use $dbname_upper
+
+# assert: database names are in upper case in master and lower
+#         case in slave
+-- eval show databases like '$dbname_upper'
+sync_slave_with_master;
+-- echo ******** [ SLAVE ] ********
+--eval show databases like '$dbname_lower'
+
+-- connection master
+-- echo ******** [ MASTER ] ********
+CREATE TABLE T1 (a int);
+-- eval CREATE TABLE T2 (b int) ENGINE=$engine
+CREATE TABLE T3 (txt TEXT);
+
+# assert: that tables exist on master with upper case names
+show tables;
+
+# assert: that tables exist on slave but with lower case names
+-- sync_slave_with_master
+-- echo ******** [ SLAVE ] ********
+-- eval use $dbname_lower
+show tables;
+
+# action: lets create t1 for asserting below that t1 does not get changes
+#         from master (slave configured with --replicate-ignore-db=$dbname_lower.t1)
+CREATE TABLE t1 (a INT);
+
+# action: fill data into tables
+-- connection master
+-- echo ******** [ MASTER ] ********
+-- eval use $dbname_upper
+INSERT INTO T1 VALUES (1);
+INSERT INTO T2 VALUES (1);
+if (`SELECT @@session.binlog_format != 'ROW'`)
+{
+  -- eval LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE $dbname_upper.T3
+}
+
+if  (`SELECT @@session.binlog_format = 'ROW'`)
+{
+  use test;
+  -- eval INSERT INTO $dbname_upper.T1 VALUES (2)
+  -- eval INSERT INTO $dbname_upper.T2 VALUES (2)
+  -- eval LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE $dbname_upper.T3
+}
+# assert: lower case tables on lower case database on slave
+#         get updates from upper case tables on upper case
+#         database on master
+-- sync_slave_with_master
+-- echo ******** [ SLAVE ] ********
+
+# assert: changes for slave's t1 were filterd out
+if (`SELECT count(*) != 0 FROM t1`)
+{
+  -- echo UNEXPECTED DATA on $dbname_lower.t1 as table is filtered by replicate-ignore-table rules
+}
+
+-- let $diff_table_1=master:$dbname_upper.T2
+-- let $diff_table_2=slave:$dbname_lower.t2
+-- source include/diff_tables.inc
+
+-- let $diff_table_1=master:$dbname_upper.T3
+-- let $diff_table_2=slave:$dbname_lower.t3
+-- source include/diff_tables.inc
+
+# clean up
+-- connection master
+-- echo ******** [ MASTER ] ********
+-- eval DROP DATABASE $dbname_upper
+-- sync_slave_with_master
+
+
+# 
+# BUG#50653: drop procedure implicitely treats db name in a case sensitive way
+#
+
+-- source include/master-slave-reset.inc
+-- connection master
+
+-- let $dbname= B50653
+-- let $procname= b50653_proc
+
+-- eval CREATE DATABASE $dbname
+-- eval USE $dbname
+-- eval CREATE PROCEDURE $procname() BEGIN SELECT 1; END
+
+if (`SELECT count(*) = 1 FROM mysql.proc WHERE name like '$dbname'`)
+{
+  -- die Procedure not created on MASTER
+}
+
+-- sync_slave_with_master
+if (`SELECT count(*) = 1 FROM mysql.proc WHERE name like '$dbname'`)
+{
+  -- die Procedure not created on SLAVE
+}
+
+-- connection master
+-- eval DROP PROCEDURE $procname
+
+if (`SELECT count(*) FROM mysql.proc WHERE name like '$dbname'`)
+{
+  -- die Procedure not dropped on MASTER
+}
+
+-- sync_slave_with_master
+if (`SELECT count(*) FROM mysql.proc WHERE name like '$dbname'`)
+{
+  -- die Procedure not dropped on SLAVE
+}
+
+-- let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1)
+if ($last_error)
+{
+  -- die UNEXPECTED SLAVE SQL error: $last_error
+}
+
+-- connection master
+-- eval DROP DATABASE $dbname
+-- sync_slave_with_master
+
+-- source include/master-slave-end.inc

=== added file 'mysql-test/suite/rpl/r/rpl_lcase_tblnames_rewrite_db.result'
--- a/mysql-test/suite/rpl/r/rpl_lcase_tblnames_rewrite_db.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_lcase_tblnames_rewrite_db.result	2010-03-02 16:45:06 +0000
@@ -0,0 +1,36 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+SET SQL_LOG_BIN=0;
+CREATE DATABASE B37656;
+SET SQL_LOG_BIN=1;
+CREATE DATABASE BUG37656;
+### action: show that database on slave is created in lowercase
+SHOW DATABASES LIKE '%37656';
+Database (%37656)
+bug37656
+USE B37656;
+CREATE TABLE T1 (a int);
+INSERT INTO T1 VALUES (1);
+### assertion: master contains capitalized case table
+SHOW TABLES;
+Tables_in_B37656
+T1
+use bug37656;
+### assertion: slave contains lowered case table
+SHOW TABLES;
+Tables_in_bug37656
+t1
+### assertion: master and slave tables do not differ
+Comparing tables master:B37656.T1 and slave:bug37656.t1
+SET SQL_LOG_BIN=0;
+DROP DATABASE B37656;
+SET SQL_LOG_BIN=1;
+SHOW DATABASES LIKE '%37656';
+Database (%37656)
+DROP DATABASE BUG37656;
+SHOW DATABASES LIKE '%37656';
+Database (%37656)

=== added file 'mysql-test/suite/rpl/r/rpl_row_lcase_tblnames.result'
--- a/mysql-test/suite/rpl/r/rpl_row_lcase_tblnames.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_lcase_tblnames.result	2010-03-02 16:45:06 +0000
@@ -0,0 +1,56 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+******** [ MASTER ] ********
+CREATE DATABASE BUG_37656;
+use BUG_37656;
+show databases like 'BUG_37656';
+Database (BUG_37656)
+BUG_37656
+******** [ SLAVE ] ********
+show databases like 'bug_37656';
+Database (bug_37656)
+bug_37656
+******** [ MASTER ] ********
+CREATE TABLE T1 (a int);
+CREATE TABLE T2 (b int) ENGINE=InnoDB;
+CREATE TABLE T3 (txt TEXT);
+show tables;
+Tables_in_BUG_37656
+T1
+T2
+T3
+******** [ SLAVE ] ********
+use bug_37656;
+show tables;
+Tables_in_bug_37656
+t2
+t3
+CREATE TABLE t1 (a INT);
+******** [ MASTER ] ********
+use BUG_37656;
+INSERT INTO T1 VALUES (1);
+INSERT INTO T2 VALUES (1);
+use test;
+INSERT INTO BUG_37656.T1 VALUES (2);
+INSERT INTO BUG_37656.T2 VALUES (2);
+LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE BUG_37656.T3;
+******** [ SLAVE ] ********
+Comparing tables master:BUG_37656.T2 and slave:bug_37656.t2
+Comparing tables master:BUG_37656.T3 and slave:bug_37656.t3
+******** [ MASTER ] ********
+DROP DATABASE BUG_37656;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE DATABASE B50653;
+USE B50653;
+CREATE PROCEDURE b50653_proc() BEGIN SELECT 1; END;
+DROP PROCEDURE b50653_proc;
+DROP DATABASE B50653;

=== added file 'mysql-test/suite/rpl/r/rpl_stm_lcase_tblnames.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_lcase_tblnames.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_lcase_tblnames.result	2010-03-02 16:45:06 +0000
@@ -0,0 +1,53 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+******** [ MASTER ] ********
+CREATE DATABASE BUG_37656;
+use BUG_37656;
+show databases like 'BUG_37656';
+Database (BUG_37656)
+BUG_37656
+******** [ SLAVE ] ********
+show databases like 'bug_37656';
+Database (bug_37656)
+bug_37656
+******** [ MASTER ] ********
+CREATE TABLE T1 (a int);
+CREATE TABLE T2 (b int) ENGINE=InnoDB;
+CREATE TABLE T3 (txt TEXT);
+show tables;
+Tables_in_BUG_37656
+T1
+T2
+T3
+******** [ SLAVE ] ********
+use bug_37656;
+show tables;
+Tables_in_bug_37656
+t2
+t3
+CREATE TABLE t1 (a INT);
+******** [ MASTER ] ********
+use BUG_37656;
+INSERT INTO T1 VALUES (1);
+INSERT INTO T2 VALUES (1);
+LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE BUG_37656.T3;
+******** [ SLAVE ] ********
+Comparing tables master:BUG_37656.T2 and slave:bug_37656.t2
+Comparing tables master:BUG_37656.T3 and slave:bug_37656.t3
+******** [ MASTER ] ********
+DROP DATABASE BUG_37656;
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE DATABASE B50653;
+USE B50653;
+CREATE PROCEDURE b50653_proc() BEGIN SELECT 1; END;
+DROP PROCEDURE b50653_proc;
+DROP DATABASE B50653;

=== added file 'mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db-slave.opt	2010-03-02 16:45:06 +0000
@@ -0,0 +1 @@
+--lower-case-table-names=1 "--replicate-rewrite-db=b37656->bug37656"

=== added file 'mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db.test'
--- a/mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_lcase_tblnames_rewrite_db.test	2010-03-02 16:45:06 +0000
@@ -0,0 +1,60 @@
+# BUG#37656
+#
+# DESCRIPTION
+#
+#
+#  This test case is tests whether replication works properly when
+#  slave is configured with --lower-case-table-names=1 and replication
+#  rewrite rules are in effect.
+#
+#  It checks four issues:
+# 
+#   (i) master contains capitalized table name
+#
+#  (ii) slave contains lowered case table name
+#
+# (iii) master and slave tables do not differ
+#
+-- source include/master-slave.inc
+-- source include/not_windows.inc
+
+SET SQL_LOG_BIN=0;
+CREATE DATABASE B37656;
+SET SQL_LOG_BIN=1;
+
+-- connection slave
+CREATE DATABASE BUG37656;
+
+-- echo ### action: show that database on slave is created in lowercase
+SHOW DATABASES LIKE '%37656';
+
+-- connection master
+USE B37656;
+CREATE TABLE T1 (a int);
+INSERT INTO T1 VALUES (1);
+
+-- echo ### assertion: master contains capitalized case table
+SHOW TABLES;
+
+-- sync_slave_with_master
+
+use bug37656;
+
+-- echo ### assertion: slave contains lowered case table
+SHOW TABLES;
+
+-- echo ### assertion: master and slave tables do not differ
+let $diff_table_1=master:B37656.T1;
+let $diff_table_2=slave:bug37656.t1;
+
+-- source include/diff_tables.inc
+
+-- connection master
+SET SQL_LOG_BIN=0;
+DROP DATABASE B37656;
+SET SQL_LOG_BIN=1;
+SHOW DATABASES LIKE '%37656';
+
+-- connection slave
+DROP DATABASE BUG37656;
+SHOW DATABASES LIKE '%37656';

=== added file 'mysql-test/suite/rpl/t/rpl_row_lcase_tblnames-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_row_lcase_tblnames-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_lcase_tblnames-slave.opt	2010-03-02 16:45:06 +0000
@@ -0,0 +1 @@
+--replicate-do-db=bug_37656 --replicate-ignore-table=bug_37656.t1 --replicate-do-table=bug_37656.t2 --replicate-do-table=bug_37656.t3 --lower-case-table-names=1

=== added file 'mysql-test/suite/rpl/t/rpl_row_lcase_tblnames.test'
--- a/mysql-test/suite/rpl/t/rpl_row_lcase_tblnames.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_lcase_tblnames.test	2010-03-02 16:45:06 +0000
@@ -0,0 +1,12 @@
+# BUG#37656
+#  
+#  For details look into extra/rpl_tests/rpl_lower_case_table_names.test
+# 
+
+-- source include/master-slave.inc
+-- source include/have_innodb.inc
+-- source include/not_windows.inc
+-- source include/have_binlog_format_row.inc
+
+-- let $engine=InnoDB
+-- source extra/rpl_tests/rpl_lower_case_table_names.test

=== added file 'mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames-slave.opt	2010-03-02 16:45:06 +0000
@@ -0,0 +1 @@
+--replicate-do-db=bug_37656 --replicate-ignore-table=bug_37656.t1 --replicate-do-table=bug_37656.t2 --replicate-do-table=bug_37656.t3 --lower-case-table-names=1

=== added file 'mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_lcase_tblnames.test	2010-03-02 16:45:06 +0000
@@ -0,0 +1,12 @@
+# BUG#37656
+#  
+#  For details look into extra/rpl_tests/rpl_lower_case_table_names.test
+# 
+
+-- source include/master-slave.inc
+-- source include/have_innodb.inc
+-- source include/not_windows.inc
+-- source include/have_binlog_format_mixed_or_statement.inc
+
+-- let $engine=InnoDB
+-- source extra/rpl_tests/rpl_lower_case_table_names.test

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-12-05 22:51:49 +0000
+++ b/sql/log_event.cc	2010-12-09 15:05:09 +0000
@@ -239,6 +239,26 @@ static void inline slave_rows_error_repo
                 type, table->s->db.str, table->s->table_name.str,
                 buff, log_name, pos);
 }
+
+static void set_thd_db(THD *thd, const char *db, uint32 db_len)
+{
+  char lcase_db_buf[NAME_LEN +1]; 
+  LEX_STRING new_db;
+  new_db.length= db_len;
+  if (lower_case_table_names == 1)
+  {
+    strmov(lcase_db_buf, db); 
+    my_casedn_str(system_charset_info, lcase_db_buf);
+    new_db.str= lcase_db_buf;
+  }
+  else 
+    new_db.str= (char*) db;
+
+  new_db.str= (char*) rpl_filter->get_rewrite_db(new_db.str,
+                                                 &new_db.length);
+  thd->set_db(new_db.str, new_db.length);
+}
+
 #endif
 
 
@@ -3399,7 +3419,6 @@ int Query_log_event::do_apply_event(Rela
 int Query_log_event::do_apply_event(Relay_log_info const *rli,
                                       const char *query_arg, uint32 q_len_arg)
 {
-  LEX_STRING new_db;
   int expected_error,actual_error= 0;
   HA_CREATE_INFO db_options;
 
@@ -3411,9 +3430,7 @@ int Query_log_event::do_apply_event(Rela
     you.
   */
   thd->catalog= catalog_len ? (char *) catalog : (char *)"";
-  new_db.length= db_len;
-  new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
-  thd->set_db(new_db.str, new_db.length);       /* allocates a copy of 'db' */
+  set_thd_db(thd, db, db_len);
 
   /*
     Setting the character set and collation of the current database thd->db.
@@ -5137,12 +5154,9 @@ void Load_log_event::set_fields(const ch
 int Load_log_event::do_apply_event(NET* net, Relay_log_info const *rli,
                                    bool use_rli_only_for_errors)
 {
-  LEX_STRING new_db;
-  new_db.length= db_len;
-  new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
-  thd->set_db(new_db.str, new_db.length);
   DBUG_ASSERT(thd->query() == 0);
   thd->reset_query_inner();                    // Should not be needed
+  set_thd_db(thd, db, db_len);
   thd->is_slave_error= 0;
   clear_all_errors(thd, const_cast<Relay_log_info*>(rli));
 
@@ -5196,10 +5210,14 @@ int Load_log_event::do_apply_event(NET*
     thd->warning_info->opt_clear_warning_info(thd->query_id);
 
     TABLE_LIST tables;
+    char table_buf[NAME_LEN + 1];
+    strmov(table_buf, table_name);
+    if (lower_case_table_names == 1)
+      my_casedn_str(system_charset_info, table_buf);
     tables.init_one_table(thd->strmake(thd->db, thd->db_length),
                           thd->db_length,
-                          table_name, strlen(table_name),
-                          table_name, TL_WRITE);
+                          table_buf, strlen(table_buf),
+                          table_buf, TL_WRITE);
     tables.updating= 1;
 
     // the table will be opened in mysql_load    
@@ -8702,7 +8720,7 @@ Table_map_log_event::~Table_map_log_even
 int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
 {
   RPL_TABLE_LIST *table_list;
-  char *db_mem, *tname_mem;
+  char *db_mem, *tname_mem, *ptr;
   size_t dummy_len;
   void *memory;
   DBUG_ENTER("Table_map_log_event::do_apply_event(Relay_log_info*)");
@@ -8718,9 +8736,19 @@ int Table_map_log_event::do_apply_event(
                                 NullS)))
     DBUG_RETURN(HA_ERR_OUT_OF_MEM);
 
-  strmov(db_mem, rpl_filter->get_rewrite_db(m_dbnam, &dummy_len));
+  strmov(db_mem, m_dbnam);
   strmov(tname_mem, m_tblnam);
 
+  if (lower_case_table_names == 1)
+  {
+    my_casedn_str(system_charset_info, db_mem);
+    my_casedn_str(system_charset_info, tname_mem);
+  }
+
+  /* rewrite rules changed the database */
+  if (((ptr= (char*) rpl_filter->get_rewrite_db(db_mem, &dummy_len)) != db_mem))
+    strmov(db_mem, ptr);
+
   table_list->init_one_table(db_mem, strlen(db_mem),
                              tname_mem, strlen(tname_mem),
                              tname_mem, TL_WRITE);

No bundle (reason: revision is a merge (you can force generation of a bundle with env var BZR_FORCE_BUNDLE=1)).
Thread
bzr commit into mysql-trunk-bugfixing branch (luis.soares:3420) Luis Soares10 Dec