From c0fdf02b7863f627c4e41380f4e32b628843fde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Fri, 13 May 2022 10:00:28 +0000 Subject: [PATCH] Fixed various compiler warnings --- include/MySQL_Variables.h | 1 - lib/ClickHouse_Server.cpp | 48 +++----------------------------- lib/MySQL_HostGroups_Manager.cpp | 5 ++-- lib/MySQL_Session.cpp | 3 -- lib/MySQL_Thread.cpp | 5 ++-- lib/MySQL_Variables.cpp | 20 ------------- lib/ProxySQL_Admin.cpp | 15 +++++----- lib/mysql_data_stream.cpp | 10 ++++--- 8 files changed, 21 insertions(+), 86 deletions(-) diff --git a/include/MySQL_Variables.h b/include/MySQL_Variables.h index a26b5e074..e51caee16 100644 --- a/include/MySQL_Variables.h +++ b/include/MySQL_Variables.h @@ -49,7 +49,6 @@ public: bool verify_variable(MySQL_Session* session, int idx) const; bool update_variable(MySQL_Session* session, session_status status, int &_rc); - bool on_connect_to_backend(MySQL_Connection *myconn); bool parse_variable_boolean(MySQL_Session *sess, int idx, std::string &value1, bool* lock_hostgroup); bool parse_variable_number(MySQL_Session *sess, int idx, std::string &value1, bool* lock_hostgroup); }; diff --git a/lib/ClickHouse_Server.cpp b/lib/ClickHouse_Server.cpp index a221b459e..73e6485f3 100644 --- a/lib/ClickHouse_Server.cpp +++ b/lib/ClickHouse_Server.cpp @@ -263,33 +263,6 @@ inline void ClickHouse_to_MySQL(const Block& block) { } - - - - - -static void StringToHex(unsigned char *string, unsigned char *hexstring, size_t l) { - unsigned char ch; - size_t i, j; - - for (i=0, j=0; i> 4; - if (ch <= 9) { - hexstring[j]= '0' + ch; - } else { - hexstring[j]= 'A' + ch - 10; - } - ch = string[i]; - ch = ch & 0x0F; - if (ch <= 9) { - hexstring[j+1]= '0' + ch; - } else { - hexstring[j+1]= 'A' + ch - 10; - } - } -} - struct cpu_timer { cpu_timer() { @@ -315,17 +288,6 @@ static char *s_strdup(char *s) { } -static char *sha1_pass_hex(char *sha1_pass) { // copied from MySQL_Protocol.cpp - if (sha1_pass==NULL) return NULL; - char *buff1=(char *)malloc(SHA_DIGEST_LENGTH*2+2); - buff1[0]='*'; - buff1[SHA_DIGEST_LENGTH*2+1]='\0'; - StringToHex((unsigned char *)sha1_pass,(unsigned char *)buff1+1,SHA_DIGEST_LENGTH); -// assert(strcmp(buff,buff1)==0); -// free(buff); - return buff1; -} - static int __ClickHouse_Server_refresh_interval=1000; extern Query_Cache *GloQC; extern ClickHouse_Authentication *GloClickHouseAuth; @@ -473,8 +435,6 @@ class sqlite3server_main_loop_listeners { static sqlite3server_main_loop_listeners S_amll; void ClickHouse_Server_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { - - ClickHouse_Server *s3s=(ClickHouse_Server *)_pa; char *error=NULL; int cols; int affected_rows; @@ -1576,10 +1536,10 @@ bool ClickHouse_Server::set_variable(char *name, char *value) { // this is the if ((variables.mysql_ifaces==NULL) || strcasecmp(variables.mysql_ifaces,value) ) update_creds=true; if (variables.mysql_ifaces) free(variables.mysql_ifaces); - variables.mysql_ifaces=strdup(value); - if (update_creds && variables.mysql_ifaces) { - S_amll.update_ifaces(variables.mysql_ifaces, &S_amll.ifaces_mysql); - } + variables.mysql_ifaces=strdup(value); + if (update_creds && variables.mysql_ifaces) { + S_amll.update_ifaces(variables.mysql_ifaces, &S_amll.ifaces_mysql); + } return true; } else { return false; diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index e7ec97b2c..cec3c3b06 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -3452,7 +3452,7 @@ void MySQL_HostGroups_Manager::replication_lag_action_inner(MyHGC *myhgc, char * ) { // always increase the counter mysrvc->cur_replication_lag_count += 1; - if (mysrvc->cur_replication_lag_count >= mysql_thread___monitor_replication_lag_count) { + if (mysrvc->cur_replication_lag_count >= (unsigned int)mysql_thread___monitor_replication_lag_count) { proxy_warning("Shunning server %s:%d from HG %u with replication lag of %d second, count number: '%d'\n", address, port, myhgc->hid, current_replication_lag, mysrvc->cur_replication_lag_count); mysrvc->status=MYSQL_SERVER_STATUS_SHUNNED_REPLICATION_LAG; } else { @@ -3706,7 +3706,7 @@ int MySQL_HostGroups_Manager::get_multiple_idle_connections(int _hid, unsigned l MySQL_Connection *mc=mscl->index(k); // If the connection is idle ... if (mc->last_time_used && mc->last_time_used < _max_last_time_used) { - if (oldest_idle_connections.size() < num_conn) { + if ((int)oldest_idle_connections.size() < num_conn) { oldest_idle_connections.insert({mc->last_time_used, { mysrvc, k }}); } else if (num_conn != 0) { auto last_elem_it = std::prev(oldest_idle_connections.end()); @@ -4524,7 +4524,6 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re // LCOV_EXCL_STOP } -__exit_read_only_action: pthread_mutex_unlock(&readonly_mutex); if (resultset) { delete resultset; diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index f253beff2..6f9cddfbb 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2773,7 +2773,6 @@ bool MySQL_Session::handler_again___status_CONNECTING_SERVER(int *_rc) { myds->myconn->send_quit = false; myds->myconn->reusable = false; } - mysql_variables.on_connect_to_backend(myds->myconn); NEXT_IMMEDIATE_NEW(st); break; case -1: @@ -6765,7 +6764,6 @@ void MySQL_Session::MySQL_Stmt_Result_to_MySQL_wire(MYSQL_STMT *stmt, MySQL_Conn */ if (MyRS) { assert(MyRS->result); - bool transfer_started=MyRS->transfer_started; MyRS->init_with_stmt(myconn); bool resultset_completed=MyRS->get_resultset(client_myds->PSarrayOUT); CurrentQuery.rows_sent = MyRS->num_rows; @@ -7188,7 +7186,6 @@ void MySQL_Session::create_new_session_and_reset_connection(MySQL_Data_Stream *_ mc->async_state_machine = ASYNC_IDLE; // may not be true, but is used to correctly perform error handling new_myds->DSS = STATE_MARIADB_QUERY; thread->register_session_connection_handler(new_sess,true); - mysql_variables.on_connect_to_backend(mc); if (new_myds->mypolls==NULL) { thread->mypolls.add(POLLIN|POLLOUT, new_myds->fd, new_myds, thread->curtime); } diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 1265785fb..d102ceaec 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -3332,7 +3332,7 @@ __run_skip_2: // end of ::run() unsigned int MySQL_Thread::find_session_idx_in_mysql_sessions(MySQL_Session *sess) { - int i=0; + unsigned int i=0; for (i=0;ilen;i++) { MySQL_Session *mysess=(MySQL_Session *)mysql_sessions->index(i); if (mysess==sess) { @@ -3668,7 +3668,6 @@ void MySQL_Thread::ProcessAllSessions_MaintenanceLoop(MySQL_Session *sess, unsig unsigned int numTrx=0; sess->active_transactions=sess->NumActiveTransactions(); { - unsigned long long sess_active_transactions = sess->active_transactions; sess->active_transactions=sess->NumActiveTransactions(); // in case we detected a new transaction just now if (sess->active_transactions == 0) { @@ -3737,7 +3736,7 @@ void MySQL_Thread::ProcessAllSessions_MaintenanceLoop(MySQL_Session *sess, unsig if (sess->mybe && sess->mybe->server_myds && sess->mybe->server_myds->myconn) { MySQL_Connection* myconn = sess->mybe->server_myds->myconn; - if (mysql_thread___auto_increment_delay_multiplex_timeout_ms != 0 && (sess_time/1000 > mysql_thread___auto_increment_delay_multiplex_timeout_ms)) { + if (mysql_thread___auto_increment_delay_multiplex_timeout_ms != 0 && (sess_time/1000 > (unsigned long long)mysql_thread___auto_increment_delay_multiplex_timeout_ms)) { myconn->auto_increment_delay_token = 0; } } diff --git a/lib/MySQL_Variables.cpp b/lib/MySQL_Variables.cpp index 1c3d9c0db..f0c4111c7 100644 --- a/lib/MySQL_Variables.cpp +++ b/lib/MySQL_Variables.cpp @@ -76,26 +76,6 @@ MySQL_Variables::MySQL_Variables() { MySQL_Variables::~MySQL_Variables() {} -bool MySQL_Variables::on_connect_to_backend(MySQL_Connection *myconn) { - assert(myconn); - auto be_version = myconn->mysql->server_version; - -/* - // completely remove this part, see suggestion in issue #3723 - // because in MySQL_Session::handler_again___status_SETTING_GENERIC_VARIABLE() - // we handle error 1193 (variable is not found), this optimization here seems - // unnecessary, especially because the assumption used here is wrong - // verify this is not galera cluster - // assume galera cluster has two dashes in a version - char* first_dash = strstr(be_version, "-"); - if (!first_dash || !strstr(first_dash+1, "-")) { - myconn->var_absent[SQL_WSREP_SYNC_WAIT] = true; - } -*/ - return true; -} - - bool MySQL_Variables::client_set_hash_and_value(MySQL_Session* session, int idx, const std::string& value, uint32_t hash) { if (!session || !session->client_myds || !session->client_myds->myconn) { proxy_warning("Session validation failed\n"); diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 539dc7991..01c3bb13a 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -962,7 +962,7 @@ const std::vector SAVE_MYSQL_VARIABLES_TO_MEMORY = { bool is_admin_command_or_alias(const std::vector& cmds, char *query_no_space, int query_no_space_length) { for (std::vector::const_iterator it=cmds.begin(); it!=cmds.end(); ++it) { - if (query_no_space_length==it->length() && !strncasecmp(it->c_str(), query_no_space, query_no_space_length)) { + if ((unsigned int)query_no_space_length==it->length() && !strncasecmp(it->c_str(), query_no_space, query_no_space_length)) { proxy_info("Received %s command\n", query_no_space); return true; } @@ -1419,7 +1419,7 @@ bool admin_handler_command_proxysql(char *query_no_space, unsigned int query_no_ sess->client_myds->shut_soft(); return false; } - if (query_no_space_length >= l+36+2) { + if (query_no_space_length >= (unsigned int)l+36+2) { uuid_t uu; char *A_uuid = NULL; char *B_interface = NULL; @@ -4031,7 +4031,7 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { char msg[256]; unsigned long long d = SPA->ProxySQL_Test___MySQL_HostGroups_Manager_read_only_action(); sprintf(msg, "Tested in %llums\n", d); - SPA->send_MySQL_OK(&sess->client_myds->myprot, msg, NULL); + SPA->send_MySQL_OK(&sess->client_myds->myprot, msg); run_query=false; } break; @@ -4041,7 +4041,7 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { char msg[256]; unsigned long long d = SPA->ProxySQL_Test___MySQL_HostGroups_Manager_HG_lookup(); sprintf(msg, "Tested in %llums\n", d); - SPA->send_MySQL_OK(&sess->client_myds->myprot, msg, NULL); + SPA->send_MySQL_OK(&sess->client_myds->myprot, msg); run_query=false; } break; @@ -4063,7 +4063,7 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { SPA->admindb->execute("DELETE FROM mysql_servers WHERE hostgroup_id=5211"); SPA->load_mysql_servers_to_runtime(); SPA->mysql_servers_wrunlock(); - SPA->send_MySQL_OK(&sess->client_myds->myprot, msg, NULL); + SPA->send_MySQL_OK(&sess->client_myds->myprot, msg); run_query=false; } break; @@ -4879,7 +4879,7 @@ void admin_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt) { char *tn=NULL; // tablename tn=(char *)malloc(strAl+1); unsigned int i=0, j=0; - while (iMyHGC_lookup(5211); assert(myhgc); @@ -13161,7 +13160,7 @@ unsigned long long ProxySQL_Admin::ProxySQL_Test___MySQL_HostGroups_Manager_Bala } unsigned int NL = 1000; for (unsigned int i=0; iget_random_MySrvC(NULL, NULL, -1, NULL); + MySrvC * mysrvc = myhgc->get_random_MySrvC(NULL, 0, -1, NULL); assert(mysrvc); for (unsigned int k=0; kmysrvs->servers->index(k); diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index 7bad707a5..678978211 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -906,10 +906,12 @@ int MySQL_Data_Stream::read_pkts() { int MySQL_Data_Stream::buffer2array() { int ret=0; bool fast_mode=sess->session_fast_forward; - int s = queue_data(queueIN); - if (s==0) return ret; - if ((queueIN.pkt.size==0) && s