diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2016-08-19 15:46:27 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2016-08-19 15:46:27 +0000 |
commit | 31a8cf54c8a7913338480a0571feaf32143b5f64 (patch) | |
tree | 8847835f515af17d6c090300b138c31e1226731e /client | |
parent | 7b89b9f5108c80f4f270da922d7e6c182a663719 (diff) | |
download | mariadb-git-31a8cf54c8a7913338480a0571feaf32143b5f64.tar.gz |
Revert "MDEV-9293 Connector/C integration"
This reverts commit 7b89b9f5108c80f4f270da922d7e6c182a663719.
Diffstat (limited to 'client')
-rw-r--r-- | client/CMakeLists.txt | 43 | ||||
-rw-r--r-- | client/client_priv.h | 1 | ||||
-rw-r--r-- | client/get_password.c | 208 | ||||
-rw-r--r-- | client/mysql.cc | 35 | ||||
-rw-r--r-- | client/mysql_plugin.c | 1 | ||||
-rw-r--r-- | client/mysqladmin.cc | 28 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 22 | ||||
-rw-r--r-- | client/mysqlcheck.c | 3 | ||||
-rw-r--r-- | client/mysqldump.c | 4 | ||||
-rw-r--r-- | client/mysqlimport.c | 4 | ||||
-rw-r--r-- | client/mysqlshow.c | 4 | ||||
-rw-r--r-- | client/mysqltest.cc | 40 |
12 files changed, 268 insertions, 125 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 50280834a68..e4643ad9358 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -26,23 +26,13 @@ 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 ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysql mysqlclient) IF(UNIX) TARGET_LINK_LIBRARIES(mysql ${MY_READLINE_LIBRARY}) SET_TARGET_PROPERTIES(mysql PROPERTIES ENABLE_EXPORTS TRUE) @@ -50,40 +40,39 @@ ENDIF(UNIX) MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test) SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre pcreposix) +TARGET_LINK_LIBRARIES(mysqltest mysqlclient pcre pcreposix) SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE) MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c) -TARGET_LINK_LIBRARIES(mysqlcheck ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient) MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c) -TARGET_LINK_LIBRARIES(mysqldump ${CLIENT_LIB}) - +TARGET_LINK_LIBRARIES(mysqldump mysqlclient) MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c) SET_SOURCE_FILES_PROPERTIES(mysqlimport.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlimport ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient) MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c COMPONENT Server) -TARGET_LINK_LIBRARIES(mysql_upgrade ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c) -TARGET_LINK_LIBRARIES(mysqlshow ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient) MYSQL_ADD_EXECUTABLE(mysql_plugin mysql_plugin.c) -TARGET_LINK_LIBRARIES(mysql_plugin ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysql_plugin mysqlclient) MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc) -TARGET_LINK_LIBRARIES(mysqlbinlog ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient) -MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc ../sql/password.c) -TARGET_LINK_LIBRARIES(mysqladmin ${CLIENT_LIB}) +MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient) MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c) SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") -TARGET_LINK_LIBRARIES(mysqlslap ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(mysqlslap mysqlclient) # "WIN32" also covers 64 bit. "echo" is used in some files below "mysql-test/". IF(WIN32) @@ -92,16 +81,10 @@ 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 ${CLIENT_LIB}) +TARGET_LINK_LIBRARIES(async_example mysqlclient) 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 1d85791fa73..c0c4954cdf0 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -24,7 +24,6 @@ #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 new file mode 100644 index 00000000000..8a507d94e9b --- /dev/null +++ b/client/get_password.c @@ -0,0 +1,208 @@ +/* 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 181320e436e..2cc818bd6c1 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1143,9 +1143,6 @@ 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)) @@ -1206,6 +1203,7 @@ 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)) { @@ -1367,8 +1365,6 @@ 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); @@ -4621,23 +4617,6 @@ 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]; @@ -4662,13 +4641,12 @@ sql_real_connect(char *host,char *database,char *user,char *password, } return -1; // Retryable } - - charset_info= get_charset_by_name(mysql.charset->name, MYF(0)); - + + charset_info= mysql.charset; connected=1; #ifndef EMBEDDED_LIBRARY - mysql_options(&mysql, MYSQL_OPT_RECONNECT, &debug_info_flag); + mysql.reconnect= debug_info_flag; // We want to know if this happens /* CLIENT_PROGRESS_OBSOLETE is set only if we requested it in @@ -4677,10 +4655,7 @@ 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 - { - my_bool reconnect= 1; - mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect); - } + mysql.reconnect= 1; #endif #ifdef HAVE_READLINE build_completion_hash(opt_rehash, 1); diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 72fa9485c6c..ebf04c9a8c3 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -20,7 +20,6 @@ #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 fcc4e626f2f..fe9db6ea93d 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -23,10 +23,8 @@ #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 @@ -442,7 +440,7 @@ int main(int argc,char *argv[]) didn't signal for us to die. Otherwise, signal failure. */ - if (mysql.net.pvio == 0) + if (mysql.net.vio == 0) { if (option_wait && !interrupted) { @@ -523,8 +521,7 @@ 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)) { - my_bool reconnect= 1; - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect= 1; if (info) { fputs("\n",stderr); @@ -545,16 +542,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_ADDR); + unix_port ? unix_port : mysql_unix_port); } 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; @@ -1080,9 +1077,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) } } if (old) - my_make_scrambled_password_323(crypted_pw, typed_password, sizeof(crypted_pw)); + make_scrambled_password_323(crypted_pw, typed_password); else - my_make_scrambled_password(crypted_pw, typed_password, sizeof(crypted_pw)); + make_scrambled_password(crypted_pw, typed_password); } else crypted_pw[0]=0; /* No password */ @@ -1190,9 +1187,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) break; } case ADMIN_PING: - { - my_bool reconnect= 0; - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect=0; /* We want to know of reconnects */ if (!mysql_ping(mysql)) { if (option_silent < 2) @@ -1202,8 +1197,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) { if (mysql_errno(mysql) == CR_SERVER_GONE_ERROR) { - reconnect= 1; - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect=1; if (!mysql_ping(mysql)) puts("connection was down, but mysqld is now alive"); } @@ -1214,10 +1208,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) return -1; } } - reconnect=1; /* Automatic reconnect is default */ - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect=1; /* Automatic reconnect is default */ 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 b3c73d3ce68..fa75c423d1b 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -52,18 +52,14 @@ #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; @@ -90,11 +86,6 @@ 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[]= @@ -1773,7 +1764,6 @@ 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); @@ -1819,7 +1809,7 @@ static Exit_status safe_connect() error("Failed on connect: %s", mysql_error(mysql)); return ERROR_STOP; } - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect= 1; return OK_CONTINUE; } @@ -2283,7 +2273,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, for (;;) { - len= net_safe_read(mysql); + len= cli_safe_read(mysql); if (len == packet_error) { error("Got error reading packet from server: %s", mysql_error(mysql)); @@ -2853,8 +2843,6 @@ 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 f0f25dbeb71..3e821b183bd 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1086,7 +1086,6 @@ static void print_result() static int dbConnect(char *host, char *user, char *passwd) { - my_bool reconnect= 1; DBUG_ENTER("dbConnect"); if (verbose > 1) { @@ -1125,7 +1124,7 @@ static int dbConnect(char *host, char *user, char *passwd) DBerror(&mysql_connection, "when trying to connect"); DBUG_RETURN(1); } - mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect); + mysql_connection.reconnect= 1; DBUG_RETURN(0); } /* dbConnect */ diff --git a/client/mysqldump.c b/client/mysqldump.c index acb72a12bf3..60f244bf591 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1643,7 +1643,6 @@ 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"); @@ -1698,8 +1697,7 @@ 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. */ - reconnect= 0; - mysql_options(&mysql_connection, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect= 0; 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 37807a4eea5..5b15155e039 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -419,7 +419,6 @@ 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))) @@ -464,8 +463,7 @@ static MYSQL *db_connect(char *host, char *database, ignore_errors=0; /* NO RETURN FROM db_error */ db_error(mysql); } - reconnect= 0; - mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql->reconnect= 0; 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 e3e30abc426..eec4a8d3268 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -68,7 +68,6 @@ 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 */ @@ -156,8 +155,7 @@ int main(int argc, char **argv) error= 1; goto error; } - reconnect= 1; - mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect); + mysql.reconnect= 1; switch (argc) { case 0: error=list_dbs(&mysql,wild); break; diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 92f602c2444..4ff408bfa9d 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -190,8 +190,6 @@ 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 { @@ -5407,6 +5405,18 @@ 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; +} /** @@ -5491,7 +5501,11 @@ void do_close_connection(struct st_command *command) #ifndef EMBEDDED_LIBRARY if (command->type == Q_DIRTY_CLOSE) { - mariadb_cancel(con->mysql); + if (con->mysql->net.vio) + { + vio_delete(con->mysql->net.vio); + con->mysql->net.vio = 0; + } } #endif /*!EMBEDDED_LIBRARY*/ if (con->stmt) @@ -8215,18 +8229,10 @@ end: revert_properties(); /* Close the statement if reconnect, need new prepare */ + if (mysql->reconnect) { -#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; - } + mysql_stmt_close(stmt); + cn->stmt= NULL; } DBUG_VOID_RETURN; @@ -8758,7 +8764,7 @@ static void dump_backtrace(void) #endif } fputs("Attempting backtrace...\n", stderr); - my_print_stacktrace(NULL, (ulong)my_thread_stack_size); + my_print_stacktrace(NULL, my_thread_stack_size); } #else @@ -9401,10 +9407,10 @@ int main(int argc, char **argv) non_blocking_api_enabled= 1; break; case Q_DISABLE_RECONNECT: - mysql_options(cur_con->mysql, MYSQL_OPT_RECONNECT, &my_false); + set_reconnect(cur_con->mysql, 0); break; case Q_ENABLE_RECONNECT: - mysql_options(cur_con->mysql, MYSQL_OPT_RECONNECT, &my_true); + set_reconnect(cur_con->mysql, 1); /* Close any open statements - no reconnect, need new prepare */ close_statements(); break; |