1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Merge branch 'master' into serg-integr

This commit is contained in:
Vladislav Vaintroub
2016-09-12 11:47:14 +00:00
55 changed files with 772 additions and 587 deletions

View File

@@ -362,7 +362,7 @@ mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg,
if (multi == MARIADB_COM_MULTI_BEGIN)
{
/* todo: error handling */
return(net_add_multi_command(&mysql->net, command, arg, length));
return(net_add_multi_command(&mysql->net, command, (uchar *)arg, length));
}
if (mysql->net.pvio == 0)
@@ -556,7 +556,7 @@ enum enum_option_type {
struct st_default_options {
enum mysql_option option;
enum enum_option_type type;
char *conf_key;
const char *conf_key;
};
struct st_default_options mariadb_defaults[] =
@@ -715,7 +715,7 @@ static size_t rset_field_offsets[]= {
MYSQL_FIELD *
unpack_fields(MYSQL_DATA *data,MA_MEM_ROOT *alloc,uint fields,
my_bool default_value, my_bool long_flag_protocol)
my_bool default_value, my_bool long_flag_protocol __attribute__((unused)))
{
MYSQL_ROWS *row;
MYSQL_FIELD *field,*result;
@@ -1005,11 +1005,11 @@ mysql_get_ssl_cipher(MYSQL *mysql)
** NB! Errors are not reported until you do mysql_real_connect.
**************************************************************************/
uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer)
char *ma_send_connect_attr(MYSQL *mysql, unsigned char *buffer)
{
if (mysql->server_capabilities & CLIENT_CONNECT_ATTRS)
{
buffer= mysql_net_store_length((unsigned char *)buffer, (mysql->options.extension) ?
buffer= (unsigned char *)mysql_net_store_length((unsigned char *)buffer, (mysql->options.extension) ?
mysql->options.extension->connect_attrs_len : 0);
if (mysql->options.extension &&
hash_inited(&mysql->options.extension->connect_attrs))
@@ -1025,14 +1025,14 @@ uchar *ma_send_connect_attr(MYSQL *mysql, uchar *buffer)
memcpy(buffer, p, len);
buffer+= (len);
p+= (len + 1);
len= strlen(p);
len= strlen((char *)p);
buffer= mysql_net_store_length(buffer, len);
memcpy(buffer, p, len);
buffer+= len;
}
}
}
return buffer;
return (char *)buffer;
}
/** set some default attributes */
@@ -1223,8 +1223,15 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
else
#endif
#else
if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY ||
mysql->options.shared_memory_base_name)
{
cinfo.host= mysql->options.shared_memory_base_name;
cinfo.type= PVIO_TYPE_SHAREDMEM;
sprintf(host_info=buff,ER(CR_SHARED_MEMORY_CONNECTION), cinfo.host ? cinfo.host : SHM_DEFAULT_NAME);
}
/* named pipe */
if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
else if (mysql->options.protocol == MYSQL_PROTOCOL_PIPE ||
(host && strcmp(host,LOCAL_HOST_NAMEDPIPE) == 0))
{
cinfo.type= PVIO_TYPE_NAMEDPIPE;
@@ -2095,7 +2102,7 @@ mysql_real_query(MYSQL *mysql, const char *query, size_t length)
if (OPT_HAS_EXT_VAL(mysql, multi_command))
is_multi= mysql->options.extension->multi_command;
if (length == -1)
if (length == (size_t)-1)
length= strlen(query);
free_old_query(mysql);
@@ -2541,7 +2548,7 @@ uchar *ma_get_hash_keyval(const uchar *hash_entry,
key_length + 1 value (\0 terminated)
*/
uchar *p= (uchar *)hash_entry;
size_t len= strlen(p);
size_t len= strlen((char *)p);
*length= (unsigned int)len;
return p;
}
@@ -2556,20 +2563,23 @@ int mariadb_flush_multi_command(MYSQL *mysql)
int rc;
size_t length= mysql->net.extension->mbuff_pos - mysql->net.extension->mbuff;
rc= ma_simple_command(mysql, COM_MULTI, mysql->net.extension->mbuff,
rc= ma_simple_command(mysql, COM_MULTI, (char *)mysql->net.extension->mbuff,
length, 1, 0);
/* reset multi_buff */
mysql->net.extension->mbuff_pos= mysql->net.extension->mbuff;
/* don't read result for mysql_stmt_execute_direct() */
if (!rc)
if (mysql->net.extension->mbuff && length > 3 &&
(mysql->net.extension->mbuff[3] == COM_STMT_PREPARE ||
mysql->net.extension->mbuff[3] == COM_STMT_EXECUTE ||
mysql->net.extension->mbuff[3] == COM_STMT_CLOSE))
{
uchar *p= (uchar *)mysql->net.extension->mbuff;
unsigned long len= net_field_length(&p);
if (len && (*p == COM_STMT_PREPARE ||
*p == COM_STMT_EXECUTE ||
*p == COM_STMT_CLOSE))
return rc;
else
return mysql->methods->db_read_query_result(mysql);
}
return rc;
}
@@ -2623,6 +2633,11 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
case MYSQL_OPT_PROTOCOL:
mysql->options.protocol= *((uint *)arg1);
break;
#ifdef _WIN32
case MYSQL_SHARED_MEMORY_BASE_NAME:
OPT_SET_VALUE_STR(&mysql->options, shared_memory_base_name, arg1);
break;
#endif
case MYSQL_OPT_READ_TIMEOUT:
mysql->options.read_timeout= *(uint *)arg1;
break;
@@ -2732,10 +2747,10 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
arg1 ? (uint)strlen((char *)arg1) : 0)))
{
uchar *p= h;
size_t key_len= strlen(p);
size_t key_len= strlen((char *)p);
mysql->options.extension->connect_attrs_len-= key_len + get_store_length(key_len);
p+= key_len + 1;
key_len= strlen(p);
key_len= strlen((char *)p);
mysql->options.extension->connect_attrs_len-= key_len + get_store_length(key_len);
hash_delete(&mysql->options.extension->connect_attrs, h);
}
@@ -2808,8 +2823,10 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
}
}
/* check if key is already in buffer */
if (p= (uchar *)hash_search(&mysql->options.extension->userdata, (uchar *)key,
(uint)strlen((char *)key)))
p= (uchar *)hash_search(&mysql->options.extension->userdata,
(uchar *)key,
(uint)strlen(key));
if (p)
{
p+= strlen(key) + 1;
memcpy(p, &data, sizeof(void *));
@@ -2823,7 +2840,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
}
p= buffer;
strcpy(p, key);
strcpy((char *)p, key);
p+= strlen(key) + 1;
memcpy(p, &data, sizeof(void *));
@@ -2870,10 +2887,10 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
if ((buffer= (uchar *)malloc(key_len + value_len)))
{
uchar *p= buffer;
strcpy(p, arg1);
strcpy((char *)p, arg1);
p+= (strlen(arg1) + 1);
if (arg2)
strcpy(p, arg2);
strcpy((char *)p, arg2);
if (hash_insert(&mysql->options.extension->connect_attrs, buffer))
{
@@ -3003,7 +3020,7 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
break;
case MYSQL_SET_CHARSET_NAME:
if (mysql->charset)
*((char **)arg)= mysql->charset->csname;
*((const char **)arg)= mysql->charset->csname;
else
*((char **)arg)= mysql->options.charset_name;
break;
@@ -3074,7 +3091,7 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
case MYSQL_OPT_CONNECT_ATTRS:
/* mysql_get_optionsv(mysql, MYSQL_OPT_CONNECT_ATTRS, keys, vals, elements) */
{
int i, *elements;
unsigned int i, *elements;
char **key= NULL;
void *arg1;
char **val= NULL;
@@ -3106,10 +3123,10 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
{
uchar *p= hash_element(&mysql->options.extension->connect_attrs, i);
if (key)
key[i]= p;
p+= strlen(p) + 1;
key[i]= (char *)p;
p+= strlen((char *)p) + 1;
if (val)
val[i]= p;
val[i]= (char *)p;
}
}
}
@@ -3198,7 +3215,7 @@ mysql_options4(MYSQL *mysql,enum mysql_option option, const void *arg1, const vo
****************************************************************************/
/* MYSQL_RES */
unsigned long long STDCALL mysql_num_rows(MYSQL_RES *res)
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res)
{
return res->row_count;
}
@@ -3241,7 +3258,7 @@ unsigned int STDCALL mysql_field_count(MYSQL *mysql)
return mysql->field_count;
}
unsigned long long STDCALL mysql_affected_rows(MYSQL *mysql)
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql)
{
return (mysql)->affected_rows;
}
@@ -3262,7 +3279,7 @@ my_bool STDCALL mysql_rollback(MYSQL *mysql)
return((my_bool)mysql_real_query(mysql, "ROLLBACK", sizeof("ROLLBACK")));
}
unsigned long long STDCALL mysql_insert_id(MYSQL *mysql)
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
{
return (mysql)->insert_id;
}
@@ -3274,7 +3291,7 @@ uint STDCALL mysql_errno(MYSQL *mysql)
char * STDCALL mysql_error(MYSQL *mysql)
{
return mysql ? (mysql)->net.last_error : "";
return mysql ? (mysql)->net.last_error : (char *)"";
}
char *STDCALL mysql_info(MYSQL *mysql)
@@ -3655,18 +3672,18 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
case MARIADB_TLS_LIBRARY:
#ifdef HAVE_TLS
#ifdef HAVE_GNUTLS
*((char **)arg)= "GNUTLS";
*((const char **)arg)= "GNUTLS";
#elif HAVE_OPENSSL
*((char **)arg)= "OPENSSL";
*((const char **)arg)= "OPENSSL";
#elif HAVE_SCHANNEL
*((char **)arg)= "SCHANNEL";
*((const char **)arg)= "SCHANNEL";
#endif
#else
*((char **)arg)= "OFF";
#endif
break;
case MARIADB_CLIENT_VERSION:
*((char **)arg)= MARIADB_CLIENT_VERSION_STR;
*((const char **)arg)= MARIADB_CLIENT_VERSION_STR;
break;
case MARIADB_CLIENT_VERSION_ID:
*((size_t *)arg)= MARIADB_VERSION_ID;
@@ -3679,7 +3696,7 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
break;
case MARIADB_CONNECTION_SERVER_TYPE:
if (mysql)
*((char **)arg)= mariadb_connection(mysql) ? "MariaDB" : "MySQL";
*((const char **)arg)= mariadb_connection(mysql) ? "MariaDB" : "MySQL";
else
goto error;
break;