You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
10.2 integration fixes
- changed plugin API to avoid crashes: Oracle/MariaDB changed structure several times without updating interface version. - ABI fixes: moved additional net items to net->extension (connection handler and com_multi buffer)
This commit is contained in:
@@ -62,6 +62,19 @@ struct st_mysql_options_extension {
|
||||
HASH userdata;
|
||||
};
|
||||
|
||||
typedef struct st_connection_handler
|
||||
{
|
||||
struct st_ma_connection_plugin *plugin;
|
||||
void *data;
|
||||
my_bool active;
|
||||
my_bool free_data;
|
||||
} MA_CONNECTION_HANDLER;
|
||||
|
||||
struct st_mariadb_net_extension {
|
||||
unsigned char *mbuff, *mbuff_end, *mbuff_pos;
|
||||
MA_CONNECTION_HANDLER *conn_hdlr;
|
||||
};
|
||||
|
||||
#define OPT_HAS_EXT_VAL(a,key) \
|
||||
((a)->options.extension && (a)->options.extension->key)
|
||||
|
||||
|
@@ -179,6 +179,8 @@ extern MARIADB_CHARSET_INFO *get_charset(uint cs_number, myf flags);
|
||||
extern MARIADB_CHARSET_INFO *get_charset_by_name(const char *cs_name);
|
||||
extern MARIADB_CHARSET_INFO *get_charset_by_nr(uint cs_number);
|
||||
|
||||
/* string functions */
|
||||
char *ma_strmake(register char *dst, register const char *src, size_t length);
|
||||
|
||||
/* statistics */
|
||||
#ifdef TBR
|
||||
|
@@ -246,19 +246,11 @@ typedef struct st_ma_pvio MARIADB_PVIO;
|
||||
|
||||
struct st_ma_connection_plugin;
|
||||
|
||||
typedef struct st_connection_handler
|
||||
{
|
||||
struct st_ma_connection_plugin *plugin;
|
||||
void *data;
|
||||
my_bool active;
|
||||
my_bool free_data;
|
||||
} MA_CONNECTION_HANDLER;
|
||||
|
||||
typedef struct st_net {
|
||||
MARIADB_PVIO *pvio;
|
||||
unsigned char *buff;
|
||||
unsigned char *buff_end,*write_pos,*read_pos;
|
||||
unsigned char *mbuff, *mbuff_end, *mbuff_pos;
|
||||
my_socket fd; /* For Perl DBI/dbd */
|
||||
unsigned long remain_in_buf,length;
|
||||
unsigned long buf_length, where_b;
|
||||
@@ -269,18 +261,18 @@ typedef struct st_net {
|
||||
unsigned int *return_status;
|
||||
unsigned char reading_or_writing;
|
||||
char save_char;
|
||||
my_bool unused_1, unused_2;
|
||||
char unused_1;
|
||||
my_bool unused_2;
|
||||
my_bool compress;
|
||||
my_bool unused_3;
|
||||
MA_CONNECTION_HANDLER *conn_hdlr;
|
||||
void *unused_4;
|
||||
unsigned int last_errno;
|
||||
unsigned char error;
|
||||
my_bool unused_4;
|
||||
my_bool unused_5;
|
||||
|
||||
my_bool unused_6;
|
||||
char last_error[MYSQL_ERRMSG_SIZE];
|
||||
char sqlstate[SQLSTATE_LENGTH+1];
|
||||
void *extension;
|
||||
struct st_mariadb_net_extension *extension;
|
||||
} NET;
|
||||
|
||||
#define packet_error ((unsigned int) -1)
|
||||
|
@@ -424,8 +424,10 @@ typedef struct character_set
|
||||
const char *desc; \
|
||||
unsigned int version[3]; \
|
||||
const char *license; \
|
||||
void *mariadb_api; \
|
||||
int (*init)(char *, size_t, int, va_list); \
|
||||
int (*deinit)();
|
||||
int (*deinit)(); \
|
||||
int (*options)(const char *option, const void *);
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
|
@@ -76,8 +76,10 @@
|
||||
const char *desc; \
|
||||
unsigned int version[3]; \
|
||||
const char *license; \
|
||||
void *mysql_api; \
|
||||
int (*init)(char *, size_t, int, va_list); \
|
||||
int (*deinit)();
|
||||
int (*deinit)(); \
|
||||
int (*options)(const char *option, const void *);
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
@@ -94,7 +96,7 @@ typedef struct st_ma_connection_plugin
|
||||
MYSQL *(*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 (*close)(MYSQL *mysql);
|
||||
int (*options)(MYSQL *mysql, enum mysql_option, void *arg);
|
||||
int (*set_options)(MYSQL *mysql, enum mysql_option, void *arg);
|
||||
int (*set_connection)(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
size_t length, my_bool skipp_check, void *opt_arg);
|
||||
my_bool (*reconnect)(MYSQL *mysql);
|
||||
|
@@ -258,12 +258,12 @@ ma_alloc.c
|
||||
ma_compress.c
|
||||
ma_init.c
|
||||
ma_password.c
|
||||
ma_string.c
|
||||
ma_ll2str.c
|
||||
ma_sha1.c
|
||||
mariadb_stmt.c
|
||||
ma_loaddata.c
|
||||
ma_stmt_codec.c
|
||||
ma_string.c
|
||||
${CMAKE_BINARY_DIR}/libmariadb/ma_client_plugin.c
|
||||
ma_io.c
|
||||
${SSL_SOURCES}
|
||||
|
@@ -84,7 +84,7 @@ int mysql_local_infile_init(void **ptr, const char *filename, void *userdata)
|
||||
if (mysql_errno(mysql) && !info->error_no)
|
||||
{
|
||||
info->error_no= mysql_errno(mysql);
|
||||
strncpy(info->error_msg, mysql_error(mysql), MYSQL_ERRMSG_SIZE);
|
||||
ma_strmake(info->error_msg, mysql_error(mysql), MYSQL_ERRMSG_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -127,11 +127,11 @@ int mysql_local_infile_error(void *ptr, char *error_buf, unsigned int error_buf_
|
||||
MYSQL_INFILE_INFO *info = (MYSQL_INFILE_INFO *)ptr;
|
||||
|
||||
if (info) {
|
||||
strncpy(error_buf, info->error_msg, error_buf_len);
|
||||
ma_strmake(error_buf, info->error_msg, error_buf_len);
|
||||
return(info->error_no);
|
||||
}
|
||||
|
||||
strncpy(error_buf, "Unknown error", error_buf_len);
|
||||
ma_strmake(error_buf, "Unknown error", error_buf_len);
|
||||
return(CR_UNKNOWN_ERROR);
|
||||
}
|
||||
/* }}} */
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <ma_pvio.h>
|
||||
#include <ma_common.h>
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#endif
|
||||
@@ -103,6 +104,11 @@ int ma_net_init(NET *net, MARIADB_PVIO* pvio)
|
||||
if (!(net->buff=(uchar*) calloc(1, net_buffer_length)))
|
||||
return 1;
|
||||
|
||||
if (!net->extension)
|
||||
{
|
||||
printf("Fatal\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* We don't allocate memory for multi buffer, since we don't know in advance if the server
|
||||
* supports COM_MULTI comand. It will be allocated on demand in net_add_multi_command */
|
||||
max_allowed_packet= net->max_packet_size= MAX(net_buffer_length, max_allowed_packet);
|
||||
@@ -130,9 +136,9 @@ int ma_net_init(NET *net, MARIADB_PVIO* pvio)
|
||||
void ma_net_end(NET *net)
|
||||
{
|
||||
free(net->buff);
|
||||
free(net->mbuff);
|
||||
free(net->extension->mbuff);
|
||||
net->buff=0;
|
||||
net->mbuff= 0;
|
||||
net->extension->mbuff= 0;
|
||||
}
|
||||
|
||||
/* Realloc the packet buffer */
|
||||
@@ -151,7 +157,7 @@ static my_bool net_realloc(NET *net, my_bool is_multi, size_t length)
|
||||
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
|
||||
/* reallocate buffer:
|
||||
size= pkt_length + NET_HEADER_SIZE + COMP_HEADER_SIZE */
|
||||
if (!(buff=(uchar*) realloc(is_multi ? net->mbuff : net->buff,
|
||||
if (!(buff=(uchar*) realloc(is_multi ? net->extension->mbuff : net->buff,
|
||||
pkt_length + NET_HEADER_SIZE + COMP_HEADER_SIZE)))
|
||||
{
|
||||
net->error=1;
|
||||
@@ -164,8 +170,8 @@ static my_bool net_realloc(NET *net, my_bool is_multi, size_t length)
|
||||
}
|
||||
else
|
||||
{
|
||||
net->mbuff=net->mbuff_pos=buff;
|
||||
net->mbuff_end=buff+(net->max_packet=(unsigned long)pkt_length);
|
||||
net->extension->mbuff=net->extension->mbuff_pos=buff;
|
||||
net->extension->mbuff_end=buff+(net->max_packet=(unsigned long)pkt_length);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -178,8 +184,8 @@ void ma_net_clear(NET *net)
|
||||
ma_pvio_has_data(net->pvio, &len); */
|
||||
net->compress_pkt_nr= net->pkt_nr=0; /* Ready for new command */
|
||||
net->write_pos=net->buff;
|
||||
if (net->mbuff)
|
||||
net->mbuff_pos= net->mbuff;
|
||||
if (net->extension->mbuff)
|
||||
net->extension->mbuff_pos= net->extension->mbuff;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,42 +332,42 @@ int net_add_multi_command(NET *net, uchar command, const uchar *packet,
|
||||
|
||||
/* We didn't allocate memory in ma_net_init since it was to early to
|
||||
* detect if the server supports COM_MULTI command */
|
||||
if (!net->mbuff)
|
||||
if (!net->extension->mbuff)
|
||||
{
|
||||
size_t alloc_size= (required_length + IO_SIZE - 1) & ~(IO_SIZE - 1);
|
||||
if (!(net->mbuff= (char *)malloc(alloc_size)))
|
||||
if (!(net->extension->mbuff= (char *)malloc(alloc_size)))
|
||||
{
|
||||
net->last_errno=ER_OUT_OF_RESOURCES;
|
||||
net->error=2;
|
||||
net->reading_or_writing=0;
|
||||
return(1);
|
||||
}
|
||||
net->mbuff_pos= net->mbuff;
|
||||
net->mbuff_end= net->mbuff + alloc_size;
|
||||
net->extension->mbuff_pos= net->extension->mbuff;
|
||||
net->extension->mbuff_end= net->extension->mbuff + alloc_size;
|
||||
}
|
||||
|
||||
left_length= net->mbuff_end - net->mbuff_pos;
|
||||
left_length= net->extension->mbuff_end - net->extension->mbuff_pos;
|
||||
|
||||
/* check if our buffer is large enough */
|
||||
if (left_length < required_length)
|
||||
{
|
||||
current_length= net->mbuff_pos - net->mbuff;
|
||||
current_length= net->extension->mbuff_pos - net->extension->mbuff;
|
||||
if (net_realloc(net, 1, current_length + required_length))
|
||||
goto error;
|
||||
}
|
||||
int3store(net->mbuff_pos, length + 1);
|
||||
net->mbuff_pos+= 3;
|
||||
*net->mbuff_pos= command;
|
||||
net->mbuff_pos++;
|
||||
memcpy(net->mbuff_pos, packet, length);
|
||||
net->mbuff_pos+= length;
|
||||
int3store(net->extension->mbuff_pos, length + 1);
|
||||
net->extension->mbuff_pos+= 3;
|
||||
*net->extension->mbuff_pos= command;
|
||||
net->extension->mbuff_pos++;
|
||||
memcpy(net->extension->mbuff_pos, packet, length);
|
||||
net->extension->mbuff_pos+= length;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (net->mbuff)
|
||||
if (net->extension->mbuff)
|
||||
{
|
||||
free(net->mbuff);
|
||||
net->mbuff= net->mbuff_pos= net->mbuff_end= 0;
|
||||
free(net->extension->mbuff);
|
||||
net->extension->mbuff= net->extension->mbuff_pos= net->extension->mbuff_end= 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@@ -124,4 +124,11 @@ void ma_dynstr_free(DYNAMIC_STRING *str)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *ma_strmake(register char *dst, register const char *src, size_t length)
|
||||
{
|
||||
while (length--)
|
||||
if (! (*dst++ = *src++))
|
||||
return dst-1;
|
||||
*dst=0;
|
||||
return dst;
|
||||
}
|
||||
|
@@ -136,7 +136,7 @@ struct st_mariadb_methods MARIADB_DEFAULT_METHODS;
|
||||
#define native_password_plugin_name "mysql_native_password"
|
||||
|
||||
#define IS_CONNHDLR_ACTIVE(mysql)\
|
||||
(((mysql)->net.conn_hdlr))
|
||||
(((mysql)->net.extension->conn_hdlr))
|
||||
|
||||
static void end_server(MYSQL *mysql);
|
||||
static void mysql_close_memory(MYSQL *mysql);
|
||||
@@ -226,14 +226,14 @@ restart:
|
||||
net->last_errno= last_errno;
|
||||
if (pos[0]== '#')
|
||||
{
|
||||
strncpy(net->sqlstate, pos+1, SQLSTATE_LENGTH);
|
||||
ma_strmake(net->sqlstate, pos+1, SQLSTATE_LENGTH);
|
||||
pos+= SQLSTATE_LENGTH + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(net->sqlstate, SQLSTATE_UNKNOWN);
|
||||
}
|
||||
strncpy(net->last_error,(char*) pos,
|
||||
ma_strmake(net->last_error,(char*) pos,
|
||||
min(len,sizeof(net->last_error)-1));
|
||||
}
|
||||
else
|
||||
@@ -387,7 +387,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg,
|
||||
|
||||
if (IS_CONNHDLR_ACTIVE(mysql))
|
||||
{
|
||||
result= mysql->net.conn_hdlr->plugin->set_connection(mysql, command, arg, length, skipp_check, opt_arg);
|
||||
result= mysql->net.extension->conn_hdlr->plugin->set_connection(mysql, command, arg, length, skipp_check, opt_arg);
|
||||
if (result== -1)
|
||||
return(result);
|
||||
}
|
||||
@@ -467,11 +467,11 @@ void read_user_name(char *name)
|
||||
!(str=getenv("LOGIN")))
|
||||
str="UNKNOWN_USER";
|
||||
}
|
||||
strncpy(name,str,USERNAME_LENGTH);
|
||||
ma_strmake(name,str,USERNAME_LENGTH);
|
||||
#elif HAVE_CUSERID
|
||||
(void) cuserid(name);
|
||||
#else
|
||||
strncpy(name,"UNKNOWN_USER", USERNAME_LENGTH);
|
||||
ma_strmake(name,"UNKNOWN_USER", USERNAME_LENGTH);
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
@@ -482,7 +482,7 @@ void read_user_name(char *name)
|
||||
void read_user_name(char *name)
|
||||
{
|
||||
char *str=getenv("USERNAME"); /* ODBC will send user variable */
|
||||
strncpy(name,str ? str : "ODBC", USERNAME_LENGTH);
|
||||
ma_strmake(name,str ? str : "ODBC", USERNAME_LENGTH);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -582,6 +582,7 @@ struct st_default_options mariadb_defaults[] =
|
||||
{MYSQL_OPT_SSL_CERT, MARIADB_OPTION_STR,"ssl-cert"},
|
||||
{MYSQL_OPT_SSL_CA, MARIADB_OPTION_STR,"ssl-ca"},
|
||||
{MYSQL_OPT_SSL_CAPATH, MARIADB_OPTION_STR,"ssl-capath"},
|
||||
{MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MARIADB_OPTION_BOOL,"ssl-verify-server-cert"},
|
||||
{MYSQL_SET_CHARSET_DIR, MARIADB_OPTION_STR, "character-sets-dir"},
|
||||
{MYSQL_SET_CHARSET_NAME, MARIADB_OPTION_STR, "default-character-set"},
|
||||
{MARIADB_OPT_INTERACTIVE, MARIADB_OPTION_NONE, "interactive-timeout"},
|
||||
@@ -936,9 +937,38 @@ mysql_init(MYSQL *mysql)
|
||||
return 0;
|
||||
mysql->free_me=1;
|
||||
mysql->net.pvio= 0;
|
||||
mysql->net.extension= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset((char*) (mysql), 0, sizeof(*(mysql)));
|
||||
mysql->net.pvio= 0;
|
||||
mysql->net.extension= 0;
|
||||
}
|
||||
|
||||
if (!(mysql->net.extension= (struct st_mariadb_net_extension *)
|
||||
calloc(1, sizeof(struct st_mariadb_net_extension))))
|
||||
{
|
||||
if (mysql->free_me)
|
||||
free(mysql);
|
||||
return 0;
|
||||
}
|
||||
mysql->options.report_data_truncation= 1;
|
||||
mysql->options.connect_timeout=CONNECT_TIMEOUT;
|
||||
mysql->charset= ma_default_charset_info;
|
||||
mysql->methods= &MARIADB_DEFAULT_METHODS;
|
||||
strcpy(mysql->net.sqlstate, "00000");
|
||||
mysql->net.last_error[0]= mysql->net.last_errno= 0;
|
||||
|
||||
/*
|
||||
}
|
||||
if (!(mysql->net.extension= (struct st_mariadb_net_extension *)
|
||||
calloc(1, sizeof(struct st_mariadb_net_extension))))
|
||||
{
|
||||
if (mysql->free_me)
|
||||
free(mysql);
|
||||
return 0;
|
||||
}
|
||||
mysql->options.report_data_truncation= 1;
|
||||
mysql->options.connect_timeout=CONNECT_TIMEOUT;
|
||||
mysql->charset= ma_default_charset_info;
|
||||
@@ -1081,16 +1111,16 @@ mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
|
||||
if (!connection_handler || !connection_handler[0])
|
||||
{
|
||||
memset(plugin_name, 0, 64);
|
||||
strncpy(plugin_name, host, MIN(end - host, 63));
|
||||
ma_strmake(plugin_name, host, MIN(end - host, 63));
|
||||
end+= 3;
|
||||
}
|
||||
else
|
||||
strncpy(plugin_name, connection_handler, MIN(63, strlen(connection_handler)));
|
||||
ma_strmake(plugin_name, connection_handler, MIN(63, strlen(connection_handler)));
|
||||
|
||||
if (!(plugin= (MARIADB_CONNECTION_PLUGIN *)mysql_client_find_plugin(mysql, plugin_name, MARIADB_CLIENT_CONNECTION_PLUGIN)))
|
||||
return NULL;
|
||||
|
||||
if (!(mysql->net.conn_hdlr= (MA_CONNECTION_HANDLER *)calloc(1, sizeof(MA_CONNECTION_HANDLER))))
|
||||
if (!(mysql->net.extension->conn_hdlr= (MA_CONNECTION_HANDLER *)calloc(1, sizeof(MA_CONNECTION_HANDLER))))
|
||||
{
|
||||
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
||||
return NULL;
|
||||
@@ -1099,15 +1129,15 @@ mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
|
||||
/* save URL for reconnect */
|
||||
OPT_SET_EXTENDED_VALUE_STR(&mysql->options, url, host);
|
||||
|
||||
mysql->net.conn_hdlr->plugin= plugin;
|
||||
mysql->net.extension->conn_hdlr->plugin= plugin;
|
||||
|
||||
if (plugin && plugin->connect)
|
||||
{
|
||||
MYSQL *my= plugin->connect(mysql, end, user, passwd, db, port, unix_socket, client_flag);
|
||||
if (!my)
|
||||
{
|
||||
free(mysql->net.conn_hdlr);
|
||||
mysql->net.conn_hdlr= NULL;
|
||||
free(mysql->net.extension->conn_hdlr);
|
||||
mysql->net.extension->conn_hdlr= NULL;
|
||||
}
|
||||
return my;
|
||||
}
|
||||
@@ -1166,6 +1196,8 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
|
||||
#ifndef DONT_USE_MYSQL_PWD
|
||||
if (!passwd)
|
||||
passwd=getenv("MYSQL_PWD"); /* get it from environment (haneke) */
|
||||
if (!passwd)
|
||||
passwd= "";
|
||||
#endif
|
||||
}
|
||||
if (!db || !db[0])
|
||||
@@ -1514,8 +1546,8 @@ my_bool STDCALL mysql_reconnect(MYSQL *mysql)
|
||||
/* check if connection handler is active */
|
||||
if (IS_CONNHDLR_ACTIVE(mysql))
|
||||
{
|
||||
if (mysql->net.conn_hdlr->plugin && mysql->net.conn_hdlr->plugin->reconnect)
|
||||
return(mysql->net.conn_hdlr->plugin->reconnect(mysql));
|
||||
if (mysql->net.extension->conn_hdlr->plugin && mysql->net.extension->conn_hdlr->plugin->reconnect)
|
||||
return(mysql->net.extension->conn_hdlr->plugin->reconnect(mysql));
|
||||
}
|
||||
|
||||
if (!mysql->options.reconnect ||
|
||||
@@ -1529,10 +1561,10 @@ my_bool STDCALL mysql_reconnect(MYSQL *mysql)
|
||||
|
||||
mysql_init(&tmp_mysql);
|
||||
tmp_mysql.options=mysql->options;
|
||||
if (mysql->net.conn_hdlr)
|
||||
if (mysql->net.extension->conn_hdlr)
|
||||
{
|
||||
tmp_mysql.net.conn_hdlr= mysql->net.conn_hdlr;
|
||||
mysql->net.conn_hdlr= 0;
|
||||
tmp_mysql.net.extension->conn_hdlr= mysql->net.extension->conn_hdlr;
|
||||
mysql->net.extension->conn_hdlr= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1803,7 +1835,7 @@ void my_set_error(MYSQL *mysql,
|
||||
va_list ap;
|
||||
|
||||
mysql->net.last_errno= error_nr;
|
||||
strncpy(mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH);
|
||||
ma_strmake(mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH);
|
||||
va_start(ap, format);
|
||||
vsnprintf(mysql->net.last_error, MYSQL_ERRMSG_SIZE,
|
||||
format ? format : ER(error_nr), ap);
|
||||
@@ -1829,9 +1861,9 @@ mysql_close(MYSQL *mysql)
|
||||
{
|
||||
if (mysql) /* Some simple safety */
|
||||
{
|
||||
if (mysql->net.conn_hdlr)
|
||||
if (mysql->net.extension->conn_hdlr)
|
||||
{
|
||||
MA_CONNECTION_HANDLER *p= mysql->net.conn_hdlr;
|
||||
MA_CONNECTION_HANDLER *p= mysql->net.extension->conn_hdlr;
|
||||
p->plugin->close(mysql);
|
||||
free(p);
|
||||
}
|
||||
@@ -1851,6 +1883,8 @@ mysql_close(MYSQL *mysql)
|
||||
|
||||
if (mysql->extension)
|
||||
free(mysql->extension);
|
||||
if (mysql->net.extension)
|
||||
free(mysql->net.extension);
|
||||
|
||||
mysql->net.pvio= 0;
|
||||
if (mysql->free_me)
|
||||
@@ -2405,16 +2439,16 @@ void ma_hash_free(void *p)
|
||||
int mariadb_flush_multi_command(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
size_t length= mysql->net.mbuff_pos - mysql->net.mbuff;
|
||||
size_t length= mysql->net.extension->mbuff_pos - mysql->net.extension->mbuff;
|
||||
|
||||
rc= ma_simple_command(mysql, COM_MULTI, mysql->net.mbuff,
|
||||
rc= ma_simple_command(mysql, COM_MULTI, mysql->net.extension->mbuff,
|
||||
length, 1, 0);
|
||||
/* reset multi_buff */
|
||||
mysql->net.mbuff_pos= mysql->net.mbuff;
|
||||
mysql->net.extension->mbuff_pos= mysql->net.extension->mbuff;
|
||||
|
||||
if (!rc)
|
||||
if (mysql->net.mbuff && length > 3 &&
|
||||
(mysql->net.mbuff[3] == COM_STMT_PREPARE || mysql->net.mbuff[3] == COM_STMT_EXECUTE))
|
||||
if (mysql->net.extension->mbuff && length > 3 &&
|
||||
(mysql->net.extension->mbuff[3] == COM_STMT_PREPARE || mysql->net.extension->mbuff[3] == COM_STMT_EXECUTE))
|
||||
return rc;
|
||||
else
|
||||
return mysql->methods->db_read_query_result(mysql);
|
||||
@@ -2774,7 +2808,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
|
||||
mysql->options.extension->multi_command != MARIADB_COM_MULTI_BEGIN)
|
||||
return(-1);
|
||||
/* reset multi_buff */
|
||||
mysql->net.mbuff_pos= mysql->net.mbuff;
|
||||
mysql->net.extension->mbuff_pos= mysql->net.extension->mbuff;
|
||||
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, multi_command, MARIADB_COM_MULTI_END);
|
||||
break;
|
||||
case MARIADB_COM_MULTI_END:
|
||||
|
@@ -115,5 +115,7 @@ struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ =
|
||||
"BSD",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
gssapi_auth_client
|
||||
};
|
||||
|
@@ -54,8 +54,10 @@ struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ =
|
||||
"Dialog Client Authentication Plugin",
|
||||
{0,1,0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
auth_dialog_init,
|
||||
NULL,
|
||||
NULL,
|
||||
auth_dialog_open
|
||||
};
|
||||
|
||||
|
@@ -68,6 +68,8 @@ struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ =
|
||||
"LGPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
clear_password_auth_client
|
||||
};
|
||||
|
||||
|
@@ -45,6 +45,8 @@ auth_plugin_t native_password_client_plugin=
|
||||
"LGPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
native_password_auth_client
|
||||
};
|
||||
|
||||
@@ -104,7 +106,7 @@ static int send_change_user_packet(MCPVIO_EXT *mpvio,
|
||||
|
||||
buff= malloc(USERNAME_LENGTH+1 + data_len+1 + NAME_LEN+1 + 2 + NAME_LEN+1 + 9 + conn_attr_len);
|
||||
|
||||
end= strncpy(buff, mysql->user, USERNAME_LENGTH) + strlen(buff) + 1;
|
||||
end= ma_strmake(buff, mysql->user, USERNAME_LENGTH) + 1;
|
||||
|
||||
if (!data_len)
|
||||
*end++= 0;
|
||||
@@ -162,6 +164,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
|
||||
/* see end= buff+32 below, fixed size of the packet is 32 bytes */
|
||||
buff= malloc(33 + USERNAME_LENGTH + data_len + NAME_LEN + NAME_LEN + conn_attr_len + 9);
|
||||
end= buff;
|
||||
|
||||
mysql->client_flag|= mysql->options.client_flag;
|
||||
mysql->client_flag|= CLIENT_CAPABILITIES;
|
||||
@@ -172,7 +175,8 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
#if defined(HAVE_SSL) && !defined(EMBEDDED_LIBRARY)
|
||||
if (mysql->options.ssl_key || mysql->options.ssl_cert ||
|
||||
mysql->options.ssl_ca || mysql->options.ssl_capath ||
|
||||
mysql->options.ssl_cipher)
|
||||
mysql->options.ssl_cipher ||
|
||||
(mysql->options.client_flag & CLIENT_SSL_VERIFY_SERVER_CERT))
|
||||
mysql->options.use_ssl= 1;
|
||||
if (mysql->options.use_ssl)
|
||||
mysql->client_flag|= CLIENT_SSL;
|
||||
@@ -190,7 +194,7 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
{
|
||||
my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
|
||||
ER(CR_SSL_CONNECTION_ERROR),
|
||||
"Server doesn't support SSL");
|
||||
"SSL is required, but the server does not support it");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -259,13 +263,13 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
#endif /* HAVE_SSL */
|
||||
|
||||
/* This needs to be changed as it's not useful with big packets */
|
||||
if (mysql->user[0])
|
||||
strncpy(end, mysql->user, USERNAME_LENGTH);
|
||||
if (mysql->user && mysql->user[0])
|
||||
ma_strmake(end, mysql->user, USERNAME_LENGTH);
|
||||
else
|
||||
read_user_name(end);
|
||||
|
||||
/* We have to handle different version of handshake here */
|
||||
end= strchr(end, '\0') + 1;
|
||||
end+= strlen(end) + 1;
|
||||
if (data_len)
|
||||
{
|
||||
if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
|
||||
@@ -287,12 +291,12 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
|
||||
/* Add database if needed */
|
||||
if (mpvio->db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
|
||||
{
|
||||
end= strncpy(end, mpvio->db, NAME_LEN) + strlen(end) + 1;
|
||||
end= ma_strmake(end, mpvio->db, NAME_LEN) + 1;
|
||||
mysql->db= strdup(mpvio->db);
|
||||
}
|
||||
|
||||
if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH)
|
||||
end= strncpy(end, mpvio->plugin->name, NAME_LEN) + strlen(end) + 1;
|
||||
end= ma_strmake(end, mpvio->plugin->name, NAME_LEN) + 1;
|
||||
|
||||
end= ma_send_connect_attr(mysql, end);
|
||||
|
||||
@@ -547,8 +551,9 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
|
||||
if (res > CR_ERROR)
|
||||
my_set_error(mysql, res, SQLSTATE_UNKNOWN, 0);
|
||||
else
|
||||
if (!mysql->net.last_errno)
|
||||
if (!mysql->net.last_errno) {
|
||||
my_set_error(mysql, CR_UNKNOWN_ERROR, SQLSTATE_UNKNOWN, 0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -587,7 +592,6 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len,
|
||||
mpvio.cached_server_reply.pkt_len= pkt_length - len - 2;
|
||||
mpvio.cached_server_reply.pkt= mysql->net.read_pos + len + 2;
|
||||
}
|
||||
|
||||
if (!(auth_plugin= (auth_plugin_t *) mysql_client_find_plugin(mysql,
|
||||
auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN)))
|
||||
return 1;
|
||||
|
@@ -54,13 +54,15 @@ struct st_mysql_client_plugin_AUTHENTICATION _mysql_client_plugin_declaration_ =
|
||||
{
|
||||
MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
|
||||
MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION,
|
||||
"old_password",
|
||||
"mysql_old_password",
|
||||
"Sergei Golubchik, R.J. Silk, Georg Richter",
|
||||
"Old (pre 4.1) authentication plugin",
|
||||
{1,0,0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
auth_old_password
|
||||
};
|
||||
|
||||
@@ -94,11 +96,11 @@ static int auth_old_password(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
|
||||
return CR_SERVER_HANDSHAKE_ERR;
|
||||
|
||||
/* save it in MYSQL */
|
||||
memcpy(mysql->scramble_buff, pkt, pkt_len);
|
||||
memmove(mysql->scramble_buff, pkt, pkt_len);
|
||||
mysql->scramble_buff[pkt_len] = 0;
|
||||
}
|
||||
|
||||
if (mysql->passwd[0])
|
||||
if (mysql && mysql->passwd[0])
|
||||
{
|
||||
char scrambled[SCRAMBLE_LENGTH_323 + 1];
|
||||
ma_scramble_323(scrambled, (char*)pkt, mysql->passwd);
|
||||
|
@@ -67,8 +67,10 @@ MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ =
|
||||
"MariaDB connection plugin for Aurora failover",
|
||||
{1, 0, 0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
aurora_init,
|
||||
NULL,
|
||||
NULL,
|
||||
aurora_connect,
|
||||
aurora_close,
|
||||
NULL,
|
||||
|
@@ -62,6 +62,8 @@ MARIADB_CONNECTION_PLUGIN _mysql_client_plugin_declaration_ =
|
||||
"LGPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
repl_connect,
|
||||
repl_close,
|
||||
repl_set_options,
|
||||
|
@@ -104,8 +104,10 @@ MARIADB_REMOTEIO_PLUGIN _mysql_client_plugin_declaration_ =
|
||||
"Remote IO plugin",
|
||||
{0,1,0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
ma_rio_init,
|
||||
ma_rio_deinit,
|
||||
NULL,
|
||||
&ma_rio_methods
|
||||
mysql_end_client_plugin;
|
||||
|
||||
|
@@ -78,6 +78,8 @@ MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_ =
|
||||
"LGPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&pvio_npipe_methods
|
||||
};
|
||||
|
||||
|
@@ -75,6 +75,8 @@ MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_=
|
||||
"LGPPL",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&pvio_shm_methods,
|
||||
|
||||
};
|
||||
|
@@ -127,8 +127,10 @@ MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_
|
||||
"MariaDB virtual IO plugin for socket communication",
|
||||
{1, 0, 0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
&pvio_socket_init,
|
||||
&pvio_socket_end,
|
||||
NULL,
|
||||
&pvio_socket_methods
|
||||
};
|
||||
|
||||
|
@@ -57,8 +57,10 @@ struct st_mysql_client_plugin _mysql_client_plugin_declaration_ =
|
||||
"Trace example plugin",
|
||||
{1,0,0},
|
||||
"LGPL",
|
||||
NULL,
|
||||
&trace_init,
|
||||
&trace_deinit
|
||||
&trace_deinit,
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *commands[]= {
|
||||
|
Reference in New Issue
Block a user