diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 9fe8aefcf..faa957fc5 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -3715,8 +3715,8 @@ void MySQL_HostGroups_Manager::update_galera_set_offline(char *_hostname, int _p } else { // the server is already offline, but we check if needs to be taken back online SQLite3_result *numw_result = NULL; q=(char *)"SELECT 1 FROM mysql_servers WHERE hostgroup_id=%d AND status=0"; - query=(char *)malloc(strlen(q)+strlen(_hostname)+32); - sprintf(query,q,_hostname,_port); + query=(char *)malloc(strlen(q) + (sizeof(_writer_hostgroup) * 8 + 1)); + sprintf(query,q,_writer_hostgroup); mydb->execute_statement(query, &error , &cols , &affected_rows , &numw_result); free(query); if (numw_result) { diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index 1ba77dae8..8a70358d4 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2412,7 +2412,7 @@ __get_pkts_from_client: if (session_type != PROXYSQL_SESSION_MYSQL) { // only MySQL module supports prepared statement!! l_free(pkt.size,pkt.ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported"); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported"); client_myds->DSS=STATE_SLEEP; status=WAITING_CLIENT_DATA; break; @@ -2473,7 +2473,7 @@ __get_pkts_from_client: if (session_type != PROXYSQL_SESSION_MYSQL) { // only MySQL module supports prepared statement!! l_free(pkt.size,pkt.ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported"); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported"); client_myds->DSS=STATE_SLEEP; status=WAITING_CLIENT_DATA; break; @@ -2499,7 +2499,7 @@ __get_pkts_from_client: // we couldn't find it l_free(pkt.size,pkt.ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Prepared statement doesn't exist", true); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Prepared statement doesn't exist", true); client_myds->DSS=STATE_SLEEP; status=WAITING_CLIENT_DATA; break; @@ -2517,7 +2517,7 @@ __get_pkts_from_client: if (stmt_meta==NULL) { l_free(pkt.size,pkt.ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Error in prepared statement execution", true); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Error in prepared statement execution", true); client_myds->DSS=STATE_SLEEP; status=WAITING_CLIENT_DATA; //__sync_fetch_and_sub(&stmt_info->ref_count,1); // decrease reference count @@ -3813,12 +3813,12 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C /* FIXME: temporary */ l_free(pkt->size,pkt->ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported", true); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported", true); client_myds->DSS=STATE_SLEEP; } else { l_free(pkt->size,pkt->ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported", true); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported", true); client_myds->DSS=STATE_SLEEP; } } @@ -3833,7 +3833,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C } else { l_free(pkt->size,pkt->ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported"); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported"); client_myds->DSS=STATE_SLEEP; } } @@ -3847,7 +3847,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C } else { l_free(pkt->size,pkt->ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"#28000",(char *)"Command not supported"); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,1045,(char *)"28000",(char *)"Command not supported"); client_myds->DSS=STATE_SLEEP; } } @@ -3855,7 +3855,7 @@ void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_C void MySQL_Session::handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_PROCESS_KILL(PtrSize_t *pkt) { l_free(pkt->size,pkt->ptr); client_myds->setDSS_STATE_QUERY_SENT_NET(); - client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,9003,(char *)"#28000",(char *)"Command not supported"); + client_myds->myprot.generate_pkt_ERR(true,NULL,NULL,1,9003,(char *)"28000",(char *)"Command not supported"); client_myds->DSS=STATE_SLEEP; } @@ -4632,7 +4632,7 @@ void MySQL_Session::SQLite3_to_MySQL(SQLite3_result *result, char *error, int af } else { // no result set if (error) { // there was an error - myprot->generate_pkt_ERR(true,NULL,NULL,sid,1045,(char *)"#28000",error); + myprot->generate_pkt_ERR(true,NULL,NULL,sid,1045,(char *)"28000",error); } else { // no error, DML succeeded unsigned int nTrx=NumActiveTransactions();