Skip to content

Commit

Permalink
Merge branch 'bb-10.11-release' into bb-11.0-release
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jun 5, 2023
2 parents 5ba3baf + 4e2b93d commit 0005f2f
Show file tree
Hide file tree
Showing 430 changed files with 4,170 additions and 1,742 deletions.
48 changes: 0 additions & 48 deletions client/client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,51 +153,3 @@ enum options_client
#else
#define SOCKET_PROTOCOL_TO_FORCE MYSQL_PROTOCOL_PIPE
#endif

/**
Utility function to implicitly change the connection protocol to a
consistent value given the command line arguments. Additionally,
warns the user that the protocol has been changed.
Arguments:
@param [in] host Name of the host to connect to
@param [in, out] opt_protocol Location of the protocol option
variable to update
@param [in] new_protocol New protocol to force
*/
static inline void warn_protocol_override(char *host,
uint *opt_protocol,
uint new_protocol)
{
DBUG_ASSERT(new_protocol == MYSQL_PROTOCOL_TCP
|| new_protocol == SOCKET_PROTOCOL_TO_FORCE);


if ((host == NULL
|| strncmp(host, LOCAL_HOST, sizeof(LOCAL_HOST)-1) == 0))
{
const char *protocol_name;

if (*opt_protocol == MYSQL_PROTOCOL_DEFAULT
#ifndef _WIN32
&& new_protocol == MYSQL_PROTOCOL_SOCKET
#else
&& new_protocol == MYSQL_PROTOCOL_TCP
#endif
)
{
/* This is already the default behavior, do nothing */
return;
}

protocol_name= sql_protocol_typelib.type_names[new_protocol-1];

fprintf(stderr, "%s %s %s\n",
"WARNING: Forcing protocol to ",
protocol_name,
" due to option specification. "
"Please explicitly state intended protocol.");

*opt_protocol = new_protocol;
}
}
64 changes: 10 additions & 54 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ unsigned short terminal_width= 80;
static uint opt_protocol=0;
static const char *opt_protocol_type= "";

static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;

#include "sslopt-vars.h"

const char *default_dbug_option="d:t:o,/tmp/mariadb.trace";
Expand Down Expand Up @@ -1273,14 +1271,6 @@ int main(int argc,char *argv[])
exit(status.exit_status);
}

/* Command line options override configured protocol */
if (protocol_to_force > MYSQL_PROTOCOL_DEFAULT
&& protocol_to_force != opt_protocol)
{
warn_protocol_override(current_host, &opt_protocol, protocol_to_force);
}


if (status.batch && !status.line_buff &&
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
{
Expand Down Expand Up @@ -1890,11 +1880,9 @@ static void usage(int version)


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)
{
/* Track when protocol is set via CLI to not force port TCP protocol override */
static my_bool ignore_protocol_override = FALSE;

switch(opt->id) {
case OPT_CHARSETS_DIR:
strmake_buf(mysql_charsets_dir, argument);
Expand Down Expand Up @@ -1955,18 +1943,11 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
#ifndef EMBEDDED_LIBRARY
if (!argument[0])
opt_protocol= 0;
else if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib,
else if ((opt_protocol=
find_type_with_warning(argument, &sql_protocol_typelib,
opt->name)) <= 0)
exit(1);
#endif

/* Specification of protocol via CLI trumps implicit overrides */
if (filename[0] == '\0')
{
ignore_protocol_override = TRUE;
protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
}

break;
case OPT_SERVER_ARG:
#ifdef EMBEDDED_LIBRARY
Expand Down Expand Up @@ -2066,13 +2047,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
opt_protocol_type= "pipe";

/* Prioritize pipe if explicit via command line */
if (filename[0] == '\0')
{
ignore_protocol_override = TRUE;
protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
}
#endif
break;
#include <sslopt-case.h>
Expand All @@ -2085,35 +2059,17 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
mysql_end(-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 'I':
Expand Down
61 changes: 8 additions & 53 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ static bool sql_log_bin_off= false;
static uint opt_protocol=0;
static myf error_flags; /* flags to pass to my_printf_error, like ME_BELL */

static uint protocol_to_force= MYSQL_PROTOCOL_DEFAULT;

/*
When using extended-status relatively, ex_val_max_len is the estimated
maximum length for any relative value printed by extended-status. The
Expand Down Expand Up @@ -243,12 +241,9 @@ static const char *load_default_groups[]=
0 };

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)
{

/* Track when protocol is set via CLI to not force overrides */
static my_bool ignore_protocol_override = FALSE;

switch(opt->id) {
case 'c':
opt_count_iterations= 1;
Expand Down Expand Up @@ -280,13 +275,6 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
case 'W':
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
if (filename[0] == '\0')
{
ignore_protocol_override = TRUE;
protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
}
#endif
break;
case '#':
Expand Down Expand Up @@ -322,45 +310,19 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
sf_leaking_memory= 1; /* no memory leak reports here */
exit(1);
}

/* Specification of protocol via CLI trumps implicit overrides */
if (filename[0] == '\0')
{
ignore_protocol_override = TRUE;
protocol_to_force = MYSQL_PROTOCOL_DEFAULT;
}

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;
}
Expand Down Expand Up @@ -388,13 +350,6 @@ int main(int argc,char *argv[])
temp_argv= mask_password(argc, &argv);
temp_argc= argc;

/* 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 (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
if (debug_check_flag)
Expand Down
53 changes: 8 additions & 45 deletions client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,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;
Expand Down Expand Up @@ -2061,13 +2059,11 @@ int parse_gtid_filter_option(
}

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 '#':
Expand Down Expand Up @@ -2117,14 +2113,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:
Expand Down Expand Up @@ -2165,35 +2153,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':
Expand Down Expand Up @@ -3261,13 +3231,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)
Expand Down
Loading

0 comments on commit 0005f2f

Please sign in to comment.