Skip to content

Commit

Permalink
Merge pull request #4476 from sysown/v2.x-doc240320
Browse files Browse the repository at this point in the history
Several code documentation
  • Loading branch information
renecannao authored Mar 25, 2024
2 parents ac0d084 + 6b9a787 commit 3187ee6
Show file tree
Hide file tree
Showing 10 changed files with 1,954 additions and 535 deletions.
41 changes: 38 additions & 3 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* @file MySQL_Session.h
* @brief Declaration of the MySQL_Session class and associated types and enums.
*/


#ifndef __CLASS_MYSQL_SESSION_H
#define __CLASS_MYSQL_SESSION_H

Expand All @@ -13,6 +19,10 @@ using json = nlohmann::json;

extern class MySQL_Variables mysql_variables;

/**
* @enum proxysql_session_type
* @brief Defines the types of ProxySQL sessions.
*/
enum proxysql_session_type {
PROXYSQL_SESSION_MYSQL,
PROXYSQL_SESSION_ADMIN,
Expand All @@ -24,6 +34,10 @@ enum proxysql_session_type {
PROXYSQL_SESSION_NONE
};

/**
* @enum ps_type
* @brief Defines types for prepared statement handling.
*/
enum ps_type : uint8_t {
ps_type_not_set = 0x0,
ps_type_prepare_stmt = 0x1,
Expand All @@ -32,9 +46,14 @@ enum ps_type : uint8_t {

std::string proxysql_session_type_str(enum proxysql_session_type session_type);

// these structs will be used for various regex hardcoded
// their initial use will be for sql_log_bin , sql_mode and time_zone
// issues #509 , #815 and #816
/**
* @class Session_Regex
* @brief Encapsulates regex operations for session handling.
*
* This class is used for matching patterns in SQL queries, specifically for
* settings like sql_log_bin, sql_mode, and time_zone.
* See issues #509 , #815 and #816
*/
class Session_Regex {
private:
void *opt;
Expand All @@ -46,6 +65,13 @@ class Session_Regex {
bool match(char *m);
};

/**
* @class Query_Info
* @brief Holds information about a SQL query within a session.
*
* This class encapsulates various details about a query such as its text,
* execution times, affected rows, and more, to facilitate query processing and logging.
*/
class Query_Info {
public:
SQP_par_t QueryParserArgs;
Expand Down Expand Up @@ -84,6 +110,13 @@ class Query_Info {
bool is_select_NOT_for_update();
};

/**
* @class MySQL_Session
* @brief Manages a client session, including query parsing, backend connections, and state transitions.
*
* This class is central to ProxySQL's handling of client connections. It manages the lifecycle
* of a session, processes queries, and communicates with backend MySQL servers.
*/
class MySQL_Session
{
private:
Expand Down Expand Up @@ -401,6 +434,8 @@ class MySQL_Session
void generate_status_one_hostgroup(int hid, std::string& s);
void reset_warning_hostgroup_flag_and_release_connection();
friend void SQLite3_Server_session_handler(MySQL_Session *sess, void *_pa, PtrSize_t *pkt);

void set_previous_status_mode3(bool allow_execute=true);
};

#define KILL_QUERY 1
Expand Down
Loading

0 comments on commit 3187ee6

Please sign in to comment.