diff --git a/include/mysql_connection.h b/include/mysql_connection.h index 853b6b05a..db579c6cd 100644 --- a/include/mysql_connection.h +++ b/include/mysql_connection.h @@ -4,6 +4,12 @@ #include "proxysql.h" #include "cpp.h" +#define STATUS_MYSQL_CONNECTION_TRANSACTION 0x00000001 +#define STATUS_MYSQL_CONNECTION_COMPRESSION 0x00000002 +#define STATUS_MYSQL_CONNECTION_USER_VARIABLE 0x00000004 +#define STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT 0x00000008 + + class MySQL_Connection_userinfo { private: uint64_t compute_hash(); @@ -35,7 +41,9 @@ class MySQL_Connection { char *server_version; uint8_t protocol_version; uint8_t charset; + unsigned int compression_min_length; } options; + uint32_t status_flags; unsigned long long last_time_used; MySrvC *parent; // void * operator new(size_t); @@ -53,6 +61,16 @@ class MySQL_Connection { MyConnArray *set_MCA(MySQL_Connection_Pool *_MyConnPool, const char *hostname, const char *username, const char *password, const char *db, unsigned int port); bool return_to_connection_pool(); uint8_t set_charset(uint8_t); + + void set_status_transaction(bool); + void set_status_compression(bool); + void set_status_prepared_statement(bool); + void set_status_user_variable(bool); + bool get_status_transaction(); + bool get_status_compression(); + bool get_status_prepared_statement(); + bool get_status_user_variable(); + friend class MyConnArray; }; #endif /* __CLASS_MYSQL_CONNECTION_H */ diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 9c21ee3b6..60be2c50e 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -109,6 +109,8 @@ MySQL_Connection::MySQL_Connection() { parent=NULL; userinfo=new MySQL_Connection_userinfo(); fd=-1; + status_flags=0; + options.compression_min_length=0; options.server_version=NULL; proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "Creating new MySQL_Connection %p\n", this); }; @@ -201,3 +203,51 @@ bool MySQL_Connection::is_expired(unsigned long long timeout) { // FIXME: for now this is just a temporary (and stupid) check return false; } + +MySQL_Connection::set_status_transaction(bool v) { + if (v) { + status_flags |= STATUS_MYSQL_CONNECTION_TRANSACTION; + } else { + status_flags &= ~STATUS_MYSQL_CONNECTION_TRANSACTION; + } +} + +MySQL_Connection::set_status_compression(bool v) { + if (v) { + status_flags |= STATUS_MYSQL_CONNECTION_COMPRESSION; + } else { + status_flags &= ~STATUS_MYSQL_CONNECTION_COMPRESSION; + } +} + +MySQL_Connection::set_status_user_variable(bool v) { + if (v) { + status_flags |= STATUS_MYSQL_CONNECTION_USER_VARIABLE; + } else { + status_flags &= ~STATUS_MYSQL_CONNECTION_USER_VARIABLE; + } +} + +MySQL_Connection::set_status_prepared_statement(bool v) { + if (v) { + status_flags |= STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT; + } else { + status_flags &= ~STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT; + } +} + +bool MySQL_Connection::get_status_transaction() { + return status_flags & STATUS_MYSQL_CONNECTION_TRANSACTION; +} + +bool MySQL_Connection::get_status_compression() { + return status_flags & STATUS_MYSQL_CONNECTION_COMPRESSION; +} + +bool MySQL_Connection::get_status_user_variable() { + return status_flags & STATUS_MYSQL_CONNECTION_USER_VARIABLE; +} + +bool MySQL_Connection::get_status_prepared_statement() { + return status_flags & STATUS_MYSQL_CONNECTION_PREPARED_STATEMENT; +}