Skip to content

Commit 964d5fd

Browse files
committed
Bug #30787660: CONTRIBUTION: INCLUDE PORT NUMBER IN CLIENT ERROR MESSAGE
RB#25395 Now prints the port in the error message too. A contribution by Daniel van Eeden
1 parent 79f6d74 commit 964d5fd

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

libmysql/errmsg.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const char *client_errors[] = {
3636
"Unknown MySQL error",
3737
"Can't create UNIX socket (%d)",
3838
"Can't connect to local MySQL server through socket '%-.100s' (%d)",
39-
"Can't connect to MySQL server on '%-.100s' (%d)",
39+
"Can't connect to MySQL server on '%-.100s:%u' (%d)",
4040
"Can't create TCP/IP socket (%d)",
4141
"Unknown MySQL server host '%-.100s' (%d)",
4242
"MySQL server has gone away",

mysql-test/r/mysql.result

+6
Original file line numberDiff line numberDiff line change
@@ -545,5 +545,11 @@ include/assert_grep.inc [check the output of mysql for the binary-as-hex mark in
545545
#
546546
SUBSTR(NULL, 0, 0) @novar
547547
NULL NULL
548+
#
549+
# Bug #30787660: CONTRIBUTION: INCLUDE PORT NUMBER IN CLIENT ERROR
550+
# MESSAGE
551+
#
552+
# Success criteria: port number present in the error text
553+
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:99999' (111)
548554

549555
End of tests

mysql-test/suite/clone/r/remote_error_basic.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SET GLOBAL clone_autotune_concurrency = OFF;
1313
SET GLOBAL clone_max_concurrency = 8;
1414
SET GLOBAL clone_valid_donor_list = 'HOST:PORT';
1515
CLONE INSTANCE FROM USER@HOST:PORT IDENTIFIED BY '' DATA DIRECTORY = 'CLONE_DATADIR';
16-
ERROR HY000: Clone Donor Error: Connect failed: 2003 : Can't connect to MySQL server on 'HOST' (socket errno).
16+
ERROR HY000: Clone Donor Error: Connect failed: 2003 : Can't connect to MySQL server on 'HOST:PORT' (socket errno).
1717
select ID, STATE, ERROR_NO from performance_schema.clone_status;
1818
ID STATE ERROR_NO
1919
1 Failed 3862

mysql-test/suite/federated/r/federated_bug_35333.result

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ FROM INFORMATION_SCHEMA.TABLES
3131
WHERE TABLE_SCHEMA = 'realdb' OR TABLE_SCHEMA = 'federated'
3232
ORDER BY TABLE_SCHEMA, TABLE_NAME;
3333
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT
34-
federated t0 BASE TABLE FEDERATED Dynamic NULL 0 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
34+
federated t0 BASE TABLE FEDERATED Dynamic NULL 0 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno)
3535
realdb t0 BASE TABLE MyISAM Dynamic 0 0
3636
Warnings:
37-
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
37+
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno)
3838
SHOW WARNINGS;
3939
Level Code Message
40-
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (socket errno)
40+
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno)
4141
#
4242
# Create a MyISAM table then corrupt the file
4343
#

mysql-test/t/mysql.test

+9
Original file line numberDiff line numberDiff line change
@@ -662,5 +662,14 @@ DROP USER bug21464621;
662662
--echo #
663663
--exec $MYSQL --binary-as-hex -e "SELECT SUBSTR(NULL, 0, 0), @novar" 2>&1
664664

665+
--echo #
666+
--echo # Bug #30787660: CONTRIBUTION: INCLUDE PORT NUMBER IN CLIENT ERROR
667+
--echo # MESSAGE
668+
--echo #
669+
670+
--echo # Success criteria: port number present in the error text
671+
--error 1
672+
--exec $MYSQL -h 127.0.0.1 -P 99999 2>&1
673+
665674
--echo
666675
--echo End of tests

sql-common/client.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -6065,7 +6065,7 @@ static mysql_state_machine_status csm_begin_connect(mysql_async_connect *ctx) {
60656065
DBUG_PRINT("error",
60666066
("Got error %d on connect to '%s'", saved_error, host));
60676067
set_mysql_extended_error(mysql, CR_CONN_HOST_ERROR, unknown_sqlstate,
6068-
ER_CLIENT(CR_CONN_HOST_ERROR), host,
6068+
ER_CLIENT(CR_CONN_HOST_ERROR), host, port,
60696069
saved_error);
60706070
return STATE_MACHINE_FAILED;
60716071
}
@@ -6144,7 +6144,7 @@ static mysql_state_machine_status csm_wait_connect(mysql_async_connect *ctx) {
61446144
("Got error %d on connect to '%s'", error, ctx->host));
61456145
set_mysql_extended_error(
61466146
ctx->mysql, CR_CONN_HOST_ERROR, unknown_sqlstate,
6147-
ER_CLIENT(CR_CONN_HOST_ERROR), ctx->host, error);
6147+
ER_CLIENT(CR_CONN_HOST_ERROR), ctx->host, ctx->port, error);
61486148
return STATE_MACHINE_FAILED;
61496149
}
61506150
}

0 commit comments

Comments
 (0)