Skip to content

Commit 25e610c

Browse files
committed
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)
1 parent b00a0e2 commit 25e610c

File tree

3 files changed

+22
-72
lines changed

3 files changed

+22
-72
lines changed

include/ma_pvio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#ifdef HAVE_SSL
66
#include <ma_ssl.h>
7+
#else
8+
#define MARIADB_SSL void
79
#endif
810

911
#define PVIO_SET_ERROR if (pvio->set_error) \

include/mysql.h

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ extern unsigned int mariadb_deinitialize_ssl;
205205
MYSQL_OPT_CONNECT_ATTR_DELETE,
206206
MYSQL_SERVER_PUBLIC_KEY,
207207
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
208+
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
209+
MYSQL_OPT_SSL_ENFORCE,
210+
MYSQL_OPT_MAX_ALLOWED_PACKET,
211+
MYSQL_OPT_NET_BUFFER_LENGTH,
208212

209213
/* MariaDB specific */
210214
MYSQL_PROGRESS_CALLBACK=5999,
@@ -389,16 +393,6 @@ typedef struct character_set
389393
unsigned int mbmaxlen; /* max. length for multibyte strings */
390394
} MY_CHARSET_INFO;
391395

392-
typedef struct
393-
{
394-
unsigned long *p_max_allowed_packet;
395-
unsigned long *p_net_buffer_length;
396-
void *extension;
397-
} MYSQL_PARAMETERS;
398-
399-
#define net_buffer_length (*mysql_get_parameters()->p_net_buffer_length)
400-
#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
401-
402396
/* Local infile support functions */
403397
#define LOCAL_INFILE_ERROR_LEN 512
404398

@@ -450,8 +444,6 @@ int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
450444
const char *cert, const char *ca,
451445
const char *capath, const char *cipher);
452446
const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
453-
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
454-
const char *user, const char *passwd);
455447
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
456448
const char *passwd, const char *db);
457449
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
@@ -469,8 +461,6 @@ int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
469461
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
470462
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
471463
size_t length);
472-
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
473-
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
474464
int STDCALL mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level);
475465
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
476466
int STDCALL mysql_refresh(MYSQL *mysql,
@@ -528,7 +518,6 @@ size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, CHARSE
528518
int STDCALL mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...);
529519
int STDCALL mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...);
530520
int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option, void *arg);
531-
MYSQL_PARAMETERS *STDCALL mysql_get_parameters(void);
532521
unsigned long STDCALL mysql_hex_string(char *to, const char *from, size_t len);
533522
my_socket STDCALL mysql_get_socket(MYSQL *mysql);
534523
unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql);
@@ -675,7 +664,6 @@ struct st_mariadb_api {
675664
MYSQL * (STDCALL *mysql_init)(MYSQL *mysql);
676665
int (STDCALL *mysql_ssl_set)(MYSQL *mysql, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher);
677666
const char * (STDCALL *mysql_get_ssl_cipher)(MYSQL *mysql);
678-
MYSQL * (STDCALL *mysql_connect)(MYSQL *mysql, const char *host, const char *user, const char *passwd);
679667
my_bool (STDCALL *mysql_change_user)(MYSQL *mysql, const char *user, const char *passwd, const char *db);
680668
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);
681669
void (STDCALL *mysql_close)(MYSQL *sock);
@@ -684,8 +672,6 @@ struct st_mariadb_api {
684672
int (STDCALL *mysql_send_query)(MYSQL *mysql, const char *q, size_t length);
685673
my_bool (STDCALL *mysql_read_query_result)(MYSQL *mysql);
686674
int (STDCALL *mysql_real_query)(MYSQL *mysql, const char *q, size_t length);
687-
int (STDCALL *mysql_create_db)(MYSQL *mysql, const char *DB);
688-
int (STDCALL *mysql_drop_db)(MYSQL *mysql, const char *DB);
689675
int (STDCALL *mysql_shutdown)(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level);
690676
int (STDCALL *mysql_dump_debug_info)(MYSQL *mysql);
691677
int (STDCALL *mysql_refresh)(MYSQL *mysql, unsigned int refresh_options);
@@ -732,7 +718,6 @@ struct st_mariadb_api {
732718
int (STDCALL *mysql_optionsv)(MYSQL *mysql,enum mysql_option option, ...);
733719
int (STDCALL *mysql_get_optionv)(MYSQL *mysql, enum mysql_option option, void *arg, ...);
734720
int (STDCALL *mysql_get_option)(MYSQL *mysql, enum mysql_option option, void *arg);
735-
MYSQL_PARAMETERS *(STDCALL *mysql_get_parameters)(void);
736721
unsigned long (STDCALL *mysql_hex_string)(char *to, const char *from, size_t len);
737722
my_socket (STDCALL *mysql_get_socket)(MYSQL *mysql);
738723
unsigned int (STDCALL *mysql_get_timeout_value)(const MYSQL *mysql);

libmariadb/libmariadb.c

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
#undef net_buffer_length
8181
extern ulong max_allowed_packet; /* net.c */
8282
extern ulong net_buffer_length; /* net.c */
83-
static MYSQL_PARAMETERS mariadb_internal_parameters=
84-
{&max_allowed_packet, &net_buffer_length, 0};
8583

8684
static my_bool mysql_client_init=0;
8785
static void mysql_close_options(MYSQL *mysql);
@@ -1212,28 +1210,6 @@ mysql_get_ssl_cipher(MYSQL *mysql)
12121210
** NB! Errors are not reported until you do mysql_real_connect.
12131211
**************************************************************************/
12141212

1215-
/**************************************************************************
1216-
** Connect to sql server
1217-
** If host == 0 then use localhost
1218-
**************************************************************************/
1219-
1220-
MYSQL * STDCALL
1221-
mysql_connect(MYSQL *mysql,const char *host,
1222-
const char *user, const char *passwd)
1223-
{
1224-
MYSQL *res;
1225-
mysql=mysql_init(mysql); /* Make it thread safe */
1226-
{
1227-
DBUG_ENTER("mysql_connect");
1228-
if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0)))
1229-
{
1230-
if (mysql->free_me)
1231-
my_free(mysql);
1232-
}
1233-
DBUG_RETURN(res);
1234-
}
1235-
}
1236-
12371213
uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer)
12381214
{
12391215
if (mysql->server_capabilities & CLIENT_CONNECT_ATTRS)
@@ -2509,24 +2485,6 @@ mysql_list_processes(MYSQL *mysql)
25092485
DBUG_RETURN(mysql_store_result(mysql));
25102486
}
25112487

