From 329d1a7bf7881d906b8de97dbd14e86c4de7735c Mon Sep 17 00:00:00 2001 From: "hezx@mail.hezx.com" <> Date: Fri, 21 Dec 2007 11:02:48 +0800 Subject: [PATCH] BUG#28908 Replication: set global server_id is not setting the session server_id When set the server-id dynamically, the server_id member of current thread is not updated. Update the server_id member of current thread after updated the global variable value. --- mysql-test/r/rpl_server_id.result | 34 +++++++++++++++++++++++++++++++ mysql-test/t/rpl_server_id.test | 29 ++++++++++++++++++++++++++ sql/set_var.cc | 1 + 3 files changed, 64 insertions(+) create mode 100644 mysql-test/r/rpl_server_id.result create mode 100644 mysql-test/t/rpl_server_id.test diff --git a/mysql-test/r/rpl_server_id.result b/mysql-test/r/rpl_server_id.result new file mode 100644 index 00000000000..1e74394c122 --- /dev/null +++ b/mysql-test/r/rpl_server_id.result @@ -0,0 +1,34 @@ +set global server_id=1; +reset master; +drop table if exists t1,t2,t3; +create table t1 (a int); +select @@server_id; +@@server_id +1 +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3 +master-bin.000001 # Query 1 # use `test`; create table t1 (a int) +set global server_id=2; +create table t2 (b int); +select @@server_id; +@@server_id +2 +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3 +master-bin.000001 # Query 1 # use `test`; create table t1 (a int) +master-bin.000001 # Query 2 # use `test`; create table t2 (b int) +set global server_id=3; +create table t3 (c int); +select @@server_id; +@@server_id +3 +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query 1 # use `test`; drop table if exists t1,t2,t3 +master-bin.000001 # Query 1 # use `test`; create table t1 (a int) +master-bin.000001 # Query 2 # use `test`; create table t2 (b int) +master-bin.000001 # Query 3 # use `test`; create table t3 (c int) +set global server_id=1; +drop table t1,t2,t3; diff --git a/mysql-test/t/rpl_server_id.test b/mysql-test/t/rpl_server_id.test new file mode 100644 index 00000000000..6e98ec6ee6d --- /dev/null +++ b/mysql-test/t/rpl_server_id.test @@ -0,0 +1,29 @@ +# Test for BUG#28908 Replication: set global server_id is not setting the session server_id + +-- source include/have_log_bin.inc + +let $saved_server_id=`select @@server_id`; +set global server_id=1; +reset master; + +-- disable_warnings +drop table if exists t1,t2,t3; +-- enable_warnings + +create table t1 (a int); +select @@server_id; +source include/show_binlog_events2.inc; + +set global server_id=2; +create table t2 (b int); +select @@server_id; +source include/show_binlog_events2.inc; + +set global server_id=3; +create table t3 (c int); +select @@server_id; +source include/show_binlog_events2.inc; + +# cleanup +eval set global server_id=$saved_server_id; +drop table t1,t2,t3; diff --git a/sql/set_var.cc b/sql/set_var.cc index a128529fcc7..fac5a431176 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1441,6 +1441,7 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type) static void fix_server_id(THD *thd, enum_var_type type) { server_id_supplied = 1; + thd->server_id= server_id; }