Skip to content

Commit

Permalink
Bug#25304844: REMOVE EMBEDDED_LIBRARY #IFDEF
Browse files Browse the repository at this point in the history
Remove dead code related to embedded server.

Part 5: Remove EMBEDDED_LIBRARY ifdef from client/
and storage/

This patch also removes the --server-arg option from 'mysql'.
This option was embedded server specific and undocumented.
--server-arg and --server-file are, for the same reason,
removed from 'mysqltest'.
  • Loading branch information
jhauglid committed Jan 16, 2017
1 parent f3bf09a commit 0a68d5d
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 464 deletions.
6 changes: 3 additions & 3 deletions client/base/mysql_connection_options.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -99,7 +99,7 @@ void Mysql_connection_options::create_options()
"The protocol to use for connection (tcp, socket, pipe, memory).")
->add_callback(new std::function<void(char*)>(
std::bind(&Mysql_connection_options::protocol_callback, this, _1)));
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
this->create_new_option(&this->m_shared_memory_base_name,
"shared-memory-base-name", "Base name of shared memory.");
#endif
Expand Down Expand Up @@ -137,7 +137,7 @@ MYSQL* Mysql_connection_options::create_connection()
if (!this->m_secure_auth)
mysql_options(connection,MYSQL_SECURE_AUTH,
(char*)&this->m_secure_auth);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
if (this->m_shared_memory_base_name.has_value())
mysql_options(connection,MYSQL_SHARED_MEMORY_BASE_NAME,
this->m_shared_memory_base_name.value().c_str());
Expand Down
4 changes: 2 additions & 2 deletions client/base/mysql_connection_options.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -121,7 +121,7 @@ class Mysql_connection_options
Nullable<std::string> m_host;
uint32 m_mysql_port;
Nullable<std::string> m_mysql_unix_port;
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
Nullable<std::string> m_shared_memory_base_name;
#endif
Nullable<std::string> m_default_auth;
Expand Down
4 changes: 2 additions & 2 deletions client/base/ssl_options.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,7 @@ void Mysql_connection_options::Ssl_options::create_options()
std::function<void(char*)> callback(
std::bind(&Mysql_connection_options::Ssl_options::mode_option_callback, this, _1));

