From 8e2b20bfb0549d2f6be0cfbbfb52cebe256b1ec8 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Thu, 29 Jun 2023 18:34:34 +0700 Subject: [PATCH] MDEV-30639 Upgrade to 10.8 and later does not work on Windows During the upgrade procedure on Windows mysqld.exe is started with the named pipe connection protocol. mysqladmin.exe then pings the server to check if is up and running. Command line looks like: mysqladmin.exe --protocol=pipe --socket=mysql_upgrade_service_xxx ping But the "socket" parameter resets the "protocol" which was previously initialized with the "pipe" value, setting it to "socket". As a result, connection cannot be established and the upgrade procedure fails. "socket" in Windows is used to pass the name of the pipe so resetting the protocol is not valid in this case. This commit fixes resetting of the "protocol" parameter with "socket" parameter in the case when protocol has been previously initialized to "pipe" value --- client/mysql.cc | 11 +++++++++-- client/mysqladmin.cc | 11 +++++++++-- client/mysqlbinlog.cc | 11 +++++++++-- client/mysqlcheck.c | 11 +++++++++-- client/mysqldump.c | 11 +++++++++-- client/mysqlimport.c | 11 +++++++++-- client/mysqlshow.c | 11 +++++++++-- client/mysqlslap.c | 11 +++++++++-- mysql-test/main/cli_options_force_protocol_win.result | 8 +++++++- mysql-test/main/cli_options_force_protocol_win.test | 7 +++++++ 10 files changed, 86 insertions(+), 17 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index fff0c5984ad..f3d07bc2489 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2048,8 +2048,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; case 'I': diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 3bba27b4103..eae46b8b5f1 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -321,8 +321,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; } diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ab41680ab15..517d513c754 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2447,8 +2447,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; case 'v': diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index f326ca62d72..3b9942d55a5 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -387,8 +387,15 @@ get_one_option(const struct my_option *opt, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; } diff --git a/client/mysqldump.c b/client/mysqldump.c index 2d6584aa05b..b75dd39a106 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1074,8 +1074,15 @@ get_one_option(const struct my_option *opt, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; } diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 03f47b3a4ad..7456d109d5b 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -271,8 +271,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; case '#': diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 0a114ad94fb..63981e02d59 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -346,8 +346,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; break; diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 79e5fe1f8bc..f8b8ad15e4c 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -784,8 +784,15 @@ get_one_option(const struct my_option *opt, const char *argument, case 'S': if (filename[0] == '\0') { - /* Socket given on command line, switch protocol to use SOCKETSt */ - opt_protocol= MYSQL_PROTOCOL_SOCKET; + /* + Socket given on command line, switch protocol to use SOCKETSt + Except on Windows if 'protocol= pipe' has been provided in + the config file or command line. + */ + if (opt_protocol != MYSQL_PROTOCOL_PIPE) + { + opt_protocol= MYSQL_PROTOCOL_SOCKET; + } } break; case '#': diff --git a/mysql-test/main/cli_options_force_protocol_win.result b/mysql-test/main/cli_options_force_protocol_win.result index eedfde4f1de..0d17a54dbc7 100644 --- a/mysql-test/main/cli_options_force_protocol_win.result +++ b/mysql-test/main/cli_options_force_protocol_win.result @@ -12,6 +12,12 @@ Connection: localhost via named pipe # exec MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via named pipe # exec MYSQL --host=localhost -W --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" -Connection: localhost via TCP/IP +Connection: localhost via named pipe # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via TCP/IP +# +# MDEV-30639: Upgrade to 10.8 and later does not work on Windows +# due to connection protocol overwrite +# +# exec MYSQL --host=localhost --protocol=pipe --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +Connection: localhost via named pipe diff --git a/mysql-test/main/cli_options_force_protocol_win.test b/mysql-test/main/cli_options_force_protocol_win.test index 63024f3b620..31fb47fd72b 100644 --- a/mysql-test/main/cli_options_force_protocol_win.test +++ b/mysql-test/main/cli_options_force_protocol_win.test @@ -25,3 +25,10 @@ --echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" --exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" + +--echo # +--echo # MDEV-30639: Upgrade to 10.8 and later does not work on Windows +--echo # due to connection protocol overwrite +--echo # +--echo # exec MYSQL --host=localhost --protocol=pipe --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost --protocol=pipe --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:"