unit8_t conversion

pull/2343/head
Valentin Rakush 7 years ago
parent 1265461b5d
commit 1008b7d0c5

@ -136,7 +136,7 @@ class MySQL_Data_Stream
int switching_auth_stage;
int switching_auth_type;
uint8_t tmp_charset;
unsigned int tmp_charset;
short revents;

@ -403,7 +403,7 @@ class MySQL_Threads_Handler
char *interfaces;
char *server_version;
char *keep_multiplexing_variables;
uint8_t default_charset;
unsigned int default_charset;
bool servers_stats;
bool commands_stats;
bool query_digests;
@ -515,7 +515,7 @@ class MySQL_Threads_Handler
~MySQL_Threads_Handler();
char *get_variable_string(char *name);
uint8_t get_variable_uint8(char *name);
unsigned int get_variable_uint(char *name);
uint16_t get_variable_uint16(char *name);
int get_variable_int(const char *name);
void print_version();

@ -88,7 +88,7 @@ class MySQL_Connection {
char *ldap_user_variable_value;
bool ldap_user_variable_sent;
uint8_t protocol_version;
uint8_t charset;
unsigned int charset;
uint8_t sql_log_bin;
int8_t last_set_autocommit;
bool autocommit;
@ -149,7 +149,7 @@ class MySQL_Connection {
~MySQL_Connection();
bool set_autocommit(bool);
bool set_no_backslash_escapes(bool);
uint8_t set_charset(uint8_t);
unsigned int set_charset(unsigned int);
void set_status_transaction(bool);
void set_status_compression(bool);
@ -197,7 +197,7 @@ class MySQL_Connection {
int async_change_user(short event);
int async_select_db(short event);
int async_set_autocommit(short event, bool);
int async_set_names(short event, uint8_t nr);
int async_set_names(short event, unsigned int nr);
int async_send_simple_command(short event, char *stmt, unsigned long length); // no result set expected
int async_query(short event, char *stmt, unsigned long length, MYSQL_STMT **_stmt=NULL, stmt_execute_metadata_t *_stmt_meta=NULL);
int async_ping(short event);

@ -672,7 +672,7 @@ __thread int mysql_thread___set_query_lock_on_hostgroup;
__thread int mysql_thread___reset_connection_algorithm;
__thread uint32_t mysql_thread___server_capabilities;
__thread int mysql_thread___auto_increment_delay_multiplex;
__thread uint8_t mysql_thread___default_charset;
__thread unsigned int mysql_thread___default_charset;
__thread int mysql_thread___poll_timeout;
__thread int mysql_thread___poll_timeout_on_failure;
__thread bool mysql_thread___have_compress;
@ -822,7 +822,7 @@ extern __thread int mysql_thread___set_query_lock_on_hostgroup;
extern __thread int mysql_thread___reset_connection_algorithm;
extern __thread uint32_t mysql_thread___server_capabilities;
extern __thread int mysql_thread___auto_increment_delay_multiplex;
extern __thread uint8_t mysql_thread___default_charset;
extern __thread unsigned int mysql_thread___default_charset;
extern __thread int mysql_thread___poll_timeout;
extern __thread int mysql_thread___poll_timeout_on_failure;
extern __thread bool mysql_thread___have_compress;

@ -1147,7 +1147,7 @@ bool MySQL_Protocol::generate_pkt_initial_handshake(bool send, void **ptr, unsig
//+ sizeof(glovars.server_language)
//+ sizeof(glovars.server_status)
+ sizeof(mysql_thread___server_capabilities)/2
+ sizeof(mysql_thread___default_charset)
+ sizeof(uint8_t) // charset in handshake is 1 byte
+ sizeof(server_status)
+ 3 // unknown stuff
+ 10 // filler
@ -1207,7 +1207,8 @@ bool MySQL_Protocol::generate_pkt_initial_handshake(bool send, void **ptr, unsig
mysql_thread___server_capabilities |= CLIENT_MYSQL | CLIENT_PLUGIN_AUTH | CLIENT_RESERVED;
(*myds)->myconn->options.server_capabilities=mysql_thread___server_capabilities;
memcpy(_ptr+l,&mysql_thread___server_capabilities, sizeof(mysql_thread___server_capabilities)/2); l+=sizeof(mysql_thread___server_capabilities)/2;
memcpy(_ptr+l,&mysql_thread___default_charset, sizeof(mysql_thread___default_charset)); l+=sizeof(mysql_thread___default_charset);
uint8_t uint8_charset = mysql_thread___default_charset & 255;
memcpy(_ptr+l,&uint8_charset, sizeof(uint8_charset)); l+=sizeof(uint8_charset);
memcpy(_ptr+l,&server_status, sizeof(server_status)); l+=sizeof(server_status);
memcpy(_ptr+l,"\x8f\x80\x15",3); l+=3;
for (i=0;i<10; i++) { _ptr[l]=0x00; l++; } //filler
@ -1475,7 +1476,7 @@ bool MySQL_Protocol::process_pkt_handshake_response(unsigned char *pkt, unsigned
if (dump_pkt) { __dump_pkt(__func__,pkt,len); }
#endif
bool ret=false;
uint8_t charset;
unsigned int charset;
uint32_t capabilities = 0;
uint32_t max_pkt;
uint32_t pass_len;
@ -1709,8 +1710,8 @@ __do_auth:
// reject connections from unknown charsets
const MARIADB_CHARSET_INFO * c = proxysql_find_charset_nr(charset);
if (!c) {
proxy_error("Client %s:%d is trying to use unknown charset %d. Disconnecting\n", (*myds)->addr.addr, (*myds)->addr.port, charset);
proxy_debug(PROXY_DEBUG_MYSQL_AUTH, 5, "Session=%p , DS=%p , user='%s' . Client %s:%d is trying to use unknown charset %d. Disconnecting\n", (*myds), (*myds)->sess, user, (*myds)->addr.addr, (*myds)->addr.port, charset);
proxy_error("Client %s:%d is trying to use unknown charset %u. Disconnecting\n", (*myds)->addr.addr, (*myds)->addr.port, charset);
proxy_debug(PROXY_DEBUG_MYSQL_AUTH, 5, "Session=%p , DS=%p , user='%s' . Client %s:%d is trying to use unknown charset %u. Disconnecting\n", (*myds), (*myds)->sess, user, (*myds)->addr.addr, (*myds)->addr.port, charset);
ret = false;
goto __exit_do_auth;
}

@ -1562,7 +1562,7 @@ void MySQL_Session::handler_again___new_thread_to_kill_connection() {
#define NEXT_IMMEDIATE_NEW(new_st) do { set_status(new_st); return true; } while (0)
bool MySQL_Session::handler_again___verify_backend_charset() {
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Session %p , client charset: %d , backend charset: %d\n", this, client_myds->myconn->options.charset, mybe->server_myds->myconn->mysql->charset->nr);
proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "Session %p , client charset: %u , backend charset: %u\n", this, client_myds->myconn->options.charset, mybe->server_myds->myconn->mysql->charset->nr);
if (client_myds->myconn->options.charset != mybe->server_myds->myconn->mysql->charset->nr) {
//previous_status.push(PROCESSING_QUERY);
switch(status) { // this switch can be replaced with a simple previous_status.push(status), but it is here for readibility
@ -2907,7 +2907,7 @@ bool MySQL_Session::handler_again___status_CHANGING_CHARSET(int *_rc) {
int myerr=mysql_errno(myconn->mysql);
if (myerr >= 2000) {
if (myerr == 2019) {
proxy_error("Client trying to set a charset/collation (%d) not supported by backend (%s:%d). Changing it to %d\n", client_myds->myconn->options.charset, myconn->parent->address, myconn->parent->port, mysql_thread___default_charset);
proxy_error("Client trying to set a charset/collation (%u) not supported by backend (%s:%d). Changing it to %u\n", client_myds->myconn->options.charset, myconn->parent->address, myconn->parent->port, mysql_thread___default_charset);
client_myds->myconn->options.charset = mysql_thread___default_charset;
}
bool retry_conn=false;

@ -745,7 +745,7 @@ uint16_t MySQL_Threads_Handler::get_variable_uint16(char *name) {
return 0;
}
uint8_t MySQL_Threads_Handler::get_variable_uint8(char *name) {
unsigned int MySQL_Threads_Handler::get_variable_uint(char *name) {
if (!strcasecmp(name,"default_charset")) return variables.default_charset;
proxy_error("Not existing variable: %s\n", name); assert(0);
return 0;
@ -4497,7 +4497,7 @@ void MySQL_Thread::refresh_variables() {
if (mysql_thread___keep_multiplexing_variables) free(mysql_thread___keep_multiplexing_variables);
mysql_thread___keep_multiplexing_variables=GloMTH->get_variable_string((char *)"keep_multiplexing_variables");
mysql_thread___server_capabilities=GloMTH->get_variable_uint16((char *)"server_capabilities");
mysql_thread___default_charset=GloMTH->get_variable_uint8((char *)"default_charset");
mysql_thread___default_charset=GloMTH->get_variable_uint((char *)"default_charset");
mysql_thread___poll_timeout=GloMTH->get_variable_int((char *)"poll_timeout");
mysql_thread___poll_timeout_on_failure=GloMTH->get_variable_int((char *)"poll_timeout_on_failure");
mysql_thread___have_compress=(bool)GloMTH->get_variable_int((char *)"have_compress");

@ -382,7 +382,7 @@ bool MySQL_Connection::set_no_backslash_escapes(bool _ac) {
return _ac;
}
uint8_t MySQL_Connection::set_charset(uint8_t _c) {
unsigned int MySQL_Connection::set_charset(unsigned int _c) {
proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "Setting charset %d\n", _c);
options.charset=_c;
return _c;
@ -1679,7 +1679,7 @@ int MySQL_Connection::async_set_autocommit(short event, bool ac) {
return 1;
}
int MySQL_Connection::async_set_names(short event, uint8_t c) {
int MySQL_Connection::async_set_names(short event, unsigned int c) {
PROXY_TRACE();
assert(mysql);
assert(ret_mysql);

Loading…
Cancel
Save