summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-08-19 15:27:37 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2016-08-19 15:27:37 +0000
commit7b89b9f5108c80f4f270da922d7e6c182a663719 (patch)
tree858a3873942f07610fb26685781e8bdbd3ab2c7f /client
parentdaff133ddf9a9d120050703c0b5753979c6190e0 (diff)
downloadmariadb-git-7b89b9f5108c80f4f270da922d7e6c182a663719.tar.gz
MDEV-9293 Connector/C integration
Diffstat (limited to 'client')
-rw-r--r--client/CMakeLists.txt43
-rw-r--r--client/client_priv.h1
-rw-r--r--client/get_password.c208
-rw-r--r--client/mysql.cc35
-rw-r--r--client/mysql_plugin.c1
-rw-r--r--client/mysqladmin.cc28
-rw-r--r--client/mysqlbinlog.cc22
-rw-r--r--client/mysqlcheck.c3
-rw-r--r--client/mysqldump.c4
-rw-r--r--client/mysqlimport.c4
-rw-r--r--client/mysqlshow.c4
-rw-r--r--client/mysqltest.cc40
12 files changed, 125 insertions, 268 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index e4643ad9358..50280834a68 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -26,13 +26,23 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
)
+ADD_DEFINITIONS(-DHAVE_OPENSSL=1)
+
+INCLUDE_DIRECTORIES(
+BEFORE
+${CONNECTOR_C_INSTALLDIR}/include/mariadb)
+
## We will need libeay32.dll and ssleay32.dll when running client executables.
COPY_OPENSSL_DLLS(copy_openssl_client)
+
+ADD_DEFINITIONS(-DHAVE_LIBMARIADB=1)
+SET(CLIENT_LIB ${CONNECTOR_C_LIBS} mysys)
+
ADD_DEFINITIONS(${SSL_DEFINES})
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc
${CMAKE_SOURCE_DIR}/sql/sql_string.cc)
-TARGET_LINK_LIBRARIES(mysql mysqlclient)
+TARGET_LINK_LIBRARIES(mysql ${CLIENT_LIB})
IF(UNIX)
TARGET_LINK_LIBRARIES(mysql ${MY_READLINE_LIBRARY})
SET_TARGET_PROPERTIES(mysql PROPERTIES ENABLE_EXPORTS TRUE)
@@ -40,39 +50,40 @@ ENDIF(UNIX)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqltest mysqlclient pcre pcreposix)
+TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre pcreposix)
SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE)
MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
-TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)
+TARGET_LINK_LIBRARIES(mysqlcheck ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
-TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
+TARGET_LINK_LIBRARIES(mysqldump ${CLIENT_LIB})
+
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
+TARGET_LINK_LIBRARIES(mysqlimport ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c COMPONENT Server)
-TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
+TARGET_LINK_LIBRARIES(mysql_upgrade ${CLIENT_LIB})
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c)
-TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
+TARGET_LINK_LIBRARIES(mysqlshow ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c)
-TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient)
+TARGET_LINK_LIBRARIES(mysql_plugin ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
-TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
+TARGET_LINK_LIBRARIES(mysqlbinlog ${CLIENT_LIB})
-MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
-TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)
+MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc ../sql/password.c)
+TARGET_LINK_LIBRARIES(mysqladmin ${CLIENT_LIB})
MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)
+TARGET_LINK_LIBRARIES(mysqlslap ${CLIENT_LIB})
# "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/".
IF(WIN32)
@@ -81,10 +92,16 @@ ENDIF(WIN32)
# async_example is just a code example, do not install it.
ADD_EXECUTABLE(async_example async_example.c)
-TARGET_LINK_LIBRARIES(async_example mysqlclient)
+TARGET_LINK_LIBRARIES(async_example ${CLIENT_LIB})
SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap mysql_plugin async_example
PROPERTIES HAS_CXX TRUE)
+
+FOREACH(t mysql mysqltest mysqltest mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysql_plugin mysqlbinlog
+ mysqladmin mysqlslap async_example)
+ ADD_DEPENDENCIES(${t} GenError mariadb_connector_c)
+ENDFOREACH()
+
ADD_DEFINITIONS(-DHAVE_DLOPEN)
diff --git a/client/client_priv.h b/client/client_priv.h
index c0c4954cdf0..1d85791fa73 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -24,6 +24,7 @@
#include <mysql.h>
#include <errmsg.h>
#include <my_getopt.h>
+#include <mysql_version.h>
#ifndef WEXITSTATUS
# ifdef __WIN__
diff --git a/client/get_password.c b/client/get_password.c
deleted file mode 100644
index 8a507d94e9b..00000000000
--- a/client/get_password.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* Copyright (c) 2000, 2001, 2003, 2006, 2008 MySQL AB
- Use is subject to license terms
-
- 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
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
-
-/*
-** Ask for a password from tty
-** This is an own file to avoid conflicts with curses
-*/
-#include <my_global.h>
-#include <my_sys.h>
-#include "mysql.h"
-#include <m_string.h>
-#include <m_ctype.h>
-
-#ifdef HAVE_GETPASS
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif /* HAVE_PWD_H */
-#else /* ! HAVE_GETPASS */
-#ifndef __WIN__
-#include <sys/ioctl.h>
-#ifdef HAVE_TERMIOS_H /* For tty-password */
-#include <termios.h>
-#define TERMIO struct termios
-#else
-#ifdef HAVE_TERMIO_H /* For tty-password */
-#include <termio.h>
-#define TERMIO struct termio
-#else
-#include <sgtty.h>
-#define TERMIO struct sgttyb
-#endif
-#endif
-#ifdef alpha_linux_port
-#include <asm/ioctls.h> /* QQ; Fix this in configure */
-#include <asm/termiobits.h>
-#endif
-#else
-#include <conio.h>
-#endif /* __WIN__ */
-#endif /* HAVE_GETPASS */
-
-#ifdef HAVE_GETPASSPHRASE /* For Solaris */
-#define getpass(A) getpassphrase(A)
-#endif
-
-#ifdef __WIN__
-/* were just going to fake it here and get input from
- the keyboard */
-
-char *get_tty_password(const char *opt_message)
-{
- char to[80];
- char *pos=to,*end=to+sizeof(to)-1;
- int i=0;
- DBUG_ENTER("get_tty_password");
- _cputs(opt_message ? opt_message : "Enter password: ");
- for (;;)
- {
- char tmp;
- tmp=_getch();
- if (tmp == '\b' || (int) tmp == 127)
- {
- if (pos != to)
- {
- _cputs("\b \b");
- pos--;
- continue;
- }
- }
- if (tmp == '\n' || tmp == '\r' || tmp == 3)
- break;
- if (iscntrl(tmp) || pos == end)
- continue;
- _cputs("*");
- *(pos++) = tmp;
- }
- while (pos != to && isspace(pos[-1]) == ' ')
- pos--; /* Allow dummy space at end */
- *pos=0;
- _cputs("\n");
- DBUG_RETURN(my_strdup(to,MYF(MY_FAE)));
-}
-
-#else
-
-
-#ifndef HAVE_GETPASS
-/*
-** Can't use fgets, because readline will get confused
-** length is max number of chars in to, not counting \0
-* to will not include the eol characters.
-*/
-
-static void get_password(char *to,uint length,int fd, my_bool echo)
-{
- char *pos=to,*end=to+length;
-
- for (;;)
- {
- uchar tmp;
- if (my_read(fd,&tmp,1,MYF(0)) != 1)
- break;
- if (tmp == '\b' || (int) tmp == 127)
- {
- if (pos != to)
- {
- if (echo)
- {
- fputs("\b \b",stderr);
- fflush(stderr);
- }
- pos--;
- continue;
- }
- }
- if (tmp == '\n' || tmp == '\r' || tmp == 3)
- break;
- if (iscntrl(tmp) || pos == end)
- continue;
- if (echo)
- {
- fputc('*',stderr);
- fflush(stderr);
- }
- *(pos++)= (char) tmp;
- }
- while (pos != to && isspace(pos[-1]) == ' ')
- pos--; /* Allow dummy space at end */
- *pos=0;
- return;
-}
-
-#endif /* ! HAVE_GETPASS */
-
-
-char *get_tty_password(const char *opt_message)
-{
-#ifdef HAVE_GETPASS
- char *passbuff;
-#else /* ! HAVE_GETPASS */
- TERMIO org,tmp;
-#endif /* HAVE_GETPASS */
- char buff[80];
-
- DBUG_ENTER("get_tty_password");
-
-#ifdef HAVE_GETPASS
- passbuff = getpass(opt_message ? opt_message : "Enter password: ");
-
- /* copy the password to buff and clear original (static) buffer */
- strnmov(buff, passbuff, sizeof(buff) - 1);
-#ifdef _PASSWORD_LEN
- memset(passbuff, 0, _PASSWORD_LEN);
-#endif
-#else
- if (isatty(fileno(stderr)))
- {
- fputs(opt_message ? opt_message : "Enter password: ",stderr);
- fflush(stderr);
- }
-#if defined(HAVE_TERMIOS_H)
- tcgetattr(fileno(stdin), &org);
- tmp = org;
- tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
- tmp.c_cc[VMIN] = 1;
- tmp.c_cc[VTIME] = 0;
- tcsetattr(fileno(stdin), TCSADRAIN, &tmp);
- get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stderr)));
- tcsetattr(fileno(stdin), TCSADRAIN, &org);
-#elif defined(HAVE_TERMIO_H)
- ioctl(fileno(stdin), (int) TCGETA, &org);
- tmp=org;
- tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
- tmp.c_cc[VMIN] = 1;
- tmp.c_cc[VTIME]= 0;
- ioctl(fileno(stdin),(int) TCSETA, &tmp);
- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
- ioctl(fileno(stdin),(int) TCSETA, &org);
-#else
- gtty(fileno(stdin), &org);
- tmp=org;
- tmp.sg_flags &= ~ECHO;
- tmp.sg_flags |= RAW;
- stty(fileno(stdin), &tmp);
- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
- stty(fileno(stdin), &org);
-#endif
- if (isatty(fileno(stderr)))
- fputc('\n',stderr);
-#endif /* HAVE_GETPASS */
-
- DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
-}
-
-#endif /*__WIN__*/
diff --git a/client/mysql.cc b/client/mysql.cc
index 2cc818bd6c1..181320e436e 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1143,6 +1143,9 @@ int main(int argc,char *argv[])
outfile[0]=0; // no (default) outfile
strmov(pager, "stdout"); // the default, if --pager wasn't given
+
+ mysql_init(&mysql);
+
{
char *tmp=getenv("PAGER");
if (tmp && strlen(tmp))
@@ -1203,7 +1206,6 @@ int main(int argc,char *argv[])
glob_buffer.realloc(512);
completion_hash_init(&ht, 128);
init_alloc_root(&hash_mem_root, 16384, 0, MYF(0));
- bzero((char*) &mysql, sizeof(mysql));
if (sql_connect(current_host,current_db,current_user,opt_password,
opt_silent))
{
@@ -1365,6 +1367,8 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user,
opt_ssl_capath, opt_ssl_cipher);
mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
+ char enforce= 1;
+ mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &enforce);
}
mysql_options(mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
(char*)&opt_ssl_verify_server_cert);
@@ -4617,6 +4621,23 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
if (using_opt_local_infile)
mysql_options(&mysql,MYSQL_OPT_LOCAL_INFILE, (char*) &opt_local_infile);
+#if !defined(EMBEDDED_LIBRARY)
+ if (opt_use_ssl)
+ {
+ mysql_ssl_set(&mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
+ opt_ssl_capath, opt_ssl_cipher);
+ mysql_options(&mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
+ mysql_options(&mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
+ }
+ mysql_options(&mysql,MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
+ (my_bool*)&opt_ssl_verify_server_cert);
+#endif
+ if (opt_protocol)
+ mysql_options(&mysql,MYSQL_OPT_PROTOCOL,(char*)&opt_protocol);
+#ifdef HAVE_SMEM
+ if (shared_memory_base_name)
+ mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
+#endif
if (safe_updates)
{
char init_command[100];
@@ -4641,12 +4662,13 @@ sql_real_connect(char *host,char *database,char *user,char *password,
}
return -1; // Retryable
}
-
- charset_info= mysql.charset;
+
+ charset_info= get_charset_by_name(mysql.charset->name, MYF(0));
+
connected=1;
#ifndef EMBEDDED_LIBRARY
- mysql.reconnect= debug_info_flag; // We want to know if this happens
+ mysql_options(&mysql, MYSQL_OPT_RECONNECT, &debug_info_flag);
/*
CLIENT_PROGRESS_OBSOLETE is set only if we requested it in
@@ -4655,7 +4677,10 @@ sql_real_connect(char *host,char *database,char *user,char *password,
if (mysql.client_flag & CLIENT_PROGRESS_OBSOLETE)
mysql_options(&mysql, MYSQL_PROGRESS_CALLBACK, (void*) report_progress);
#else
- mysql.reconnect= 1;
+ {
+ my_bool reconnect= 1;
+ mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
+ }
#endif
#ifdef HAVE_READLINE
build_completion_hash(opt_rehash, 1);
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index ebf04c9a8c3..72fa9485c6c 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -20,6 +20,7 @@
#include <mysql.h>
#include <my_getopt.h>
#include <my_dir.h>
+#include <mysql_version.h>
#define SHOW_VERSION "1.0.0"
#define PRINT_VERSION do { printf("%s Ver %s Distrib %s\n", \
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index fe9db6ea93d..fcc4e626f2f 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -23,8 +23,10 @@
#include <sys/stat.h>
#include <mysql.h>
#include <sql_common.h>
+#include <mysql_version.h>
#include <welcome_copyright_notice.h>
#include <my_rnd.h>
+#include <password.h>
#define ADMIN_VERSION "9.1"
#define MAX_MYSQL_VAR 512
@@ -440,7 +442,7 @@ int main(int argc,char *argv[])
didn't signal for us to die. Otherwise, signal failure.
*/
- if (mysql.net.vio == 0)
+ if (mysql.net.pvio == 0)
{
if (option_wait && !interrupted)
{
@@ -521,7 +523,8 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
if (mysql_real_connect(mysql,host,user,opt_password,NullS,tcp_port,
unix_port, CLIENT_REMEMBER_OPTIONS))
{
- mysql->reconnect= 1;
+ my_bool reconnect= 1;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
if (info)
{
fputs("\n",stderr);
@@ -542,16 +545,16 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)
{
fprintf(stderr,
"Check that mysqld is running and that the socket: '%s' exists!\n",
- unix_port ? unix_port : mysql_unix_port);
+ unix_port ? unix_port : MYSQL_UNIX_ADDR);
}
else if (mysql_errno(mysql) == CR_CONN_HOST_ERROR ||
mysql_errno(mysql) == CR_UNKNOWN_HOST)
{
fprintf(stderr,"Check that mysqld is running on %s",host);
fprintf(stderr," and that the port is %d.\n",
- tcp_port ? tcp_port: mysql_port);
+ tcp_port ? tcp_port: MYSQL_PORT);
fprintf(stderr,"You can check this by doing 'telnet %s %d'\n",
- host, tcp_port ? tcp_port: mysql_port);
+ host, tcp_port ? tcp_port: MYSQL_PORT);
}
}
return 1;
@@ -1077,9 +1080,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
}
if (old)
- make_scrambled_password_323(crypted_pw, typed_password);
+ my_make_scrambled_password_323(crypted_pw, typed_password, sizeof(crypted_pw));
else
- make_scrambled_password(crypted_pw, typed_password);
+ my_make_scrambled_password(crypted_pw, typed_password, sizeof(crypted_pw));
}
else
crypted_pw[0]=0; /* No password */
@@ -1187,7 +1190,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
break;
}
case ADMIN_PING:
- mysql->reconnect=0; /* We want to know of reconnects */
+ {
+ my_bool reconnect= 0;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
if (!mysql_ping(mysql))
{
if (option_silent < 2)
@@ -1197,7 +1202,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
if (mysql_errno(mysql) == CR_SERVER_GONE_ERROR)
{
- mysql->reconnect=1;
+ reconnect= 1;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
if (!mysql_ping(mysql))
puts("connection was down, but mysqld is now alive");
}
@@ -1208,8 +1214,10 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return -1;
}
}
- mysql->reconnect=1; /* Automatic reconnect is default */
+ reconnect=1; /* Automatic reconnect is default */
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
break;
+ }
default:
my_printf_error(0, "Unknown command: '%-.60s'", error_flags, argv[0]);
return 1;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index fa75c423d1b..b3c73d3ce68 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -52,14 +52,18 @@
#include <algorithm>
+#ifdef LIBMARIADB
+#define my_net_write ma_net_write
+#define net_flush ma_net_flush
+#define net_safe_read ma_net_safe_read
+#define my_net_read ma_net_read
+#endif
+
Rpl_filter *binlog_filter= 0;
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
-
-#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
-
/* Needed for Rpl_filter */
CHARSET_INFO* system_charset_info= &my_charset_utf8_general_ci;
@@ -86,6 +90,11 @@ static const char *load_groups[]=
static void error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
static void warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
+
+extern "C" ulong my_net_read(NET *net);
+extern "C" unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
+#define net_store_length mysql_net_store_length
+
static bool one_database=0, to_last_remote_log= 0, disable_log_bin= 0;
static bool opt_hexdump= 0, opt_version= 0;
const char *base64_output_mode_names[]=
@@ -1764,6 +1773,7 @@ static int parse_args(int *argc, char*** argv)
*/
static Exit_status safe_connect()
{
+ my_bool reconnect= 1;
/* Close any old connections to MySQL */
if (mysql)
mysql_close(mysql);
@@ -1809,7 +1819,7 @@ static Exit_status safe_connect()
error("Failed on connect: %s", mysql_error(mysql));
return ERROR_STOP;
}
- mysql->reconnect= 1;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
return OK_CONTINUE;
}
@@ -2273,7 +2283,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
for (;;)
{
- len= cli_safe_read(mysql);
+ len= net_safe_read(mysql);
if (len == packet_error)
{
error("Got error reading packet from server: %s", mysql_error(mysql));
@@ -2843,6 +2853,8 @@ struct encryption_service_st encryption_handler=
#include "my_decimal.h"
#include "decimal.c"
#include "my_decimal.cc"
+#include "../sql-common/my_time.c"
+#include "password.c"
#include "log_event.cc"
#include "log_event_old.cc"
#include "rpl_utility.cc"
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 3e821b183bd..f0f25dbeb71 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -1086,6 +1086,7 @@ static void print_result()
static int dbConnect(char *host, char *user, char *passwd)
{
+ my_bool reconnect= 1;
DBUG_ENTER("dbConnect");
if (verbose > 1)
{
@@ -1124,7 +1125,7 @@ static int dbConnect(char *host, char *user, char *passwd)
DBerror(&mysql_connection, "when trying to connect");
DBUG_RETURN(1);
}
- mysql_connection.reconnect= 1;
+ mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect);
DBUG_RETURN(0);
} /* dbConnect */
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 60f244bf591..acb72a12bf3 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1643,6 +1643,7 @@ static void maybe_exit(int error)
static int connect_to_db(char *host, char *user,char *passwd)
{
char buff[20+FN_REFLEN];
+ my_bool reconnect;
DBUG_ENTER("connect_to_db");
verbose_msg("-- Connecting to %s...\n", host ? host : "localhost");
@@ -1697,7 +1698,8 @@ static int connect_to_db(char *host, char *user,char *passwd)
As we're going to set SQL_MODE, it would be lost on reconnect, so we
cannot reconnect.
*/
- mysql->reconnect= 0;
+ reconnect= 0;
+ mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect);
my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */",
compatible_mode_normal_str);
if (mysql_query_with_error_report(mysql, 0, buff))
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 5b15155e039..37807a4eea5 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -419,6 +419,7 @@ static MYSQL *db_connect(char *host, char *database,
char *user, char *passwd)
{
MYSQL *mysql;
+ my_bool reconnect;
if (verbose)
fprintf(stdout, "Connecting to %s\n", host ? host : "localhost");
if (!(mysql= mysql_init(NULL)))
@@ -463,7 +464,8 @@ static MYSQL *db_connect(char *host, char *database,
ignore_errors=0; /* NO RETURN FROM db_error */
db_error(mysql);
}
- mysql->reconnect= 0;
+ reconnect= 0;
+ mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
if (verbose)
fprintf(stdout, "Selecting database %s\n", database);
if (mysql_select_db(mysql, database))
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index eec4a8d3268..e3e30abc426 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -68,6 +68,7 @@ int main(int argc, char **argv)
my_bool first_argument_uses_wildcards=0;
char *wild;
MYSQL mysql;
+ my_bool reconnect;
static char **defaults_argv;
MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
@@ -155,7 +156,8 @@ int main(int argc, char **argv)
error= 1;
goto error;
}
- mysql.reconnect= 1;
+ reconnect= 1;
+ mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
switch (argc) {
case 0: error=list_dbs(&mysql,wild); break;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 4ff408bfa9d..92f602c2444 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -190,6 +190,8 @@ static char global_subst_from[200];
static char global_subst_to[200];
static char *global_subst= NULL;
static MEM_ROOT require_file_root;
+static const my_bool my_true= 1;
+static const my_bool my_false= 0;
/* Block stack */
enum block_cmd {
@@ -5405,18 +5407,6 @@ static char *get_string(char **to_ptr, char **from_ptr,
}
-void set_reconnect(MYSQL* mysql, my_bool val)
-{
- my_bool reconnect= val;
- DBUG_ENTER("set_reconnect");
- DBUG_PRINT("info", ("val: %d", (int) val));
-#if MYSQL_VERSION_ID < 50000
- mysql->reconnect= reconnect;
-#else
- mysql_options(mysql, MYSQL_OPT_RECONNECT, (char *)&reconnect);
-#endif
- DBUG_VOID_RETURN;
-}
/**
@@ -5501,11 +5491,7 @@ void do_close_connection(struct st_command *command)
#ifndef EMBEDDED_LIBRARY
if (command->type == Q_DIRTY_CLOSE)
{
- if (con->mysql->net.vio)
- {
- vio_delete(con->mysql->net.vio);
- con->mysql->net.vio = 0;
- }
+ mariadb_cancel(con->mysql);
}
#endif /*!EMBEDDED_LIBRARY*/
if (con->stmt)
@@ -8229,10 +8215,18 @@ end:
revert_properties();
/* Close the statement if reconnect, need new prepare */
- if (mysql->reconnect)
{
- mysql_stmt_close(stmt);
- cn->stmt= NULL;
+#ifndef EMBEDDED_LIBRARY
+ my_bool reconnect;
+ mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
+ if (reconnect)
+#else
+ if (mysql->reconnect)
+#endif
+ {
+ mysql_stmt_close(stmt);
+ cn->stmt= NULL;
+ }
}
DBUG_VOID_RETURN;
@@ -8764,7 +8758,7 @@ static void dump_backtrace(void)
#endif
}
fputs("Attempting backtrace...\n", stderr);
- my_print_stacktrace(NULL, my_thread_stack_size);
+ my_print_stacktrace(NULL, (ulong)my_thread_stack_size);
}
#else
@@ -9407,10 +9401,10 @@ int main(int argc, char **argv)
non_blocking_api_enabled= 1;
break;
case Q_DISABLE_RECONNECT:
- set_reconnect(cur_con->mysql, 0);
+ mysql_options(cur_con->mysql, MYSQL_OPT_RECONNECT, &my_false);
break;
case Q_ENABLE_RECONNECT:
- set_reconnect(cur_con->mysql, 1);
+ mysql_options(cur_con->mysql, MYSQL_OPT_RECONNECT, &my_true);
/* Close any open statements - no reconnect, need new prepare */
close_statements();
break;