=== modified file 'sql/slave.cc' --- sql/slave.cc 2012-06-13 11:10:54 +0000 +++ sql/slave.cc 2013-01-12 10:43:28 +0000 @@ -1292,12 +1292,14 @@ };); master_res= NULL; - if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) && + if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP(), @@global.server_id")) && (master_res= mysql_store_result(mysql)) && - (master_row= mysql_fetch_row(master_res))) + (master_row= mysql_fetch_row(master_res)) && + (strlen(master_row[1])) > 0) { mi->clock_diff_with_master= (long) (time((time_t*) 0) - strtoul(master_row[0], 0, 10)); + mi->master_id= strtoul(master_row[1], 0, 10); } else if (check_io_slave_killed(mi->io_thd, mi, NULL)) goto slave_killed_err; @@ -1307,6 +1309,12 @@ "Get master clock failed with error: %s", mysql_error(mysql)); goto network_err; } + else if ((strlen(master_row[1]) <= 0) && master_res) + { + mi->report(WARNING_LEVEL, ER_UNKNOWN_SYSTEM_VARIABLE, + "Unknown system variable 'SERVER_ID' on master, \ + maybe it is a *VERY OLD MASTER*."); + } else { mi->clock_diff_with_master= 0; /* The "most sensible" value */ @@ -1340,14 +1348,9 @@ DBUG_ASSERT(!debug_sync_set_action(current_thd, STRING_WITH_LEN(act))); };); - master_res= NULL; - master_row= NULL; - if (!mysql_real_query(mysql, - STRING_WITH_LEN("SHOW VARIABLES LIKE 'SERVER_ID'")) && - (master_res= mysql_store_result(mysql)) && - (master_row= mysql_fetch_row(master_res))) + if (mi->master_id > 0) { - if ((::server_id == (mi->master_id= strtoul(master_row[1], 0, 10))) && + if ((::server_id == mi->master_id) && !mi->rli.replicate_same_server_id) { errmsg= "The slave I/O thread stops because master and slave have equal \ @@ -1359,34 +1362,6 @@ goto err; } } - else if (mysql_errno(mysql)) - { - if (check_io_slave_killed(mi->io_thd, mi, NULL)) - goto slave_killed_err; - else if (is_network_error(mysql_errno(mysql))) - { - mi->report(WARNING_LEVEL, mysql_errno(mysql), - "Get master SERVER_ID failed with error: %s", mysql_error(mysql)); - goto network_err; - } - /* Fatal error */ - errmsg= "The slave I/O thread stops because a fatal error is encountered \ -when it try to get the value of SERVER_ID variable from master."; - err_code= mysql_errno(mysql); - sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql)); - goto err; - } - else if (!master_row && master_res) - { - mi->report(WARNING_LEVEL, ER_UNKNOWN_SYSTEM_VARIABLE, - "Unknown system variable 'SERVER_ID' on master, \ -maybe it is a *VERY OLD MASTER*."); - } - if (master_res) - { - mysql_free_result(master_res); - master_res= NULL; - } if (mi->master_id == 0 && mi->ignore_server_ids.elements > 0) { errmsg= "Slave configured with server id filtering could not detect the master server id.";