2512-
2513-
int STDCALL
2514-
mysql_create_db(MYSQL *mysql, const char *db)
2515-
{
2516-
DBUG_ENTER("mysql_createdb");
2517-
DBUG_PRINT("enter",("db: %s",db));
2518-
DBUG_RETURN(simple_command(mysql, COM_CREATE_DB,db, (uint) strlen(db),0,0));
2519-
}
2520-
2521-
2522-
int STDCALL
2523-
mysql_drop_db(MYSQL *mysql, const char *db)
2524-
{
2525-
DBUG_ENTER("mysql_drop_db");
2526-
DBUG_PRINT("enter",("db: %s",db));
2527-
DBUG_RETURN(simple_command(mysql, COM_DROP_DB,db,(uint) strlen(db),0,0));
2528-
}
2529-
25302488
/* In 5.0 this version became an additional parameter shutdown_level */
25312489
int STDCALL
25322490
mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level)
@@ -2820,7 +2778,15 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
28202778
if (mysql->net.pvio)
28212779
mysql->net.pvio->async_context= ctxt;
28222780
break;
2823-
2781+
case MYSQL_OPT_MAX_ALLOWED_PACKET:
2782+
if (mysql)
2783+
mysql->options.max_allowed_packet= (*(size_t *)arg1);
2784+
else
2785+
max_allowed_packet= (*(size_t *)arg1);
2786+
break;
2787+
case MYSQL_OPT_NET_BUFFER_LENGTH:
2788+
net_buffer_length= (*(size_t *)arg1);
2789+
break;
28242790
case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
28252791
if (*(my_bool *)arg1)
28262792
mysql->options.client_flag |= CLIENT_SSL_VERIFY_SERVER_CERT;
@@ -3172,6 +3138,13 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
31723138
}
31733139
}
31743140
break;
3141+
case MYSQL_OPT_MAX_ALLOWED_PACKET:
3142+
*((unsigned long *)arg)= (mysql) ? mysql->options.max_allowed_packet :
3143+
max_allowed_packet;
3144+
break;
3145+
case MYSQL_OPT_NET_BUFFER_LENGTH:
3146+
*((unsigned long *)arg)= net_buffer_length;
3147+
break;
31753148
case MYSQL_SECURE_AUTH:
31763149
*((my_bool *)arg)= mysql->options.secure_auth;
31773150
break;
@@ -3583,12 +3556,6 @@ mysql_get_server_name(MYSQL *mysql)
35833556
return mariadb_connection(mysql) ? "MariaDB" : "MySQL";
35843557
}
35853558

3586-
MYSQL_PARAMETERS *STDCALL
3587-
mysql_get_parameters(void)
3588-
{
3589-
return &mariadb_internal_parameters;
3590-
}
3591-
35923559
static my_socket mariadb_get_socket(MYSQL *mysql)
35933560
{
35943561
my_socket sock= INVALID_SOCKET;
@@ -3897,7 +3864,6 @@ struct st_mariadb_api MARIADB_API=
38973864
mysql_init,
38983865
mysql_ssl_set,
38993866
mysql_get_ssl_cipher,
3900-
mysql_connect,
39013867
mysql_change_user,
39023868
mysql_real_connect,
39033869
mysql_close,
@@ -3906,8 +3872,6 @@ struct st_mariadb_api MARIADB_API=
39063872
mysql_send_query,
39073873
mysql_read_query_result,
39083874
mysql_real_query,
3909-
mysql_create_db,
3910-
mysql_drop_db,
39113875
mysql_shutdown,
39123876
mysql_dump_debug_info,
39133877
mysql_refresh,
@@ -3954,7 +3918,6 @@ struct st_mariadb_api MARIADB_API=
39543918
mysql_optionsv,
39553919
mysql_get_optionv,
39563920
mysql_get_option,
3957-
mysql_get_parameters,
39583921
mysql_hex_string,
39593922
mysql_get_socket,
39603923
mysql_get_timeout_value,

0 commit comments

Comments
 (0)