@@ -1912,6 +1912,8 @@ bool show_master_info(THD* thd, Master_info* mi)
1912
1912
field_list.push_back (new Item_empty_string (" Slave_SQL_Running_State" , 20 ));
1913
1913
field_list.push_back (new Item_return_int (" Master_Retry_Count" , 10 ,
1914
1914
MYSQL_TYPE_LONGLONG));
1915
+ field_list.push_back (new Item_empty_string (" Master_Bind" ,
1916
+ sizeof (mi->bind_addr )));
1915
1917
1916
1918
if (protocol->send_result_set_metadata (&field_list,
1917
1919
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@@ -2100,6 +2102,8 @@ bool show_master_info(THD* thd, Master_info* mi)
2100
2102
protocol->store (slave_sql_running_state, &my_charset_bin);
2101
2103
// Master_Retry_Count
2102
2104
protocol->store ((ulonglong) mi->retry_count );
2105
+ // Master_Bind
2106
+ protocol->store (mi->bind_addr , &my_charset_bin);
2103
2107
2104
2108
mysql_mutex_unlock (&mi->rli ->err_lock );
2105
2109
mysql_mutex_unlock (&mi->err_lock );
@@ -4462,6 +4466,12 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
4462
4466
mysql_options (mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
4463
4467
mysql_options (mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
4464
4468
4469
+ if (mi->bind_addr [0 ])
4470
+ {
4471
+ DBUG_PRINT (" info" ,(" bind_addr: %s" , mi->bind_addr ));
4472
+ mysql_options (mysql, MYSQL_OPT_BIND, mi->bind_addr );
4473
+ }
4474
+
4465
4475
#ifdef HAVE_OPENSSL
4466
4476
if (mi->ssl )
4467
4477
{
@@ -4588,6 +4598,12 @@ MYSQL *rpl_connect_master(MYSQL *mysql)
4588
4598
mysql_options (mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
4589
4599
mysql_options (mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
4590
4600
4601
+ if (mi->bind_addr [0 ])
4602
+ {
4603
+ DBUG_PRINT (" info" ,(" bind_addr: %s" , mi->bind_addr ));
4604
+ mysql_options (mysql, MYSQL_OPT_BIND, mi->bind_addr );
4605
+ }
4606
+
4591
4607
#ifdef HAVE_OPENSSL
4592
4608
if (mi->ssl )
4593
4609
{
@@ -5521,7 +5537,7 @@ bool change_master(THD* thd, Master_info* mi)
5521
5537
bool need_relay_log_purge= 1 ;
5522
5538
char *var_master_log_name= NULL , *var_group_master_log_name= NULL ;
5523
5539
bool ret= FALSE ;
5524
- char saved_host[HOSTNAME_LENGTH + 1 ];
5540
+ char saved_host[HOSTNAME_LENGTH + 1 ], saved_bind_addr[HOSTNAME_LENGTH + 1 ] ;
5525
5541
uint saved_port= 0 ;
5526
5542
char saved_log_name[FN_REFLEN];
5527
5543
my_off_t saved_log_pos= 0 ;
@@ -5570,6 +5586,7 @@ bool change_master(THD* thd, Master_info* mi)
5570
5586
Before processing the command, save the previous state.
5571
5587
*/
5572
5588
strmake (saved_host, mi->host , HOSTNAME_LENGTH);
5589
+ strmake (saved_bind_addr, mi->bind_addr , HOSTNAME_LENGTH);
5573
5590
saved_port= mi->port ;
5574
5591
strmake (saved_log_name, mi->get_master_log_name (), FN_REFLEN - 1 );
5575
5592
saved_log_pos= mi->get_master_log_pos ();
@@ -5603,6 +5620,8 @@ bool change_master(THD* thd, Master_info* mi)
5603
5620
5604
5621
if (lex_mi->host )
5605
5622
strmake (mi->host , lex_mi->host , sizeof (mi->host )-1 );
5623
+ if (lex_mi->bind_addr )
5624
+ strmake (mi->bind_addr , lex_mi->bind_addr , sizeof (mi->bind_addr )-1 );
5606
5625
if (lex_mi->user )
5607
5626
strmake (mi->user , lex_mi->user , sizeof (mi->user )-1 );
5608
5627
if (lex_mi->password )
@@ -5785,11 +5804,12 @@ bool change_master(THD* thd, Master_info* mi)
5785
5804
5786
5805
sql_print_information (" 'CHANGE MASTER TO executed'. "
5787
5806
" Previous state master_host='%s', master_port='%u', master_log_file='%s', "
5788
- " master_log_pos='%ld'. "
5807
+ " master_log_pos='%ld', master_bind='%s' . "
5789
5808
" New state master_host='%s', master_port='%u', master_log_file='%s', "
5790
- " master_log_pos='%ld'." , saved_host, saved_port, saved_log_name,
5791
- (ulong) saved_log_pos, mi->host , mi->port , mi->get_master_log_name (),
5792
- (ulong) mi->get_master_log_pos ());
5809
+ " master_log_pos='%ld', master_bind='%s'." ,
5810
+ saved_host, saved_port, saved_log_name, (ulong) saved_log_pos,
5811
+ saved_bind_addr, mi->host , mi->port , mi->get_master_log_name (),
5812
+ (ulong) mi->get_master_log_pos (), mi->bind_addr );
5793
5813
5794
5814
/*
5795
5815
If we don't write new coordinates to disk now, then old will remain in
0 commit comments