#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
#if defined(HAVE_OPENSSL)
this->create_new_option(&this->m_ssl_mode_string, "ssl-mode",
"SSL connection mode.")
#ifdef MYSQL_CLIENT
Expand Down
8 changes: 4 additions & 4 deletions client/check/mysqlcheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static char *opt_password = 0, *current_user = 0,
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
static int first_error = 0;
static const char *opt_skip_database= "";
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol=0;
Expand Down Expand Up @@ -183,7 +183,7 @@ static struct my_option my_long_options[] =
{"repair", 'r',
"Can fix almost anything except unique keys that aren't unique.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", &shared_memory_base_name, &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -463,7 +463,7 @@ static int dbConnect(char *host, char *user, char *passwd)
mysql_options(&mysql_connection,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
if (opt_bind_addr)
mysql_options(&mysql_connection, MYSQL_OPT_BIND, opt_bind_addr);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
if (shared_memory_base_name)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
Expand Down Expand Up @@ -557,7 +557,7 @@ int main(int argc, char **argv)

dbDisconnect(current_host);
my_free(opt_password);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
my_free(shared_memory_base_name);
#endif
free_defaults(argv);
Expand Down
4 changes: 2 additions & 2 deletions client/client_priv.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -52,7 +52,7 @@ enum options_client
OPT_PROMPT, OPT_IGN_LINES, OPT_TRANSACTION, OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH,
OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_SET_GTID_PURGED, OPT_SERVER_ARG,
OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_SET_GTID_PURGED,
OPT_STOP_POSITION, OPT_START_DATETIME, OPT_STOP_DATETIME,
OPT_SIGINT_IGNORE, OPT_HEXBLOB, OPT_ORDER_BY_PRIMARY, OPT_COUNT,
OPT_TRIGGERS,
Expand Down
58 changes: 7 additions & 51 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static char delimiter[16]= DEFAULT_DELIMITER;
static size_t delimiter_length= 1;
unsigned short terminal_width= 80;

#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol=0;
Expand Down Expand Up @@ -1131,11 +1131,6 @@ static COMMANDS commands[] = {

static const char *load_default_groups[]= { "mysql","client",0 };

static int embedded_server_arg_count= 0;
static char *embedded_server_args[MAX_SERVER_ARGS];
static const char *embedded_server_groups[]=
{ "server", "embedded", "mysql_SERVER", 0 };

#ifdef HAVE_READLINE
/*
HIST_ENTRY is defined for libedit, but not for the real readline
Expand Down Expand Up @@ -1320,8 +1315,7 @@ int main(int argc,char *argv[])
my_end(0);
exit(1);
}
if (mysql_server_init(embedded_server_arg_count, embedded_server_args,
(char**) embedded_server_groups))
if (mysql_server_init(0, nullptr, nullptr))
{
put_error(NULL);
free_defaults(defaults_argv);
Expand Down Expand Up @@ -1518,12 +1512,10 @@ void mysql_end(int sig)
my_free(full_username);
my_free(part_username);
my_free(default_prompt);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
my_free(shared_memory_base_name);
#endif
my_free(current_prompt);
while (embedded_server_arg_count > 1)
my_free(embedded_server_args[--embedded_server_arg_count]);
mysql_server_end();
free_defaults(defaults_argv);
my_end(my_end_arg);
Expand Down Expand Up @@ -1811,7 +1803,7 @@ static struct my_option my_long_options[] =
&opt_reconnect, &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent. Print results with a tab as separator, "
"each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", &shared_memory_base_name,
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -1866,8 +1858,6 @@ static struct my_option my_long_options[] =
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol. Deprecated. Always TRUE",
&opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"server-arg", OPT_SERVER_ARG, "Send embedded server this as a parameter.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.",
&show_warnings, &show_warnings, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -2014,10 +2004,8 @@ get_one_option(int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
}
break;
case OPT_MYSQL_PROTOCOL:
#ifndef EMBEDDED_LIBRARY
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
opt->name);
#endif
break;
case OPT_SECURE_AUTH:
/* --secure-auth is a zombie option. */
Expand All @@ -2029,30 +2017,6 @@ get_one_option(int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
else
CLIENT_WARN_DEPRECATED_NO_REPLACEMENT("--secure-auth");
break;
case OPT_SERVER_ARG:
#ifdef EMBEDDED_LIBRARY
/*
When the embedded server is being tested, the client needs to be
able to pass command-line arguments to the embedded server so it can
locate the language files and data directory.
*/
if (!embedded_server_arg_count)
{
embedded_server_arg_count= 1;
embedded_server_args[0]= (char*) "";
}
if (embedded_server_arg_count == MAX_SERVER_ARGS-1 ||
!(embedded_server_args[embedded_server_arg_count++]=
my_strdup(PSI_NOT_INSTRUMENTED,
argument, MYF(MY_FAE))))
{
put_info("Can't use server argument", INFO_ERROR);
return 0;
}
#else /*EMBEDDED_LIBRARY */
printf("WARNING: --server-arg option not supported in this configuration.\n");
#endif
break;
case 'A':
opt_rehash= 0;
break;
Expand Down Expand Up @@ -5044,11 +5008,7 @@ sql_real_connect(char *host,char *database,char *user,char *password,
charset_info= mysql.charset;

connected=1;
#ifndef EMBEDDED_LIBRARY
mysql.reconnect= debug_info_flag; // We want to know if this happens
#else
mysql.reconnect= 1;
#endif
#ifdef HAVE_READLINE
build_completion_hash(opt_rehash, 1);
#endif
Expand Down Expand Up @@ -5086,7 +5046,7 @@ init_connection_options(MYSQL *mysql)
if (opt_protocol)
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);

#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
if (shared_memory_base_name)
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME, shared_memory_base_name);
#endif
Expand Down Expand Up @@ -5190,12 +5150,12 @@ com_status(String *buffer MY_ATTRIBUTE((unused)),
mysql_free_result(result);
}

#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
#if defined(HAVE_OPENSSL)
if ((status_str= mysql_get_ssl_cipher(&mysql)))
tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n",
status_str);
else
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
#endif /* HAVE_OPENSSL */
tee_puts("SSL:\t\t\tNot in use", stdout);

if (skip_updates)
Expand Down Expand Up @@ -5240,14 +5200,12 @@ com_status(String *buffer MY_ATTRIBUTE((unused)),
tee_fprintf(stdout, "Server characterset:\t%s\n", mysql.charset->csname);
}

#ifndef EMBEDDED_LIBRARY
if (strstr(mysql_get_host_info(&mysql),"TCP/IP") || ! mysql.unix_socket)
tee_fprintf(stdout, "TCP port:\t\t%d\n", mysql.port);
else
tee_fprintf(stdout, "UNIX socket:\t\t%s\n", mysql.unix_socket);
if (mysql.net.compress)
tee_fprintf(stdout, "Protocol:\t\tCompressed\n");
#endif

if ((status_str= mysql_stat(&mysql)) && !mysql_error(&mysql)[0])
{
Expand Down Expand Up @@ -5654,7 +5612,6 @@ static const char* construct_prompt()
}
case 'p':
{
#ifndef EMBEDDED_LIBRARY
if (!connected)
{
processed_prompt.append("not_connected");
Expand All @@ -5674,7 +5631,6 @@ static const char* construct_prompt()
char *pos=strrchr(mysql.unix_socket,'/');
processed_prompt.append(pos ? pos+1 : mysql.unix_socket);
}
#endif
}
break;
case 'U':
Expand Down
14 changes: 6 additions & 8 deletions client/mysql_secure_installation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static my_bool password_provided= FALSE;
static my_bool g_expire_password_on_exit= FALSE;
static my_bool opt_use_default= FALSE;

#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
static char *shared_memory_base_name= default_shared_memory_base_name;
#endif

Expand All @@ -58,7 +58,7 @@ static struct my_option my_connection_options[]=
{"password", 'p', "Password to connect to the server. If password is not "
"given it's asked from the tty.", 0, 0, 0, GET_PASSWORD, OPT_ARG , 0, 0, 0,
0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand All @@ -72,7 +72,7 @@ static struct my_option my_connection_options[]=
{"protocol", OPT_MYSQL_PROTOCOL,
"The protocol to use for connection (tcp, socket, pipe, memory).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", &shared_memory_base_name,
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -158,13 +158,11 @@ my_arguments_get_one_option(int optid,
#include <sslopt-case.h>

case OPT_MYSQL_PROTOCOL:
#ifndef EMBEDDED_LIBRARY
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
opt->name);
#endif
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
#endif
break;
Expand All @@ -183,7 +181,7 @@ init_connection_options(MYSQL *mysql)
if (opt_protocol)
mysql_options(mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol);

#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
if (shared_memory_base_name)
mysql_options(mysql, MYSQL_SHARED_MEMORY_BASE_NAME, shared_memory_base_name);
#endif
Expand Down Expand Up @@ -927,7 +925,7 @@ int main(int argc,char *argv[])
exit(1);
}

#ifdef __WIN__
#ifdef _WIN32
/* Convert command line parameters from UTF16LE to UTF8MB4. */
my_win_translate_command_line_args(&my_charset_utf8mb4_bin, &argc, &argv);
#endif
Expand Down
10 changes: 5 additions & 5 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static uint opt_enable_cleartext_plugin= 0;
static my_bool using_opt_enable_cleartext_plugin= 0;
static my_bool opt_show_warnings= 0;

#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol=0;
Expand Down Expand Up @@ -202,7 +202,7 @@ static struct my_option my_long_options[] =
{"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it"
" uses old (pre-4.1.1) protocol. Deprecated. Always TRUE",
&opt_secure_auth, &opt_secure_auth, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
"Base name of shared memory.", &shared_memory_base_name, &shared_memory_base_name,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
Expand Down Expand Up @@ -398,7 +398,7 @@ int main(int argc,char *argv[])
SSL_SET_OPTIONS(&mysql);
if (opt_protocol)
mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
if (shared_memory_base_name)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
Expand Down Expand Up @@ -528,7 +528,7 @@ int main(int argc,char *argv[])
mysql_close(&mysql);
my_free(opt_password);
my_free(user);
#if defined (_WIN32) && !defined (EMBEDDED_LIBRARY)
#if defined (_WIN32)
my_free(shared_memory_base_name);
#endif
free_defaults(save_argv);
Expand Down Expand Up @@ -1092,7 +1092,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}

/* Warn about password being set in non ssl connection */
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
#if defined(HAVE_OPENSSL)
{
uint ssl_mode= 0;
if (!mysql_get_option(mysql, MYSQL_OPT_SSL_MODE, &ssl_mode) &&
Expand Down
Loading

0 comments on commit 0a68d5d

Please sign in to comment.