Skip to content

Commit

Permalink
Merge pull request #4532 from sysown/v2.x_240427
Browse files Browse the repository at this point in the history
Some code refactoring
  • Loading branch information
renecannao authored Apr 29, 2024
2 parents 1cc0456 + 678c470 commit 5b87e89
Show file tree
Hide file tree
Showing 7 changed files with 739 additions and 613 deletions.
2 changes: 2 additions & 0 deletions include/MySQL_Data_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,7 @@ class MySQL_Data_Stream
void destroy_queues();

bool data_in_rbio();

void get_client_myds_info_json(json&);
};
#endif /* __CLASS_MYSQL_DATA_STREAM_H */
16 changes: 16 additions & 0 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class MySQL_Session
private:
//int handler_ret;
void handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE(PtrSize_t *, bool *);
void handler___status_CONNECTING_CLIENT___STATE_SERVER_HANDSHAKE_WrongCredentials(PtrSize_t *, bool *);

// void handler___status_CHANGING_USER_CLIENT___STATE_CLIENT_HANDSHAKE(PtrSize_t *, bool *);

Expand Down Expand Up @@ -202,14 +203,17 @@ class MySQL_Session
void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session();
int handler_again___status_PINGING_SERVER();
int handler_again___status_RESETTING_CONNECTION();
bool handler_again___status_SHOW_WARNINGS(MySQL_Data_Stream *, bool);
void handler_again___new_thread_to_kill_connection();
void handler_KillConnectionIfNeeded();

bool handler_again___verify_init_connect();
bool handler_again___verify_ldap_user_variable();
bool handler_again___verify_backend_autocommit();
bool handler_again___verify_backend_session_track_gtids();
bool handler_again___verify_backend_multi_statement();
bool handler_again___verify_backend_user_schema();
bool handler_again___verify_multiple_variables(MySQL_Connection *);
bool handler_again___status_SETTING_INIT_CONNECT(int *);
bool handler_again___status_SETTING_LDAP_USER_VARIABLE(int *);
bool handler_again___status_SETTING_SQL_MODE(int *);
Expand All @@ -221,6 +225,7 @@ class MySQL_Session
bool handler_again___status_CHANGING_AUTOCOMMIT(int *);
bool handler_again___status_SETTING_MULTI_STMT(int *_rc);
bool handler_again___multiple_statuses(int *rc);

void init();
void reset();
void add_ldap_comment_to_pkt(PtrSize_t *);
Expand All @@ -229,7 +234,17 @@ class MySQL_Session
* performing any processing on received client packets.
*/
void housekeeping_before_pkts();

int get_pkts_from_client(bool&, PtrSize_t&);

// GPFC_ functions are subfunctions of get_pkts_from_client()
int GPFC_Statuses2(bool&, PtrSize_t&);
void GPFC_DetectedMultiPacket_SetDDS();
int GPFC_WaitingClientData_FastForwardSession(PtrSize_t&);
void GPFC_PreparedStatements(PtrSize_t&, unsigned char);
void GPFC_Replication_SwitchToFastForward(PtrSize_t&, unsigned char);
bool GPFC_QueryUSE(PtrSize_t&, int&);

void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_RESET(PtrSize_t&);
void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_CLOSE(PtrSize_t&);
void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_STMT_SEND_LONG_DATA(PtrSize_t&);
Expand All @@ -249,6 +264,7 @@ class MySQL_Session
int RunQuery(MySQL_Data_Stream *myds, MySQL_Connection *myconn);
void handler___status_WAITING_CLIENT_DATA();
void handler_rc0_Process_GTID(MySQL_Connection *myconn);
void handler_rc0_RefreshActiveTransactions(MySQL_Connection* myconn);
void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_INIT_DB_replace_CLICKHOUSE(PtrSize_t& pkt);
void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___not_mysql(PtrSize_t& pkt);
bool handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY_detect_SQLi();
Expand Down
5 changes: 4 additions & 1 deletion include/mysql_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MySQLServers_SslParams;
class Variable {
public:
char *value = (char*)"";
void fill_server_internal_session(json &j, int conn_num, int idx);
void fill_server_internal_session(json &j, int idx);
void fill_client_internal_session(json &j, int idx);
};

Expand Down Expand Up @@ -254,5 +254,8 @@ class MySQL_Connection {
unsigned int number_of_matching_session_variables(const MySQL_Connection *client_conn, unsigned int& not_matching);
unsigned long get_mysql_thread_id() { return mysql ? mysql->thread_id : 0; }
static void set_ssl_params(MYSQL *mysql, MySQLServers_SslParams *ssl_params);

void get_mysql_info_json(json&);
void get_backend_conn_info_json(json&);
};
#endif /* __CLASS_MYSQL_CONNECTION_H */
16 changes: 15 additions & 1 deletion include/query_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define DIGEST_STATS_FAST_MINSIZE 100000
#define DIGEST_STATS_FAST_THREADS 4


#include "../deps/json/json.hpp"


#include "khash.h"
Expand Down Expand Up @@ -204,6 +204,20 @@ class Query_Processor_Output {
free(comment);
}
}
void get_info_json(nlohmann::json& j) {
j["create_new_connection"] = create_new_conn;
j["reconnect"] = reconnect;
j["sticky_conn"] = sticky_conn;
j["cache_timeout"] = cache_timeout;
j["cache_ttl"] = cache_ttl;
j["delay"] = delay;
j["destination_hostgroup"] = destination_hostgroup;
j["firewall_whitelist_mode"] = firewall_whitelist_mode;
j["multiplex"] = multiplex;
j["timeout"] = timeout;
j["retries"] = retries;
j["max_lag_ms"] = max_lag_ms;
}
};

static char *commands_counters_desc[MYSQL_COM_QUERY___NONE];
Expand Down
Loading

0 comments on commit 5b87e89

Please sign in to comment.