Below is the list of changes that have just been committed into a local
4.1 repository of lthalmann. When lthalmann does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2396 05/08/31 18:08:45 lars@stripped +3 -0
BUG#12542: All set statements should be executed by slave thd
rpl_replicate_do.result:
New test case
sql_parse.cc:
All SET statements should be executed by slave thd
rpl_replicate_do.test:
New test case
mysql-test/r/rpl_replicate_do.result
1.23 05/08/31 18:06:25 lthalmann@stripped +11 -0
New test case
sql/sql_parse.cc
1.462 05/08/31 18:05:33 lars@stripped +45 -28
All SET commands should be executed by slave thd
mysql-test/t/rpl_replicate_do.test
1.21 05/08/31 18:04:30 lthalmann@stripped +18 -0
Added testca[3~
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: lars
# Host: dl145h.mysql.com
# Root: /users/lthalmann/bk/mysql-4.1-bug12542
--- 1.461/sql/sql_parse.cc 2005-08-29 16:54:29 +02:00
+++ 1.462/sql/sql_parse.cc 2005-08-31 18:05:33 +02:00
@@ -120,6 +120,9 @@
#ifdef HAVE_REPLICATION
+/*
+ Returns true if all tables should be ignored
+*/
inline bool all_tables_not_ok(THD *thd, TABLE_LIST *tables)
{
return (table_rules_on && tables && !tables_ok(thd,tables) &&
@@ -1915,6 +1918,23 @@
return 0;
}
+static void reset_one_shot_variables(THD *thd)
+{
+ thd->variables.character_set_client=
+ global_system_variables.character_set_client;
+ thd->variables.collation_connection=
+ global_system_variables.collation_connection;
+ thd->variables.collation_database=
+ global_system_variables.collation_database;
+ thd->variables.collation_server=
+ global_system_variables.collation_server;
+ thd->update_charset();
+ thd->variables.time_zone=
+ global_system_variables.time_zone;
+ thd->one_shot_set= 0;
+}
+
+
/****************************************************************************
** mysql_execute_command
** Execute command saved in thd and current_lex->sql_command
@@ -1975,16 +1995,21 @@
/*
Skip if we are in the slave thread, some table rules have been
given and the table list says the query should not be replicated.
- Exception is DROP TEMPORARY TABLE IF EXISTS: we always execute it
- (otherwise we have stale files on slave caused by exclusion of one tmp
- table).
+
+ Exceptions are:
+ - SET: we always execute it (Not that many SET commands exists in
+ the binary log anyway)
+ - DROP TEMPORARY TABLE IF EXISTS: we always execute it (otherwise we
+ have stale files on slave caused by exclusion of one tmp table).
*/
- if (!(lex->sql_command == SQLCOM_DROP_TABLE &&
+ if (!(lex->sql_command == SQLCOM_SET_OPTION) &&
+ !(lex->sql_command == SQLCOM_DROP_TABLE &&
lex->drop_temporary && lex->drop_if_exists) &&
all_tables_not_ok(thd,tables))
{
/* we warn the slave SQL thread */
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ reset_one_shot_variables(thd);
DBUG_VOID_RETURN;
}
#ifndef TO_BE_DELETED
@@ -3309,6 +3334,7 @@
!db_ok_with_wild_table(lex->name)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ reset_one_shot_variables(thd);
break;
}
#endif
@@ -3344,6 +3370,7 @@
!db_ok_with_wild_table(lex->name)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ reset_one_shot_variables(thd);
break;
}
#endif
@@ -3384,6 +3411,7 @@
!db_ok_with_wild_table(db)))
{
my_error(ER_SLAVE_IGNORED_TABLE, MYF(0));
+ reset_one_shot_variables(thd);
break;
}
#endif
@@ -3718,30 +3746,19 @@
break;
}
thd->proc_info="query end"; // QQ
- if (thd->one_shot_set)
- {
- /*
- If this is a SET, do nothing. This is to allow mysqlbinlog to print
- many SET commands (in this case we want the charset temp setting to
- live until the real query). This is also needed so that SET
- CHARACTER_SET_CLIENT... does not cancel itself immediately.
- */
- if (lex->sql_command != SQLCOM_SET_OPTION)
- {
- thd->variables.character_set_client=
- global_system_variables.character_set_client;
- thd->variables.collation_connection=
- global_system_variables.collation_connection;
- thd->variables.collation_database=
- global_system_variables.collation_database;
- thd->variables.collation_server=
- global_system_variables.collation_server;
- thd->update_charset();
- thd->variables.time_zone=
- global_system_variables.time_zone;
- thd->one_shot_set= 0;
- }
- }
+
+ /*
+ Reset system variables temporarily modified by SET ONE SHOT.
+
+ Exception: If this is a SET, do nothing. This is to allow
+ mysqlbinlog to print many SET commands (in this case we want the
+ charset temp setting to live until the real query). This is also
+ needed so that SET CHARACTER_SET_CLIENT... does not cancel itself
+ immediately.
+ */
+ if (thd->one_shot_set && lex->sql_command != SQLCOM_SET_OPTION)
+ reset_one_shot_variables(thd);
+
if (res < 0)
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
--- 1.22/mysql-test/r/rpl_replicate_do.result 2004-06-09 16:06:56 +02:00
+++ 1.23/mysql-test/r/rpl_replicate_do.result 2005-08-31 18:06:25 +02:00
@@ -29,3 +29,14 @@
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1340 slave-relay-bin.000002 1384 master-bin.000001 Yes Yes test.t1 0 0 1340 1384 None 0 No #
+create table t1 (ts timestamp);
+set one_shot time_zone='met';
+insert into t1 values('2005-08-12 00:00:00');
+set one_shot time_zone='met';
+select * from t1;
+ts
+2005-08-12 00:00:00
+set one_shot time_zone='met';
+select * from t1;
+ts
+2005-08-12 00:00:00
--- 1.20/mysql-test/t/rpl_replicate_do.test 2005-07-28 02:21:48 +02:00
+++ 1.21/mysql-test/t/rpl_replicate_do.test 2005-08-31 18:04:30 +02:00
@@ -36,4 +36,22 @@
--replace_column 1 # 33 #
show slave status;
+#
+# BUG#12542
+# TEST: "SET ONE_SHOT should always be executed on slave"
+#
+# We could use any timezone different than server default in this test
+#
+connection master;
+create table t1 (ts timestamp);
+set one_shot time_zone='met';
+insert into t1 values('2005-08-12 00:00:00');
+set one_shot time_zone='met';
+select * from t1;
+sync_slave_with_master;
+
+connection slave;
+set one_shot time_zone='met';
+select * from t1;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (lars:1.2396) BUG#12542 | Lars Thalmann | 31 Aug |