summaryrefslogtreecommitdiff
path: root/client/mysqlbinlog.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2023-04-25 21:16:43 +0300
committerMonty <monty@mariadb.org>2023-04-27 11:34:26 +0300
commitf272463b028d3c377acf02b4818ba8d607f71d1c (patch)
tree4fc45fef3b6afd3ea450f93ee547cbbc6aa1b498 /client/mysqlbinlog.cc
parentbb1d1dc84652d43f8b6b92ba722ba8f246ce7124 (diff)
downloadmariadb-git-bb-10.6-monty.tar.gz
Cleanup of MDEV-14974: --port ignored for --host=localhostbb-10.6-monty
The old code added to 10.6 was inconsisting in how TCP/IP and socket connection was chosen. One got also a confusing warning in some cases. Examples: > ../client/mysql --print-defaults ../client/mysql would have been started with the following arguments: --socket=/tmp/mariadbd.sock --port=3307 --no-auto-rehash > ../client/mysql ERROR 2002 (HY000): Can't connect to local server through socket '/tmp/mariadbd.sock' (2) > ../client/mysql --print-defaults ../client/mysql would have been started with the following arguments: --socket=/tmp/mariadbd.sock --port=3307 --no-auto-rehash > ../client/mysql --port=3333 WARNING: Forcing protocol to TCP due to option specification. Please explicitly state intended protocol. ERROR 2002 (HY000): Can't connect to server on 'localhost' (111) > ../client/mysql --port=3333 --socket=sss ERROR 2002 (HY000): Can't connect to local server through socket 'sss' (2) > ../client/mysql --socket=sss --port=3333 ERROR 2002 (HY000): Can't connect to local server through socket 'sss' (2) Some notable things: - One gets a warning if one uses just --port if config file sets socket - Using port and socket gives no warning - Using socket and then port still uses socket This patch changes things the following ways: If --port= is given on the command line, the the protocol is automatically changed to "TCP/IP". - If --socket= is given on the command line, the protocol is automatically changed to "socket". - The last option wins - No warning is given if protocol changes automatically.
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r--client/mysqlbinlog.cc53
1 files changed, 8 insertions, 45 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 460ab22c3c9..d644a9bda49 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -98,8 +98,6 @@ static const char *output_prefix= "";
static char **defaults_argv= 0;
static MEM_ROOT glob_root;
-static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;
-
#ifndef DBUG_OFF
static const char *default_dbug_option = "d:t:o,/tmp/mariadb-binlog.trace";
const char *current_dbug_option= default_dbug_option;
@@ -1898,13 +1896,11 @@ static my_time_t convert_str_to_timestamp(const char* str)
extern "C" my_bool
-get_one_option(const struct my_option *opt, const char *argument, const char *filename)
+get_one_option(const struct my_option *opt, const char *argument,
+ const char *filename)
{
bool tty_password=0;
- /* Track when protocol is set via CLI to not force overrides */
- static my_bool ignore_protocol_override = FALSE;
-
switch (opt->id) {
#ifndef DBUG_OFF
case '#':
@@ -1954,14 +1950,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
sf_leaking_memory= 1; /* no memory leak reports here */
die(1);
}
-
- /* Specification of protocol via CLI trumps implicit overrides */
- if (filename[0] == '\0')
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
break;
#ifdef WHEN_FLASHBACK_REVIEW_READY
case opt_flashback_review:
@@ -2039,35 +2027,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
print_row_event_positions_used= 1;
break;
case 'P':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == SOCKET_PROTOCOL_TO_FORCE)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* If port is set via CLI, try to force protocol to TCP */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = MYSQL_PROTOCOL_TCP;
+ /* Port given on command line, switch protocol to use TCP */
+ opt_protocol= MYSQL_PROTOCOL_TCP;
}
break;
case 'S':
- /* If port and socket are set, fall back to default behavior */
- if (protocol_to_force == MYSQL_PROTOCOL_TCP)
- {
- ignore_protocol_override = TRUE;
- protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
- }
-
- /* Prioritize socket if set via command line */
- if (filename[0] == '\0' &&
- !ignore_protocol_override &&
- protocol_to_force == MYSQL_PROTOCOL_DEFAULT)
+ if (filename[0] == '\0')
{
- protocol_to_force = SOCKET_PROTOCOL_TO_FORCE;
+ /* Socket given on command line, switch protocol to use SOCKETSt */
+ opt_protocol= MYSQL_PROTOCOL_SOCKET;
}
break;
case 'v':
@@ -3043,13 +3013,6 @@ int main(int argc, char** argv)
parse_args(&argc, (char***)&argv);
- /* Command line options override configured protocol */
- if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
- && protocol_to_force != opt_protocol)
- {
- warn_protocol_override(host, &opt_protocol, protocol_to_force);
- }
-
if (!argc || opt_version)
{
if (!opt_version)