Skip to content

Commit c10a1f0

Browse files
author
Tor Didriksen
committed
Merge next-mr => next-mr-merge
Text conflict in include/mysql.h Text conflict in include/mysql.h.pp Text conflict in mysql-test/t/mysqlcheck.test Text conflict in sql-common/client.c
2 parents ea2cf6b + 38a8522 commit c10a1f0

20 files changed

+209
-10
lines changed

client/mysql.cc

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static ulong opt_max_allowed_packet, opt_net_buffer_length;
148148
static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0;
149149
static uint my_end_arg;
150150
static char * opt_mysql_unix_port=0;
151+
static char *opt_bind_addr = NULL;
151152
static int connect_flag=CLIENT_INTERACTIVE;
152153
static char *current_host,*current_db,*current_user=0,*opt_password=0,
153154
*current_prompt=0, *delimiter_str= 0,
@@ -1373,6 +1374,9 @@ static struct my_option my_long_options[] =
13731374
{"batch", 'B',
13741375
"Don't use history file. Disable interactive behavior. (Enables --silent.)",
13751376
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1377+
{"bind-address", 0, "IP address to bind to.",
1378+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
1379+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
13761380
{"character-sets-dir", OPT_CHARSETS_DIR,
13771381
"Directory for character set files.", &charsets_dir,
13781382
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -4273,6 +4277,8 @@ sql_real_connect(char *host,char *database,char *user,char *password,
42734277
mysql_options(&mysql,MYSQL_OPT_CONNECT_TIMEOUT,
42744278
(char*) &timeout);
42754279
}
4280+
if (opt_bind_addr)
4281+
mysql_options(&mysql, MYSQL_OPT_BIND, opt_bind_addr);
42764282
if (opt_compress)
42774283
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
42784284
if (opt_secure_auth)

client/mysqladmin.cc

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static my_bool option_force=0,interrupted=0,new_line=0,
4242
static my_bool debug_info_flag= 0, debug_check_flag= 0;
4343
static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
4444
static uint opt_count_iterations= 0, my_end_arg;
45+
static char *opt_bind_addr = NULL;
4546
static ulong opt_connect_timeout, opt_shutdown_timeout;
4647
static char * unix_port=0;
4748

@@ -117,6 +118,9 @@ static TYPELIB command_typelib=
117118

118119
static struct my_option my_long_options[] =
119120
{
121+
{"bind-address", 0, "IP address to bind to.",
122+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
123+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
120124
{"count", 'c',
121125
"Number of iterations to make. This works with -i (--sleep) only.",
122126
&nr_iterations, &nr_iterations, 0, GET_UINT,
@@ -319,6 +323,8 @@ int main(int argc,char *argv[])
319323
(void) signal(SIGINT,endprog); /* Here if abort */
320324
(void) signal(SIGTERM,endprog); /* Here if abort */
321325

326+
if (opt_bind_addr)
327+
mysql_options(&mysql,MYSQL_OPT_BIND,opt_bind_addr);
322328
if (opt_compress)
323329
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
324330
if (opt_connect_timeout)

client/mysqlbinlog.cc

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static char *shared_memory_base_name= 0;
9090
#endif
9191
static char* user = 0;
9292
static char* pass = 0;
93+
static char *opt_bind_addr = NULL;
9394
static char *charset= 0;
9495

9596
static uint verbose= 0;
@@ -1025,6 +1026,9 @@ static struct my_option my_long_options[] =
10251026
"argument, 'always' is used.",
10261027
&opt_base64_output_mode_str, &opt_base64_output_mode_str,
10271028
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1029+
{"bind-address", 0, "IP address to bind to.",
1030+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
1031+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
10281032
/*
10291033
mysqlbinlog needs charsets knowledge, to be able to convert a charset
10301034
number found in binlog to a charset name (to be able to print things
@@ -1417,6 +1421,8 @@ static Exit_status safe_connect()
14171421

14181422
if (opt_protocol)
14191423
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);
1424+
if (opt_bind_addr)
1425+
mysql_options(mysql, MYSQL_OPT_BIND, opt_bind_addr);
14201426
#ifdef HAVE_SMEM
14211427
if (shared_memory_base_name)
14221428
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME,

client/mysqlcheck.c

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ DYNAMIC_ARRAY tables4repair;
4646
static char *shared_memory_base_name=0;
4747
#endif
4848
static uint opt_protocol=0;
49+
static char *opt_bind_addr = NULL;
4950

5051
enum operations { DO_CHECK=1, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE, DO_UPGRADE };
5152

@@ -65,6 +66,9 @@ static struct my_option my_long_options[] =
6566
"If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.",
6667
&opt_auto_repair, &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0,
6768
0, 0, 0, 0, 0},
69+
{"bind-address", 0, "IP address to bind to.",
70+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
71+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
6872
{"character-sets-dir", OPT_CHARSETS_DIR,
6973
"Directory for character set files.", &charsets_dir,
7074
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -792,6 +796,8 @@ static int dbConnect(char *host, char *user, char *passwd)
792796
#endif
793797
if (opt_protocol)
794798
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
799+
if (opt_bind_addr)
800+
mysql_options(&mysql_connection, MYSQL_OPT_BIND, opt_bind_addr);
795801
#ifdef HAVE_SMEM
796802
if (shared_memory_base_name)
797803
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqldump.c

+6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static uint opt_mysql_port= 0, opt_master_data;
127127
static uint opt_slave_data;
128128
static uint my_end_arg;
129129
static char * opt_mysql_unix_port=0;
130+
static char *opt_bind_addr = NULL;
130131
static int first_error=0;
131132
static DYNAMIC_STRING extended_row;
132133
#include <sslopt-vars.h>
@@ -216,6 +217,9 @@ static struct my_option my_long_options[] =
216217
"Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.",
217218
&opt_slave_apply, &opt_slave_apply, 0, GET_BOOL, NO_ARG,
218219
0, 0, 0, 0, 0, 0},
220+
{"bind-address", 0, "IP address to bind to.",
221+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
222+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
219223
{"character-sets-dir", OPT_CHARSETS_DIR,
220224
"Directory for character set files.", &charsets_dir,
221225
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -1450,6 +1454,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
14501454
#endif
14511455
if (opt_protocol)
14521456
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
1457+
if (opt_bind_addr)
1458+
mysql_options(&mysql_connection,MYSQL_OPT_BIND,opt_bind_addr);
14531459
#ifdef HAVE_SMEM
14541460
if (shared_memory_base_name)
14551461
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqlimport.c

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static char *opt_password=0, *current_user=0,
5959
*escaped=0, *opt_columns=0,
6060
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
6161
static uint opt_mysql_port= 0, opt_protocol= 0;
62+
static char *opt_bind_addr = NULL;
6263
static char * opt_mysql_unix_port=0;
6364
static longlong opt_ignore_lines= -1;
6465
#include <sslopt-vars.h>
@@ -69,6 +70,9 @@ static char *shared_memory_base_name=0;
6970

7071
static struct my_option my_long_options[] =
7172
{
73+
{"bind-address", 0, "IP address to bind to.",
74+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
75+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
7276
{"character-sets-dir", OPT_CHARSETS_DIR,
7377
"Directory for character set files.", &charsets_dir,
7478
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -425,6 +429,8 @@ static MYSQL *db_connect(char *host, char *database,
425429
#endif
426430
if (opt_protocol)
427431
mysql_options(mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
432+
if (opt_bind_addr)
433+
mysql_options(mysql,MYSQL_OPT_BIND,opt_bind_addr);
428434
#ifdef HAVE_SMEM
429435
if (shared_memory_base_name)
430436
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);

client/mysqlshow.c

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
3939
static char *shared_memory_base_name=0;
4040
#endif
4141
static uint opt_protocol=0;
42+
static char *opt_bind_addr = NULL;
4243

4344
static void get_options(int *argc,char ***argv);
4445
static uint opt_mysql_port=0;
@@ -118,6 +119,8 @@ int main(int argc, char **argv)
118119
#endif
119120
if (opt_protocol)
120121
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
122+
if (opt_bind_addr)
123+
mysql_options(&mysql,MYSQL_OPT_BIND,opt_bind_addr);
121124
#ifdef HAVE_SMEM
122125
if (shared_memory_base_name)
123126
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
@@ -161,6 +164,9 @@ int main(int argc, char **argv)
161164

162165
static struct my_option my_long_options[] =
163166
{
167+
{"bind-address", 0, "IP address to bind to.",
168+
(uchar**) &opt_bind_addr, (uchar**) &opt_bind_addr, 0, GET_STR,
169+
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
164170
{"character-sets-dir", 'c', "Directory for character set files.",
165171
&charsets_dir, &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0,
166172
0, 0, 0, 0, 0},

include/mysql.h

+16-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ enum mysql_option
167167
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
168168
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
169169
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
170-
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH
170+
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
171+
MYSQL_OPT_BIND
171172
};
172173

173174
/**
@@ -197,7 +198,20 @@ struct st_mysql_options {
197198
my_bool unused3;
198199
my_bool unused4;
199200
enum mysql_option methods_to_use;
200-
char *client_ip;
201+
union {
202+
/*
203+
The ip/hostname to use when authenticating
204+
client against embedded server built with
205+
grant tables - only used in embedded server
206+
*/
207+
char *client_ip;
208+
209+
/*
210+
The local address to bind when connecting to
211+
remote server - not used in embedded server
212+
*/
213+
char *bind_address;
214+
} ci;
201215
/* Refuse client connecting to server if it uses old (pre-4.1.1) protocol */
202216
my_bool secure_auth;
203217
/* 0 - never report, 1 - always report (default) */

include/mysql.h.pp

+6-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@
262262
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
263263
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
264264
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
265-
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH
265+
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
266+
MYSQL_OPT_BIND
266267
};
267268
struct st_mysql_options_extention;
268269
struct st_mysql_options {
@@ -286,7 +287,10 @@
286287
my_bool unused3;
287288
my_bool unused4;
288289
enum mysql_option methods_to_use;
289-
char *client_ip;
290+
union {
291+
char *client_ip;
292+
char *bind_address;
293+
} ci;
290294
my_bool secure_auth;
291295
my_bool report_data_truncation;
292296
int (*local_infile_init)(void **, const char *, void *);

mysql-test/r/mysql.result

+2
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,5 @@ Bug #47147: mysql client option --skip-column-names does not apply to vertical o
434434
1
435435

436436
End of tests
437+
Connected
438+
1

mysql-test/r/mysqladmin.result

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ mysqld is alive
22
mysqladmin: unknown variable 'database=db1'
33
Warning: mysqladmin: unknown variable 'loose-database=db2'
44
mysqld is alive
5+
mysqld is alive

mysql-test/r/mysqldump.result

+5
Original file line numberDiff line numberDiff line change
@@ -4575,6 +4575,11 @@ SELECT LENGTH(a) FROM t2;
45754575
LENGTH(a)
45764576
800
45774577
DROP TABLE t1, t2;
4578+
create table t1 (first char(28) , last varchar(37));
4579+
insert into t1 values ("Magnus", "Blåudd");
4580+
truncate table t1;
4581+
test.t1: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
4582+
drop table t1;
45784583
#
45794584
# End of 5.1 tests
45804585
#

mysql-test/r/mysqlshow.result

+5
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,9 @@ Wildcard: inf_rmation_schema
167167
+--------------------+
168168
| information_schema |
169169
+--------------------+
170+
Database: test
171+
+--------+
172+
| Tables |
173+
+--------+
174+
+--------+
170175
End of 5.0 tests

mysql-test/t/mysql.test

+7
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,10 @@ drop table t1;
427427

428428
--echo
429429
--echo End of tests
430+
431+
432+
#
433+
# WL#3126 TCP address binding for mysql client library;
434+
# - running mysql --protocol=tcp --bind-address=127.0.0.1
435+
#
436+
--exec $MYSQL --protocol=tcp --bind-address=127.0.0.1 -e "select 1 as Connected"

mysql-test/t/mysqladmin.test

+6
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ EOF
3333
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
3434

3535
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
36+
37+
#
38+
# WL#3126 TCP address binding for mysql client library;
39+
# - running mysqladmin --protcol=tcp --bind-address=127.0.0.1
40+
#
41+
--exec $MYSQLADMIN --no-defaults --protocol=tcp --bind-address=127.0.0.1 --host=127.0.0.1 -P $MASTER_MYPORT -u root ping 2>&1

mysql-test/t/mysqlbinlog.test

+7
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,10 @@ diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn $MYSQLTEST_VARDIR/tmp/mysqlbin
487487
# Cleanup for this part of test
488488
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
489489
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
490+
491+
#
492+
# WL#3126 TCP address binding for mysql client library;
493+
# - running mysqlbinlog --protocol=tcp --bind-address=127.0.0.1
494+
#
495+
--exec $MYSQL_BINLOG --short-form --read-from-remote-server --protocol=tcp --bind-address=127.0.0.1 master-bin.000001 > /dev/null
496+

mysql-test/t/mysqlcheck.test

+6-1
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,13 @@ create table `#mysql50#t1-1` (a int);
217217
show tables like 't1-1';
218218
drop table `t1-1`;
219219

220-
--echo End of 5.1 tests
220+
#
221+
# WL#3126 TCP address binding for mysql client library;
222+
# - running mysqlcheck --protcol=tcp --bind-address=127.0.0.1
223+
#
224+
--exec $MYSQL_CHECK --protocol=tcp --bind-address=127.0.0.1 --databases test
221225

226+
--echo End of 5.1 tests
222227

223228
--echo #
224229
--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters

mysql-test/t/mysqldump.test

+12
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,18 @@ SELECT LENGTH(a) FROM t2;
21682168

21692169
DROP TABLE t1, t2;
21702170

2171+
#
2172+
# WL#3126 TCP address binding for mysql client library;
2173+
# - running mysqldump --protocol=tcp --bind-address=127.0.0.1
2174+
# - running mysqlimport --protocol=tcp --bind-address=127.0.0.1
2175+
#
2176+
create table t1 (first char(28) , last varchar(37));
2177+
insert into t1 values ("Magnus", "Blåudd");
2178+
--exec $MYSQL_DUMP --protocol=tcp --bind-address=127.0.0.1 --tab=$MYSQLTEST_VARDIR/tmp/ test
2179+
truncate table t1;
2180+
--exec $MYSQL_IMPORT --protocol=tcp --bind-address=127.0.0.1 test $MYSQLTEST_VARDIR/tmp/t1.txt
2181+
drop table t1;
2182+
21712183
###########################################################################
21722184
--echo #
21732185
--echo # End of 5.1 tests

mysql-test/t/mysqlshow.test

+6
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ DROP TABLE t1, t2;
3535
--exec $MYSQL_SHOW INFORMATION_SCHEMA
3636
--exec $MYSQL_SHOW inf_rmation_schema
3737

38+
#
39+
# WL#3126 TCP address binding for mysql client library;
40+
# - running mysqlshow --protcol=tcp --bind-address=127.0.0.1
41+
#
42+
--exec $MYSQL_SHOW --protocol=tcp --bind-address=127.0.0.1 test
43+
3844
--echo End of 5.0 tests

0 commit comments

Comments
 (0)