Skip to content

Commit

Permalink
Fix out after refactoring generate_proxysql_internal_session_json()
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Apr 28, 2024
1 parent 73f8ad0 commit 678c470
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 49 deletions.
17 changes: 1 addition & 16 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,26 +1381,11 @@ void MySQL_Session::generate_proxysql_internal_session_json(json &j) {
j["gtid"]["last"] = ( strlen(gtid_buf) ? gtid_buf : "" );
json& jqpo = j["qpo"];
qpo->get_info_json(jqpo);
/*
j["qpo"]["create_new_connection"] = qpo->create_new_conn;
j["qpo"]["reconnect"] = qpo->reconnect;
j["qpo"]["sticky_conn"] = qpo->sticky_conn;
j["qpo"]["cache_timeout"] = qpo->cache_timeout;
j["qpo"]["cache_ttl"] = qpo->cache_ttl;
j["qpo"]["delay"] = qpo->delay;
j["qpo"]["destination_hostgroup"] = qpo->destination_hostgroup;
j["qpo"]["firewall_whitelist_mode"] = qpo->firewall_whitelist_mode;
j["qpo"]["multiplex"] = qpo->multiplex;
j["qpo"]["timeout"] = qpo->timeout;
j["qpo"]["retries"] = qpo->retries;
j["qpo"]["max_lag_ms"] = qpo->max_lag_ms;
*/
j["default_schema"] = ( default_schema ? default_schema : "" );
j["user_attributes"] = ( user_attributes ? user_attributes : "" );
j["transaction_persistent"] = transaction_persistent;
if (client_myds != NULL) { // only if client_myds is defined
json& jclient = j["client"];
client_myds->get_client_myds_info_json(jclient);
client_myds->get_client_myds_info_json(j);
}
for (unsigned int i=0; i<mybes->len; i++) {
MySQL_Backend *_mybe = NULL;
Expand Down
67 changes: 34 additions & 33 deletions lib/mysql_data_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,15 +1551,17 @@ bool MySQL_Data_Stream::data_in_rbio() {
}

void MySQL_Data_Stream::get_client_myds_info_json(json& j) {
j["stream"]["pkts_recv"] = pkts_recv;
j["stream"]["pkts_sent"] = pkts_sent;
j["stream"]["bytes_recv"] = bytes_info.bytes_recv;
j["stream"]["bytes_sent"] = bytes_info.bytes_sent;
j["client_addr"]["address"] = ( addr.addr ? addr.addr : "" );
j["client_addr"]["port"] = addr.port;
j["proxy_addr"]["address"] = ( proxy_addr.addr ? proxy_addr.addr : "" );
j["proxy_addr"]["port"] = proxy_addr.port;
j["encrypted"] = encrypted;
json& jc1 = j["client"];
json& jc2 = j["conn"];
jc1["stream"]["pkts_recv"] = pkts_recv;
jc1["stream"]["pkts_sent"] = pkts_sent;
jc1["stream"]["bytes_recv"] = bytes_info.bytes_recv;
jc1["stream"]["bytes_sent"] = bytes_info.bytes_sent;
jc1["client_addr"]["address"] = ( addr.addr ? addr.addr : "" );
jc1["client_addr"]["port"] = addr.port;
jc1["proxy_addr"]["address"] = ( proxy_addr.addr ? proxy_addr.addr : "" );
jc1["proxy_addr"]["port"] = proxy_addr.port;
jc1["encrypted"] = encrypted;
if (encrypted) {
const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl);
if (cipher) {
Expand All @@ -1569,52 +1571,51 @@ void MySQL_Data_Stream::get_client_myds_info_json(json& j) {
}
}
}
j["DSS"] = DSS;
j["switching_auth_sent"] = switching_auth_sent;
j["switching_auth_type"] = switching_auth_type;
j["prot"]["sent_auth_plugin_id"] = myprot.sent_auth_plugin_id;
j["prot"]["auth_plugin_id"] = myprot.auth_plugin_id;
jc1["DSS"] = DSS;
jc1["switching_auth_sent"] = switching_auth_sent;
jc1["switching_auth_type"] = switching_auth_type;
jc1["prot"]["sent_auth_plugin_id"] = myprot.sent_auth_plugin_id;
jc1["prot"]["auth_plugin_id"] = myprot.auth_plugin_id;

switch (myprot.auth_plugin_id) {
case AUTH_MYSQL_NATIVE_PASSWORD:
j["prot"]["auth_plugin"] = "mysql_native_password";
jc1["prot"]["auth_plugin"] = "mysql_native_password";
break;
case AUTH_MYSQL_CLEAR_PASSWORD:
j["prot"]["auth_plugin"] = "mysql_clear_password";
jc1["prot"]["auth_plugin"] = "mysql_clear_password";
break;
case AUTH_MYSQL_CACHING_SHA2_PASSWORD:
j["prot"]["auth_plugin"] = "caching_sha2_password";
jc1["prot"]["auth_plugin"] = "caching_sha2_password";
break;
default:
break;
}
if (myconn != NULL) { // only if myconn is defined
json& jc = j["conn"];
if (myconn->userinfo != NULL) { // only if userinfo is defined
j["userinfo"]["username"] = ( myconn->userinfo->username ? myconn->userinfo->username : "" );
j["userinfo"]["schemaname"] = ( myconn->userinfo->schemaname ? myconn->userinfo->schemaname : "" );
jc1["userinfo"]["username"] = ( myconn->userinfo->username ? myconn->userinfo->username : "" );
jc1["userinfo"]["schemaname"] = ( myconn->userinfo->schemaname ? myconn->userinfo->schemaname : "" );
#ifdef DEBUG
j["userinfo"]["password"] = ( myconn->userinfo->password ? myconn->userinfo->password : "" );
jc1["userinfo"]["password"] = ( myconn->userinfo->password ? myconn->userinfo->password : "" );
#endif
}
jc["session_track_gtids"] = ( myconn->options.session_track_gtids ? myconn->options.session_track_gtids : "") ;
jc2["session_track_gtids"] = ( myconn->options.session_track_gtids ? myconn->options.session_track_gtids : "") ;
for (auto idx = 0; idx < SQL_NAME_LAST_LOW_WM; idx++) {
myconn->variables[idx].fill_client_internal_session(jc, idx);
myconn->variables[idx].fill_client_internal_session(jc2, idx);
}
{
for (std::vector<uint32_t>::const_iterator it_c = myconn->dynamic_variables_idx.begin(); it_c != myconn->dynamic_variables_idx.end(); it_c++) {
myconn->variables[*it_c].fill_client_internal_session(jc, *it_c);
myconn->variables[*it_c].fill_client_internal_session(jc2, *it_c);
}
}

jc["autocommit"] = ( myconn->options.autocommit ? "ON" : "OFF" );
jc["client_flag"]["value"] = myconn->options.client_flag;
jc["client_flag"]["client_found_rows"] = (myconn->options.client_flag & CLIENT_FOUND_ROWS ? 1 : 0);
jc["client_flag"]["client_multi_statements"] = (myconn->options.client_flag & CLIENT_MULTI_STATEMENTS ? 1 : 0);
jc["client_flag"]["client_multi_results"] = (myconn->options.client_flag & CLIENT_MULTI_RESULTS ? 1 : 0);
jc["client_flag"]["client_deprecate_eof"] = (myconn->options.client_flag & CLIENT_DEPRECATE_EOF ? 1 : 0);
jc["no_backslash_escapes"] = myconn->options.no_backslash_escapes;
jc["status"]["compression"] = myconn->get_status(STATUS_MYSQL_CONNECTION_COMPRESSION);
jc["ps"]["client_stmt_to_global_ids"] = myconn->local_stmts->client_stmt_to_global_ids;
jc2["autocommit"] = ( myconn->options.autocommit ? "ON" : "OFF" );
jc2["client_flag"]["value"] = myconn->options.client_flag;
jc2["client_flag"]["client_found_rows"] = (myconn->options.client_flag & CLIENT_FOUND_ROWS ? 1 : 0);
jc2["client_flag"]["client_multi_statements"] = (myconn->options.client_flag & CLIENT_MULTI_STATEMENTS ? 1 : 0);
jc2["client_flag"]["client_multi_results"] = (myconn->options.client_flag & CLIENT_MULTI_RESULTS ? 1 : 0);
jc2["client_flag"]["client_deprecate_eof"] = (myconn->options.client_flag & CLIENT_DEPRECATE_EOF ? 1 : 0);
jc2["no_backslash_escapes"] = myconn->options.no_backslash_escapes;
jc2["status"]["compression"] = myconn->get_status(STATUS_MYSQL_CONNECTION_COMPRESSION);
jc2["ps"]["client_stmt_to_global_ids"] = myconn->local_stmts->client_stmt_to_global_ids;
}
}

0 comments on commit 678c470

Please sign in to comment.