From 25e610c965df9c80b17e2a33ee47f25de5dc618e Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 27 Jan 2016 18:19:35 +0100 Subject: [PATCH] Removed deprecated API functions: - mysql_close - mysql_create_db - mysql_drop_db - mysql_get_parameters Fixed build error when SSL is disabled max_allowed_packet and net_buffer size needs to be retrieved via mysql_get_option now (instead of mariadb_get_info) --- include/ma_pvio.h | 2 ++ include/mysql.h | 23 +++----------- libmariadb/libmariadb.c | 69 ++++++++++------------------------------- 3 files changed, 22 insertions(+), 72 deletions(-) diff --git a/include/ma_pvio.h b/include/ma_pvio.h index 4d1a5a45..6984bb7b 100644 --- a/include/ma_pvio.h +++ b/include/ma_pvio.h @@ -4,6 +4,8 @@ #ifdef HAVE_SSL #include +#else +#define MARIADB_SSL void #endif #define PVIO_SET_ERROR if (pvio->set_error) \ diff --git a/include/mysql.h b/include/mysql.h index 6ffd7a96..c74653d0 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -205,6 +205,10 @@ extern unsigned int mariadb_deinitialize_ssl; MYSQL_OPT_CONNECT_ATTR_DELETE, MYSQL_SERVER_PUBLIC_KEY, MYSQL_ENABLE_CLEARTEXT_PLUGIN, + MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, + MYSQL_OPT_SSL_ENFORCE, + MYSQL_OPT_MAX_ALLOWED_PACKET, + MYSQL_OPT_NET_BUFFER_LENGTH, /* MariaDB specific */ MYSQL_PROGRESS_CALLBACK=5999, @@ -389,16 +393,6 @@ typedef struct character_set unsigned int mbmaxlen; /* max. length for multibyte strings */ } MY_CHARSET_INFO; -typedef struct -{ - unsigned long *p_max_allowed_packet; - unsigned long *p_net_buffer_length; - void *extension; -} MYSQL_PARAMETERS; - -#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length) -#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet) - /* Local infile support functions */ #define LOCAL_INFILE_ERROR_LEN 512 @@ -450,8 +444,6 @@ int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql); -MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host, - const char *user, const char *passwd); my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, const char *passwd, const char *db); MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, @@ -469,8 +461,6 @@ int STDCALL mysql_send_query(MYSQL *mysql, const char *q, my_bool STDCALL mysql_read_query_result(MYSQL *mysql); int STDCALL mysql_real_query(MYSQL *mysql, const char *q, size_t length); -int STDCALL mysql_create_db(MYSQL *mysql, const char *DB); -int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); int STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level); int STDCALL mysql_dump_debug_info(MYSQL *mysql); int STDCALL mysql_refresh(MYSQL *mysql, @@ -528,7 +518,6 @@ size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, CHARSE int STDCALL mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...); int STDCALL mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...); int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, void *arg); -MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void); unsigned long STDCALL mysql_hex_string(char *to, const char *from, size_t len); my_socket STDCALL mysql_get_socket(MYSQL *mysql); unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql); @@ -675,7 +664,6 @@ struct st_mariadb_api { MYSQL * (STDCALL *mysql_init)(MYSQL *mysql); int (STDCALL *mysql_ssl_set)(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher); const char * (STDCALL *mysql_get_ssl_cipher)(MYSQL *mysql); - MYSQL * (STDCALL *mysql_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd); my_bool (STDCALL *mysql_change_user)(MYSQL *mysql, const char *user, const char *passwd, const char *db); MYSQL * (STDCALL *mysql_real_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long clientflag); void (STDCALL *mysql_close)(MYSQL *sock); @@ -684,8 +672,6 @@ struct st_mariadb_api { int (STDCALL *mysql_send_query)(MYSQL *mysql, const char *q, size_t length); my_bool (STDCALL *mysql_read_query_result)(MYSQL *mysql); int (STDCALL *mysql_real_query)(MYSQL *mysql, const char *q, size_t length); - int (STDCALL *mysql_create_db)(MYSQL *mysql, const char *DB); - int (STDCALL *mysql_drop_db)(MYSQL *mysql, const char *DB); int (STDCALL *mysql_shutdown)(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level); int (STDCALL *mysql_dump_debug_info)(MYSQL *mysql); int (STDCALL *mysql_refresh)(MYSQL *mysql, unsigned int refresh_options); @@ -732,7 +718,6 @@ struct st_mariadb_api { int (STDCALL *mysql_optionsv)(MYSQL *mysql,enum mysql_option option, ...); int (STDCALL *mysql_get_optionv)(MYSQL *mysql, enum mysql_option option, void *arg, ...); int (STDCALL *mysql_get_option)(MYSQL *mysql, enum mysql_option option, void *arg); - MYSQL_PARAMETERS *(STDCALL *mysql_get_parameters)(void); unsigned long (STDCALL *mysql_hex_string)(char *to, const char *from, size_t len); my_socket (STDCALL *mysql_get_socket)(MYSQL *mysql); unsigned int (STDCALL *mysql_get_timeout_value)(const MYSQL *mysql); diff --git a/libmariadb/libmariadb.c b/libmariadb/libmariadb.c index 28760e4f..f2cff1b8 100644 --- a/libmariadb/libmariadb.c +++ b/libmariadb/libmariadb.c @@ -80,8 +80,6 @@ #undef net_buffer_length extern ulong max_allowed_packet; /* net.c */ extern ulong net_buffer_length; /* net.c */ -static MYSQL_PARAMETERS mariadb_internal_parameters= -{&max_allowed_packet, &net_buffer_length, 0}; static my_bool mysql_client_init=0; static void mysql_close_options(MYSQL *mysql); @@ -1212,28 +1210,6 @@ mysql_get_ssl_cipher(MYSQL *mysql) ** NB! Errors are not reported until you do mysql_real_connect. **************************************************************************/ -/************************************************************************** -** Connect to sql server -** If host == 0 then use localhost -**************************************************************************/ - -MYSQL * STDCALL -mysql_connect(MYSQL *mysql,const char *host, - const char *user, const char *passwd) -{ - MYSQL *res; - mysql=mysql_init(mysql); /* Make it thread safe */ - { - DBUG_ENTER("mysql_connect"); - if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0))) - { - if (mysql->free_me) - my_free(mysql); - } - DBUG_RETURN(res); - } -} - uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer) { if (mysql->server_capabilities & CLIENT_CONNECT_ATTRS) @@ -2509,24 +2485,6 @@ mysql_list_processes(MYSQL *mysql) DBUG_RETURN(mysql_store_result(mysql)); } - -int STDCALL -mysql_create_db(MYSQL *mysql, const char *db) -{ - DBUG_ENTER("mysql_createdb"); - DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql, COM_CREATE_DB,db, (uint) strlen(db),0,0)); -} - - -int STDCALL -mysql_drop_db(MYSQL *mysql, const char *db) -{ - DBUG_ENTER("mysql_drop_db"); - DBUG_PRINT("enter",("db: %s",db)); - DBUG_RETURN(simple_command(mysql, COM_DROP_DB,db,(uint) strlen(db),0,0)); -} - /* In 5.0 this version became an additional parameter shutdown_level */ int STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level) @@ -2820,7 +2778,15 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) if (mysql->net.pvio) mysql->net.pvio->async_context= ctxt; break; - + case MYSQL_OPT_MAX_ALLOWED_PACKET: + if (mysql) + mysql->options.max_allowed_packet= (*(size_t *)arg1); + else + max_allowed_packet= (*(size_t *)arg1); + break; + case MYSQL_OPT_NET_BUFFER_LENGTH: + net_buffer_length= (*(size_t *)arg1); + break; case MYSQL_OPT_SSL_VERIFY_SERVER_CERT: if (*(my_bool *)arg1) mysql->options.client_flag |= CLIENT_SSL_VERIFY_SERVER_CERT; @@ -3172,6 +3138,13 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...) } } break; + case MYSQL_OPT_MAX_ALLOWED_PACKET: + *((unsigned long *)arg)= (mysql) ? mysql->options.max_allowed_packet : + max_allowed_packet; + break; + case MYSQL_OPT_NET_BUFFER_LENGTH: + *((unsigned long *)arg)= net_buffer_length; + break; case MYSQL_SECURE_AUTH: *((my_bool *)arg)= mysql->options.secure_auth; break; @@ -3583,12 +3556,6 @@ mysql_get_server_name(MYSQL *mysql) return mariadb_connection(mysql) ? "MariaDB" : "MySQL"; } -MYSQL_PARAMETERS *STDCALL -mysql_get_parameters(void) -{ - return &mariadb_internal_parameters; -} - static my_socket mariadb_get_socket(MYSQL *mysql) { my_socket sock= INVALID_SOCKET; @@ -3897,7 +3864,6 @@ struct st_mariadb_api MARIADB_API= mysql_init, mysql_ssl_set, mysql_get_ssl_cipher, - mysql_connect, mysql_change_user, mysql_real_connect, mysql_close, @@ -3906,8 +3872,6 @@ struct st_mariadb_api MARIADB_API= mysql_send_query, mysql_read_query_result, mysql_real_query, - mysql_create_db, - mysql_drop_db, mysql_shutdown, mysql_dump_debug_info, mysql_refresh, @@ -3954,7 +3918,6 @@ struct st_mariadb_api MARIADB_API= mysql_optionsv, mysql_get_optionv, mysql_get_option, - mysql_get_parameters, mysql_hex_string, mysql_get_socket, mysql_get_timeout_value,