diff options
31 files changed, 436 insertions, 83 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f8ae5b2d9c..3094dc398c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,7 @@ IF(DISABLE_SHARED) ENDIF() OPTION(ENABLED_PROFILING "Enable profiling" ON) OPTION(WITHOUT_SERVER "Build only the client library and clients" OFF) +OPTION(WITH_LIBMARIADB "Build client library and clients with MariaDB Connector/C" ON) IF(UNIX) OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) ENDIF() diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index e4643ad9358..9d1162dee73 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -26,13 +26,28 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) +ADD_DEFINITIONS(-DHAVE_OPENSSL=1) + +IF(WITH_LIBMARIADB) + INCLUDE_DIRECTORIES( + BEFORE + ${CONNECTOR_C_INSTALLDIR}/include/mariadb +) +ENDIF() ## We will need libeay32.dll and ssleay32.dll when running client executables. COPY_OPENSSL_DLLS(copy_openssl_client) +IF(WITH_LIBMARIADB) + ADD_DEFINITIONS(-DHAVE_LIBMARIADB=1) + SET(CLIENT_LIB ${CONNECTOR_C_LIBS} mysys) +ELSE() + SET(CLIENT_LIB mysqlclient) +ENDIF() + 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 +55,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 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) +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 +96,14 @@ 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) + ADD_DEPENDENCIES(${t} mariadb_connector_c) +ENDFOREACH() ADD_DEFINITIONS(-DHAVE_DLOPEN) diff --git a/client/client_priv.h b/client/client_priv.h index 656c8fcf32a..1c7511c4c8a 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -23,6 +23,7 @@ #include <mysql.h> #include <errmsg.h> #include <my_getopt.h> +#include <mysql_version.h> #ifndef WEXITSTATUS # ifdef __WIN__ diff --git a/client/mysql.cc b/client/mysql.cc index 9c6320fe10a..766ddff4749 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -46,6 +46,7 @@ #include <locale.h> #endif + const char *VER= "15.1"; /* Don't try to make a nice table if the data is too big */ @@ -194,6 +195,7 @@ unsigned short terminal_width= 80; static char *shared_memory_base_name=0; #endif static uint opt_protocol=0; + static CHARSET_INFO *charset_info= &my_charset_latin1; #include "sslopt-vars.h" @@ -1051,6 +1053,7 @@ extern "C" int read_history(const char *command); extern "C" int write_history(const char *command); extern "C" HIST_ENTRY *history_get(int num); extern "C" int history_length; + static int not_in_history(const char *line); static void initialize_readline (char *name); static void fix_history(String *final_command); @@ -1355,10 +1358,11 @@ static bool do_connect(MYSQL *mysql, const char *host, const char *user, #if defined(HAVE_OPENSSL) && !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_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); + 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); @@ -1896,8 +1900,9 @@ static int get_options(int argc, char **argv) { char *tmp, *pagpoint; int ho_error; +#ifndef LIBMARIADB MYSQL_PARAMETERS *mysql_params= mysql_get_parameters(); - +#endif tmp= (char *) getenv("MYSQL_HOST"); if (tmp) current_host= my_strdup(tmp, MYF(MY_WME)); @@ -1912,14 +1917,24 @@ static int get_options(int argc, char **argv) strmov(pager, pagpoint); strmov(default_pager, pager); +#ifdef LIBMARIADB + mariadb_get_infov(NULL, MARIADB_MAX_ALLOWED_PACKET, &opt_max_allowed_packet); + mariadb_get_infov(NULL, MARIADB_NET_BUFFER_LENGTH, &opt_net_buffer_length); +#else opt_max_allowed_packet= *mysql_params->p_max_allowed_packet; opt_net_buffer_length= *mysql_params->p_net_buffer_length; +#endif if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return(ho_error); +#ifdef LIBMARIADB + mysql_options(NULL, MYSQL_OPT_MAX_ALLOWED_PACKET, &opt_max_allowed_packet); + mysql_options(NULL, MYSQL_OPT_NET_BUFFER_LENGTH, &opt_net_buffer_length); +#else *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_net_buffer_length= opt_net_buffer_length; +#endif if (status.batch) /* disable pager and outfile in this case */ { @@ -1955,7 +1970,7 @@ static int get_options(int argc, char **argv) connect_flag|= CLIENT_IGNORE_SPACE; if (opt_progress_reports) - connect_flag|= CLIENT_PROGRESS_OBSOLETE; + connect_flag|= CLIENT_PROGRESS; return(0); } @@ -4611,6 +4626,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]; @@ -4635,21 +4667,28 @@ sql_real_connect(char *host,char *database,char *user,char *password, } return -1; // Retryable } - + +#ifndef HAVE_LIBMARIADB charset_info= mysql.charset; +#else + charset_info= get_charset_by_name(mysql.charset->name, MYF(0)); +#endif 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 + CLIENT_PROGRESS is set only if we requested it in mysql_real_connect() and the server also supports it */ - if (mysql.client_flag & CLIENT_PROGRESS_OBSOLETE) + if (mysql.client_flag & CLIENT_PROGRESS) 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); @@ -4724,7 +4763,7 @@ com_status(String *buffer __attribute__((unused)), mysql_free_result(result); } -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#if !defined(EMBEDDED_LIBRARY) if ((status_str= mysql_get_ssl_cipher(&mysql))) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", status_str); 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 0089e03ac93..3978499679b 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -23,6 +23,7 @@ #include <sys/stat.h> #include <mysql.h> #include <sql_common.h> +#include <mysql_version.h> #include <welcome_copyright_notice.h> #include <my_rnd.h> @@ -446,8 +447,11 @@ int main(int argc,char *argv[]) re-establish it if --wait ("retry-connect") was given and user didn't signal for us to die. Otherwise, signal failure. */ - +#ifndef HAVE_LIBMARIADB if (mysql.net.vio == 0) +#else + if (mysql.net.pvio == 0) +#endif { if (option_wait && !interrupted) { @@ -528,7 +532,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); @@ -1083,10 +1088,14 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) mysql_free_result(res); } } +#ifndef HAVE_LIBMARIADB if (old) make_scrambled_password_323(crypted_pw, typed_password); else make_scrambled_password(crypted_pw, typed_password); +#else + ma_make_scrambled_password(crypted_pw, typed_password); +#endif } else crypted_pw[0]=0; /* No password */ @@ -1194,7 +1203,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) @@ -1204,7 +1215,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"); } @@ -1215,8 +1227,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 0463a9857bc..748f8e8f0cc 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -38,6 +38,9 @@ #include "sql_priv.h" #include "log_event.h" #include "compat56.h" +#ifdef HAVE_LIBMARIADB +#include "violite.h" +#endif #include "sql_common.h" #include "my_dir.h" #include <welcome_copyright_notice.h> // ORACLE_WELCOME_COPYRIGHT_NOTICE @@ -51,13 +54,21 @@ #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) - +/* where do we use this definition ??? #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; @@ -76,6 +87,7 @@ static FILE *result_file; static char *result_file_name= 0; static const char *output_prefix= ""; + #ifndef DBUG_OFF static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace"; #endif @@ -85,6 +97,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); +#ifdef HAVE_LIBMARIADB +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 +#endif 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[]= @@ -1761,6 +1778,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); @@ -1794,7 +1812,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; } @@ -2250,7 +2268,11 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, slave_id= 0; int4store(buf + 6, slave_id); memcpy(buf + 10, logname, logname_len); +#ifndef HAVE_LIBMARIADB if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1)) +#else + if (ma_simple_command(mysql, COM_BINLOG_DUMP, (char *)buf, logname_len + 10, 1, 0)) +#endif { error("Got fatal error sending the log dump command."); DBUG_RETURN(ERROR_STOP); @@ -2258,7 +2280,11 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, for (;;) { +#ifndef HAVE_LIBMARIADB len= cli_safe_read(mysql); +#else + len= net_safe_read(mysql); +#endif if (len == packet_error) { error("Got error reading packet from server: %s", mysql_error(mysql)); @@ -2828,6 +2854,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 627fbcb1873..f27c89ccef9 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -1081,6 +1081,7 @@ static void print_result() static int dbConnect(char *host, char *user, char *passwd) { + my_bool reconnect= 1; DBUG_ENTER("dbConnect"); if (verbose > 1) { @@ -1119,7 +1120,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 1c939b87c65..942f835ecef 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -944,10 +944,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), static int get_options(int *argc, char ***argv) { int ho_error; +#ifndef HAVE_LIBMARIADB MYSQL_PARAMETERS *mysql_params= mysql_get_parameters(); opt_max_allowed_packet= *mysql_params->p_max_allowed_packet; opt_net_buffer_length= *mysql_params->p_net_buffer_length; +#else + mysql_get_optionv(NULL, MYSQL_OPT_MAX_ALLOWED_PACKET, &opt_max_allowed_packet); + mysql_get_optionv(NULL, MYSQL_OPT_NET_BUFFER_LENGTH, &opt_net_buffer_length); +#endif md_result_file= stdout; if (load_defaults("my",load_default_groups,argc,argv)) @@ -971,8 +976,13 @@ static int get_options(int *argc, char ***argv) if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) return(ho_error); +#ifndef HAVE_LIBMARIADB *mysql_params->p_max_allowed_packet= opt_max_allowed_packet; *mysql_params->p_net_buffer_length= opt_net_buffer_length; +#else + mysql_get_optionv(NULL, MYSQL_OPT_MAX_ALLOWED_PACKET, &opt_max_allowed_packet); + mysql_get_optionv(NULL, MYSQL_OPT_NET_BUFFER_LENGTH, &opt_net_buffer_length); +#endif if (debug_info_flag) my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO; if (debug_check_flag) @@ -1644,6 +1654,7 @@ static int connect_to_db(char *host, char *user,char *passwd) { char buff[20+FN_REFLEN]; DBUG_ENTER("connect_to_db"); + my_bool reconnect; verbose_msg("-- Connecting to %s...\n", host ? host : "localhost"); mysql_init(&mysql_connection); @@ -1697,7 +1708,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 2363f1b69df..c9967e8548e 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 fd81f18790a..5f9f21fa370 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 f09ad3107cc..0978cf13556 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -265,6 +265,10 @@ static int replace(DYNAMIC_STRING *ds_str, const char *search_str, ulong search_len, const char *replace_str, ulong replace_len); +#ifdef HAVE_LIBMARIADB +extern "C" void ma_pvio_close(MARIADB_PVIO *); +#endif + static uint opt_protocol=0; DYNAMIC_ARRAY q_lines; @@ -1524,6 +1528,7 @@ static void cleanup_and_exit(int exit_code) } sf_leaking_memory= 0; /* all memory should be freed by now */ + sleep(10); exit(exit_code); } @@ -4394,9 +4399,11 @@ void do_send_quit(struct st_command *command) if (!(con= find_connection_by_name(name))) die("connection '%s' not found in connection pool", name); - +#ifndef HAVE_LIBMARIADB simple_command(con->mysql,COM_QUIT,0,0,1); - +#else + con->mysql->methods->db_command(con->mysql, COM_QUIT, 0, 0, 1, 0); +#endif DBUG_VOID_RETURN; } @@ -5501,12 +5508,20 @@ void do_close_connection(struct st_command *command) #ifndef EMBEDDED_LIBRARY if (command->type == Q_DIRTY_CLOSE) { +#ifndef HAVE_LIBMARIADB if (con->mysql->net.vio) { vio_delete(con->mysql->net.vio); con->mysql->net.vio = 0; } +#else + if (con->mysql->net.pvio) + { + ma_pvio_close(con->mysql->net.pvio); + con->mysql->net.pvio = 0; + } } +#endif #endif /*!EMBEDDED_LIBRARY*/ if (con->stmt) do_stmt_close(con); @@ -5934,7 +5949,7 @@ void do_connect(struct st_command *command) if (opt_charsets_dir) mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_DIR, opt_charsets_dir); -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#if !defined(EMBEDDED_LIBRARY) if (opt_use_ssl) con_ssl= 1; #endif @@ -8231,10 +8246,14 @@ end: revert_properties(); /* Close the statement if reconnect, need new prepare */ - if (mysql->reconnect) { - mysql_stmt_close(stmt); - cn->stmt= NULL; + my_bool reconnect; + mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect); + if (reconnect) + { + mysql_stmt_close(stmt); + cn->stmt= NULL; + } } DBUG_VOID_RETURN; diff --git a/cmake/iconv.cmake b/cmake/iconv.cmake new file mode 100644 index 00000000000..0290514fc0f --- /dev/null +++ b/cmake/iconv.cmake @@ -0,0 +1,76 @@ +# +# Copyright (c) 2010 Michael Bell <michael.bell@web.de> +# 2015-2016 MariaDB Corporation AB + +if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + # Already in cache, be silent + set(ICONV_FIND_QUIETLY TRUE) +endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +# On Mac we need to check for iconv in macports first, the default +# iconv library redefines symbols, so we will get external dependency +# errors. +IF(APPLE) + find_path(ICONV_INCLUDE_DIR iconv.h PATHS + /opt/local/include/ + /usr/include/ + NO_CMAKE_SYSTEM_PATH) + find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS + /opt/local/lib/ + /usr/lib/ + NO_CMAKE_SYSTEM_PATH) + SET(ICONV_EXTERNAL TRUE) +ELSE() + find_path(ICONV_INCLUDE_DIR iconv.h) + find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2) + IF(ICONV_LIBRARIES) + SET(ICONV_EXTERNAL TRUE) + ELSE() + find_library(ICONV_LIBRARIES NAMES c) + ENDIF() +ENDIF() + +if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + set (ICONV_FOUND TRUE) +endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) +IF(ICONV_EXTERNAL) + set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) +ENDIF() + +if (ICONV_FOUND) + include(CheckCSourceCompiles) + CHECK_C_SOURCE_COMPILES(" + #include <iconv.h> + int main(){ + iconv_t conv = 0; + const char* in = 0; + size_t ilen = 0; + char* out = 0; + size_t olen = 0; + iconv(conv, &in, &ilen, &out, &olen); + return 0; + } +" ICONV_SECOND_ARGUMENT_IS_CONST ) +endif (ICONV_FOUND) + +set (CMAKE_REQUIRED_INCLUDES) +set (CMAKE_REQUIRED_LIBRARIES) + +if (ICONV_FOUND) + if (NOT ICONV_FIND_QUIETLY) + message (STATUS "Found Iconv: ${ICONV_LIBRARIES}") + endif (NOT ICONV_FIND_QUIETLY) +else (ICONV_FOUND) + if (Iconv_FIND_REQUIRED) + message (FATAL_ERROR "Could not find Iconv") + endif (Iconv_FIND_REQUIRED) +endif (ICONV_FOUND) + +MARK_AS_ADVANCED( + ICONV_INCLUDE_DIR + ICONV_LIBRARIES + ICONV_EXTERNAL + ICONV_SECOND_ARGUMENT_IS_CONST +) diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake new file mode 100644 index 00000000000..c3cae61155f --- /dev/null +++ b/cmake/mariadb_connector_c.cmake @@ -0,0 +1,31 @@ +# +# Configuration options for Connector/C +# +IF(WIN32) + # todo: libcurl for windows +ELSE() + SET(CC_LIBS ${LIBDL} ${LIBM} ${LIBPTHREAD}) + INCLUDE(FindCURL) + IF(CURL_FOUND) + SET(CC_LIBS ${CC_LIBS} ${CURL_LIBRARIES}) + ENDIF() + FIND_PACKAGE(OpenSSL) + FIND_PACKAGE(GnuTLS) + IF(OPENSSL_FOUND) + SET(CC_LIBS ${CC_LIBS} ${OPENSSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) + SET(CC_CMAKE_OPTS "-DWITH_SSL=OPENSSL") + ELSEIF (GNUTLS_FOUND) + SET(CC_LIBS ${CC_LIBS} ${GNUTLS_LIBRARY}) + SET(CC_CMAKE_OPTS "-DWITH_SSL=GNUTLS") + ELSE() + SET(CC_CMAKE_OPTS "-DWITH_SSL=OFF") + ENDIF() + INCLUDE(${CMAKE_SOURCE_DIR}/cmake/iconv.cmake) + IF(ICONV_FOUND) + IF(ICONV_EXTERNAL) + SET(CC_LIBS ${CC_LIBS} ${ICONV_LIBRARIES}) + ENDIF() + ENDIF() +ENDIF() +MARK_AS_ADVANCED(CC_LIBS CC_CMAKE_OPTS) + diff --git a/include/my_sys.h b/include/my_sys.h index 7b7158573b4..25554701a8c 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1019,6 +1019,7 @@ extern void add_compiled_collation(struct charset_info_st *cs); extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info, char *to, size_t to_length, const char *from, size_t length); +extern char *get_tty_password(const char *opt_message); #ifdef __WIN__ #define BACKSLASH_MBTAIL /* File system character set */ diff --git a/include/mysql_com.h b/include/mysql_com.h index c13999a1028..b3ced3d18ed 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -218,7 +218,7 @@ enum enum_server_command /* Don't close the connection for a connection with expired password. */ #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) -#define CLIENT_PROGRESS_OBSOLETE (1UL << 29) +#define CLIENT_PROGRESS (1UL << 29) #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) /* It used to be that if mysql_real_connect() failed, it would delete any diff --git a/include/sql_common.h b/include/sql_common.h index 39b8ce18517..88b313093e6 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -110,7 +110,7 @@ void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate, /* client side of the pluggable authentication */ struct st_plugin_vio_info; -void mpvio_info(Vio *vio, struct st_plugin_vio_info *info); + int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, const char *data_plugin, const char *db); int mysql_client_plugin_init(); diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index e605d0134e7..2faa2094a19 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -46,7 +46,7 @@ "Certificate revocation list path (implies --ssl).", &opt_ssl_crlpath, &opt_ssl_crlpath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef MYSQL_CLIENT +#if defined(MYSQL_CLIENT) {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, "Verify server's \"Common Name\" in its cert against hostname used " "when connecting. This option is disabled by default.", diff --git a/include/sslopt-vars.h b/include/sslopt-vars.h index 8e669760faf..575e882306a 100644 --- a/include/sslopt-vars.h +++ b/include/sslopt-vars.h @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) +#if (defined(HAVE_OPENSSL) || defined(HAVE_SSL)) && !defined(EMBEDDED_LIBRARY) #ifdef SSL_VARS_NOT_STATIC #define SSL_STATIC #else @@ -30,8 +30,7 @@ SSL_STATIC char *opt_ssl_cipher = 0; SSL_STATIC char *opt_ssl_key = 0; SSL_STATIC char *opt_ssl_crl = 0; SSL_STATIC char *opt_ssl_crlpath = 0; -#ifdef MYSQL_CLIENT SSL_STATIC my_bool opt_ssl_verify_server_cert= 0; #endif -#endif #endif /* SSLOPT_VARS_INCLUDED */ + diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 7dfc572b281..ae51a3c6bd5 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -14,6 +14,44 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +INCLUDE(${CMAKE_SOURCE_DIR}/cmake/mariadb_connector_c.cmake) + +SET(CONNECTOR_C_INSTALLDIR "${CMAKE_BINARY_DIR}/mariadb-connector-c/${CMAKE_CFG_INTDIR}" CACHE STRING "") +INCLUDE(ExternalProject) +ExternalProject_Add( + mariadb_connector_c + GIT_REPOSITORY "https://github.com/MariaDB/mariadb-connector-c/" + GIT_TAG "master" + UPDATE_COMMAND "" + PATCH_COMMAND "" + SOURCE_DIR ${CMAKE_BINARY_DIR}/mariadb-connector-c-src + INSTALL_DIR ${CONNECTOR_C_INSTALLDIR} + CMAKE_ARGS ${CC_CMAKE_OPTS} + "-DCMAKE_INSTALL_PREFIX=${CONNECTOR_C_INSTALLDIR}" + TEST_COMMAND "" +) + +ADD_LIBRARY(mariadbclient STATIC IMPORTED GLOBAL) +SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_LOCATION + "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/${CMAKE_STATIC_LIBRARY_PREFIX}mariadbclient${CMAKE_STATIC_LIBRARY_SUFFIX}") + +ADD_DEPENDENCIES(mariadbclient mariadb_connector_c) +ADD_LIBRARY(libmariadb STATIC IMPORTED GLOBAL) +IF(WIN32) +SET_TARGET_PROPERTIES(libmariadb PROPERTIES IMPORTED_LOCATION + "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/libmariadb${CMAKE_STATIC_LIBRARY_SUFFIX}") +ELSE() +SET_TARGET_PROPERTIES(libmariadb PROPERTIES IMPORTED_LOCATION + "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/${CMAKE_STATIC_LIBRARY_PREFIX}mysql${CMAKE_STATIC_LIBRARY_SUFFIX}") +SET_TARGET_PROPERTIES(mariadbclient PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${CC_LIBS}") +ENDIF() +ADD_DEPENDENCIES(libmariadb mariadb_connector_c) + +SET(CONNECTOR_C_LIBS + "${CONNECTOR_C_INSTALLDIR}/lib/mariadb/${CMAKE_STATIC_LIBRARY_PREFIX}mariadbclient${CMAKE_STATIC_LIBRARY_SUFFIX}" + ${CC_LIBS} + CACHE STRING "") + INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysql @@ -390,7 +428,6 @@ ENDIF() SET(CLIENT_SOURCES - get_password.c libmysql.c errmsg.c ../sql-common/client.c diff --git a/mysql-test/t/ssl_7937.test b/mysql-test/t/ssl_7937.test index d593b9d936d..8e9d1901907 100644 --- a/mysql-test/t/ssl_7937.test +++ b/mysql-test/t/ssl_7937.test @@ -26,10 +26,10 @@ create procedure have_ssl() # we fake the test result for yassl let yassl=`select variable_value='Unknown' from information_schema.session_status where variable_name='Ssl_session_cache_mode'`; if (!$yassl) { + --replace_result "self signed certificate in certificate chain" "Failed to verify the server certificate" --exec $MYSQL --ssl --ssl-verify-server-cert -e "call test.have_ssl()" 2>&1 } if ($yassl) { --echo ERROR 2026 (HY000): SSL connection error: Failed to verify the server certificate } - drop procedure have_ssl; diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 0d404586569..6a97eb458f2 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -16,6 +16,7 @@ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c + get_password.c errors.c hash.c list.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c diff --git a/client/get_password.c b/mysys/get_password.c index 8a507d94e9b..8a507d94e9b 100644 --- a/client/get_password.c +++ b/mysys/get_password.c diff --git a/mysys/typelib.c b/mysys/typelib.c index 75744a65ec8..bb4499020df 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -409,3 +409,10 @@ my_ulonglong find_set_from_flags(const TYPELIB *lib, uint default_name, return res; } +/* Typelib by all clients */ +const char *sql_protocol_names_lib[] = +{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS }; + +TYPELIB sql_protocol_typelib ={ array_elements(sql_protocol_names_lib) - 1, "", +sql_protocol_names_lib, NULL }; + diff --git a/sql-common/client.c b/sql-common/client.c index b96231fcc13..4a4084fbc7e 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -601,7 +601,7 @@ restart: uint last_errno=uint2korr(pos); if (last_errno == 65535 && - (mysql->server_capabilities & CLIENT_PROGRESS_OBSOLETE)) + (mysql->server_capabilities & CLIENT_PROGRESS)) { if (cli_report_progress(mysql, pos+2, (uint) (len-3))) { @@ -1005,11 +1005,6 @@ enum option_id { static TYPELIB option_types={array_elements(default_options)-1, "options",default_options, NULL}; -const char *sql_protocol_names_lib[] = -{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS }; -TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"", - sql_protocol_names_lib, NULL}; - static int add_init_command(struct st_mysql_options *options, const char *cmd) { char *tmp; diff --git a/sql/log_event.cc b/sql/log_event.cc index 3715f0cc4d4..820d49c220e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1354,7 +1354,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, ulong data_len; char buf[LOG_EVENT_MINIMAL_HEADER_LEN]; uchar ev_offset= packet->length(); -#ifndef max_allowed_packet +#if (!defined(MYSQL_CLIENT) && !defined(HAVE_LIBMARIADB)) THD *thd=current_thd; ulong max_allowed_packet= thd ? thd->slave_thread ? slave_max_allowed_packet : thd->variables.max_allowed_packet diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 241f19c75a3..90a39a10df9 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -12283,6 +12283,10 @@ err: fills MYSQL_PLUGIN_VIO_INFO structure with the information about the connection */ + +extern "C" void mpvio_info(Vio *vio, + MYSQL_PLUGIN_VIO_INFO *info); + static void server_mpvio_info(MYSQL_PLUGIN_VIO *vio, MYSQL_PLUGIN_VIO_INFO *info) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f32e0270ce4..8a84e8deccf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,11 +14,22 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ADD_DEFINITIONS("-DMYSQL_CLIENT") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +IF(WITH_LIBMARIADB) + INCLUDE_DIRECTORIES( + BEFORE + ${CONNECTOR_C_INSTALLDIR}/include/mariadb +) +ENDIF() +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/client) ADD_EXECUTABLE(mysql_client_test mysql_client_test.c) -TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient) +IF(WITH_LIBMARIADB) + SET(CLIENT_LIB mariadbclient mysys) +ELSE() + SET(CLIENT_LIB mysqlclient) +ENDIF() +TARGET_LINK_LIBRARIES(mysql_client_test ${CLIENT_LIB}) SET_TARGET_PROPERTIES(mysql_client_test PROPERTIES LINKER_LANGUAGE CXX) IF(WITH_UNIT_TESTS) diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c index b7211989f1f..0ac2db67546 100644 --- a/tests/mysql_client_fw.c +++ b/tests/mysql_client_fw.c @@ -21,9 +21,12 @@ #include <my_getopt.h> #include <m_string.h> #include <mysqld_error.h> +#include <mysql_version.h> #include <sql_common.h> #include <mysql/client_plugin.h> +static void set_reconnect(MYSQL *mysql, my_bool reconnect); +static my_bool get_reconnect(MYSQL *mysql); /* If non_blocking_api_enabled is true, we will re-define all the blocking API functions as wrappers that call the corresponding non-blocking API @@ -363,7 +366,7 @@ static MYSQL* client_connect(ulong flag, uint protocol, my_bool auto_reconnect) fprintf(stdout, "\n Check the connection options using --help or -?\n"); exit(1); } - mysql->reconnect= auto_reconnect; + set_reconnect(mysql, auto_reconnect); if (!opt_silent) fprintf(stdout, "OK"); @@ -1162,7 +1165,7 @@ static my_bool thread_query(const char *query) error= 1; goto end; } - l_mysql->reconnect= 1; + set_reconnect(l_mysql, 1); if (mysql_query(l_mysql, query)) { fprintf(stderr, "Query failed (%s)\n", mysql_error(l_mysql)); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 7af1249f596..c8469dc9386 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -34,8 +34,25 @@ #include "mysql_client_fw.c" +#ifdef LIBMARIADB +#define simple_command(A,B,C,D,E) (A)->methods->db_command((A),(B),(const char *)(C),(D),(E), NULL); +#endif + /* Query processing */ + +static void set_reconnect(MYSQL *mysql, my_bool reconnect) +{ + mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect); +} + +static my_bool get_reconnect(MYSQL *mysql) +{ + my_bool reconnect; + mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect); + return reconnect; +} + static void client_query() { int rc; @@ -3121,7 +3138,7 @@ static void test_long_data_str1() int rc, i; char data[255]; long length; - ulong max_blob_length, blob_length, length1; + ulong max_blob_length, blob_length= 0, length1; my_bool true_value; MYSQL_RES *result; MYSQL_BIND my_bind[2]; @@ -4810,7 +4827,7 @@ static void test_stmt_close() myerror("connection failed"); exit(1); } - lmysql->reconnect= 1; + set_reconnect(lmysql, 1); if (!opt_silent) fprintf(stdout, "OK"); @@ -5494,7 +5511,7 @@ DROP TABLE IF EXISTS test_multi_tab"; fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } - mysql_local->reconnect= 1; + set_reconnect(mysql_local, 1); rc= mysql_query(mysql_local, query); myquery(rc); @@ -5618,7 +5635,7 @@ static void test_prepare_multi_statements() fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } - mysql_local->reconnect= 1; + set_reconnect(mysql_local, 1); strmov(query, "select 1; select 'another value'"); stmt= mysql_simple_prepare(mysql_local, query); check_stmt_r(stmt); @@ -6334,6 +6351,8 @@ static void test_pure_coverage() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); +#if 0 + /* MariaDB C/C converts geometry to string */ my_bind[0].buffer_type= MYSQL_TYPE_GEOMETRY; rc= mysql_stmt_bind_result(stmt, my_bind); check_execute_r(stmt, rc); /* unsupported buffer type */ @@ -6344,6 +6363,7 @@ static void test_pure_coverage() rc= mysql_stmt_store_result(stmt); DIE_UNLESS(rc); /* Old error must be reset first */ +#endif mysql_stmt_close(stmt); mysql_query(mysql, "DROP TABLE test_pure"); @@ -7223,7 +7243,7 @@ static void test_prepare_grant() mysql_close(lmysql); exit(1); } - lmysql->reconnect= 1; + set_reconnect(lmysql, 1); if (!opt_silent) fprintf(stdout, "OK"); @@ -7685,7 +7705,7 @@ static void test_drop_temp() mysql_close(lmysql); exit(1); } - lmysql->reconnect= 1; + set_reconnect(lmysql, 1); if (!opt_silent) fprintf(stdout, "OK"); @@ -13400,10 +13420,14 @@ static void test_bug9478() /* Fill in the fetch packet */ int4store(buff, stmt->stmt_id); buff[4]= 1; /* prefetch rows */ +#ifndef LIBMARIADB rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, (uchar*) buff, sizeof(buff), 0,0,1,NULL) || (*mysql->methods->read_query_result)(mysql)); +#else + rc= mysql_stmt_fetch(stmt); +#endif DIE_UNLESS(rc); if (!opt_silent && i == 0) printf("Got error (as expected): %s\n", mysql_error(mysql)); @@ -15001,8 +15025,8 @@ static void test_opt_reconnect() } if (!opt_silent) - fprintf(stdout, "reconnect before mysql_options: %d\n", lmysql->reconnect); - DIE_UNLESS(lmysql->reconnect == 0); + fprintf(stdout, "reconnect before mysql_options: %d\n", get_reconnect(lmysql)); + DIE_UNLESS(get_reconnect(lmysql) == 0); if (mysql_options(lmysql, MYSQL_OPT_RECONNECT, &my_true)) { @@ -15012,8 +15036,8 @@ static void test_opt_reconnect() /* reconnect should be 1 */ if (!opt_silent) - fprintf(stdout, "reconnect after mysql_options: %d\n", lmysql->reconnect); - DIE_UNLESS(lmysql->reconnect == 1); + fprintf(stdout, "reconnect after mysql_options: %d\n", get_reconnect(lmysql)); + DIE_UNLESS(get_reconnect(lmysql) == 1); if (!(mysql_real_connect(lmysql, opt_host, opt_user, opt_password, current_db, opt_port, @@ -15026,8 +15050,8 @@ static void test_opt_reconnect() /* reconnect should still be 1 */ if (!opt_silent) fprintf(stdout, "reconnect after mysql_real_connect: %d\n", - lmysql->reconnect); - DIE_UNLESS(lmysql->reconnect == 1); + get_reconnect(lmysql)); + DIE_UNLESS(get_reconnect(lmysql) == 1); mysql_close(lmysql); @@ -15038,8 +15062,8 @@ static void test_opt_reconnect() } if (!opt_silent) - fprintf(stdout, "reconnect before mysql_real_connect: %d\n", lmysql->reconnect); - DIE_UNLESS(lmysql->reconnect == 0); + fprintf(stdout, "reconnect before mysql_real_connect: %d\n", get_reconnect(lmysql)); + DIE_UNLESS(get_reconnect(lmysql) == 0); if (!(mysql_real_connect(lmysql, opt_host, opt_user, opt_password, current_db, opt_port, @@ -15052,8 +15076,8 @@ static void test_opt_reconnect() /* reconnect should still be 0 */ if (!opt_silent) fprintf(stdout, "reconnect after mysql_real_connect: %d\n", - lmysql->reconnect); - DIE_UNLESS(lmysql->reconnect == 0); + get_reconnect(lmysql)); + DIE_UNLESS(get_reconnect(lmysql) == 0); mysql_close(lmysql); } @@ -17983,7 +18007,8 @@ static void test_bug43560(void) strncpy(buffer, values[2], BUFSIZE); length= strlen(buffer); rc= mysql_stmt_execute(stmt); - DIE_UNLESS(rc && mysql_stmt_errno(stmt) == CR_SERVER_LOST); + DIE_UNLESS(rc && (mysql_stmt_errno(stmt) == CR_SERVER_LOST || + mysql_stmt_errno(stmt) == CR_SERVER_GONE_ERROR)); opt_drop_db= 0; client_disconnect(conn); @@ -18750,10 +18775,10 @@ static void test_progress_reporting() myheader("test_progress_reporting"); - conn= client_connect(CLIENT_PROGRESS_OBSOLETE, MYSQL_PROTOCOL_TCP, 0); - if (!(conn->server_capabilities & CLIENT_PROGRESS_OBSOLETE)) + conn= client_connect(CLIENT_PROGRESS, MYSQL_PROTOCOL_TCP, 0); + if (!(conn->server_capabilities & CLIENT_PROGRESS)) return; - DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS_OBSOLETE); + DIE_UNLESS(conn->client_flag & CLIENT_PROGRESS); mysql_options(conn, MYSQL_PROGRESS_CALLBACK, (void*) report_progress); rc= mysql_query(conn, "set @save=@@global.progress_report_time"); @@ -19396,9 +19421,17 @@ static void test_big_packet() /* We run the tests with a server with max packet size of 3200000 */ size_t big_packet= 31000000L; int i; +#ifndef LIBMARIADB MYSQL_PARAMETERS *mysql_params= mysql_get_parameters(); long org_max_allowed_packet= *mysql_params->p_max_allowed_packet; long opt_net_buffer_length= *mysql_params->p_net_buffer_length; +#else + size_t org_max_allowed_packet; + size_t org_net_buffer_length; + + mysql_get_option(mysql, MYSQL_OPT_MAX_ALLOWED_PACKET, &org_max_allowed_packet); + mysql_get_option(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, &org_net_buffer_length); +#endif myheader("test_big_packet"); @@ -19411,6 +19444,18 @@ static void test_big_packet() exit(1); } +#ifndef LIBMARIADB + *mysql_params->p_max_allowed_packet= big_packet+1000; + *mysql_params->p_net_buffer_length= 8L*256L*256L; +#else + { + size_t x= big_packet + 1000; + mysql_options(mysql_local, MYSQL_OPT_MAX_ALLOWED_PACKET, &x); + x= 8L * 256L*256L; + mysql_options(mysql_local, MYSQL_OPT_NET_BUFFER_LENGTH, &x); + } +#endif + if (!(mysql_real_connect(mysql_local, opt_host, opt_user, opt_password, current_db, opt_port, opt_unix_socket, 0))) @@ -19419,8 +19464,6 @@ static void test_big_packet() exit(1); } - *mysql_params->p_max_allowed_packet= big_packet+1000; - *mysql_params->p_net_buffer_length= 8L*256L*256L; end= strmov(strfill(strmov(query, "select length(\""), big_packet,'a'),"\")"); @@ -19436,9 +19479,14 @@ static void test_big_packet() mysql_close(mysql_local); my_free(query); - + +#ifndef LIBMARIADB *mysql_params->p_max_allowed_packet= org_max_allowed_packet; *mysql_params->p_net_buffer_length = opt_net_buffer_length; +#else + mysql_options(mysql, MYSQL_OPT_MAX_ALLOWED_PACKET, &org_max_allowed_packet); + mysql_options(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, &org_net_buffer_length); +#endif } diff --git a/tests/nonblock-wrappers.h b/tests/nonblock-wrappers.h index d6f42511f3a..fd50e4e4ee6 100644 --- a/tests/nonblock-wrappers.h +++ b/tests/nonblock-wrappers.h @@ -321,6 +321,7 @@ MK_WRAPPER( mysql, mysql) +#ifdef HAVE_DEPRECATED_ASYNC_API MK_WRAPPER( MYSQL_RES *, mysql_list_dbs, @@ -356,6 +357,7 @@ MK_WRAPPER( (mysql, table, wild), mysql, mysql) +#endif /* HAVE_DEPRECATED_ASYNC_API */ MK_WRAPPER( my_bool, @@ -500,7 +502,6 @@ MK_WRAPPER( #define mysql_list_dbs wrap_mysql_list_dbs #define mysql_list_tables wrap_mysql_list_tables #define mysql_list_processes wrap_mysql_list_processes -#define mysql_list_fields wrap_mysql_list_fields #define mysql_read_query_result wrap_mysql_read_query_result #define mysql_stmt_prepare wrap_mysql_stmt_prepare #define mysql_stmt_execute wrap_mysql_stmt_execute |