Skip to content

Commit

Permalink
Merge branch 'v2.0.6-query-json' into v2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Jul 16, 2019
2 parents 64c5bd9 + 255d924 commit 334cbdb
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 65 deletions.
14 changes: 11 additions & 3 deletions include/MySQL_Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@ class MySQL_Event {
enum log_event_type et;
uint64_t hid;
char *extra_info;
bool have_affected_rows;
bool have_rows_sent;
uint64_t affected_rows;
uint64_t rows_sent;
public:
MySQL_Event(log_event_type _et, uint32_t _thread_id, char * _username, char * _schemaname , uint64_t _start_time , uint64_t _end_time , uint64_t _query_digest, char *_client, size_t _client_len);
uint64_t write(std::fstream *f, MySQL_Session *sess);
uint64_t write_query(std::fstream *f);
uint64_t write_query_format_1(std::fstream *f);
uint64_t write_query_format_2_json(std::fstream *f);
void write_auth(std::fstream *f, MySQL_Session *sess);
void set_query(const char *ptr, int len);
void set_server(int _hid, const char *ptr, int len);
void set_extra_info(char *);
void set_affected_rows(uint64_t ar);
void set_rows_sent(uint64_t rs);
};

class MySQL_Logger {
Expand All @@ -59,8 +66,6 @@ class MySQL_Logger {
#else
rwlock_t rwlock;
#endif
void wrlock();
void wrunlock();
void events_close_log_unlocked();
void events_open_log_unlocked();
void audit_close_log_unlocked();
Expand All @@ -70,6 +75,7 @@ class MySQL_Logger {
public:
MySQL_Logger();
~MySQL_Logger();
void print_version();
void flush_log();
void events_flush_log_unlocked();
void audit_flush_log_unlocked();
Expand All @@ -80,6 +86,8 @@ class MySQL_Logger {
void log_request(MySQL_Session *, MySQL_Data_Stream *);
void log_audit_entry(log_event_type, MySQL_Session *, MySQL_Data_Stream *, char *e = NULL);
void flush();
void wrlock();
void wrunlock();
};


Expand Down
2 changes: 1 addition & 1 deletion include/MySQL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MySQL_ResultSet {
MYSQL *mysql;
MYSQL_RES *result;
unsigned int num_fields;
unsigned int num_rows;
unsigned long long num_rows;
unsigned long long resultset_size;
PtrSizeArray PSarrayOUT;
//PtrSizeArray *PSarrayOUT;
Expand Down
12 changes: 8 additions & 4 deletions include/MySQL_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Query_Info {
enum MYSQL_COM_QUERY_command MyComQueryCmd;
bool bool_is_select_NOT_for_update;
bool bool_is_select_NOT_for_update_computed;
bool have_affected_rows;
uint64_t affected_rows;
uint64_t rows_sent;

Query_Info();
~Query_Info();
Expand Down Expand Up @@ -95,6 +98,7 @@ class MySQL_Session
bool handler_CommitRollback(PtrSize_t *);
bool handler_SetAutocommit(PtrSize_t *);
void RequestEnd(MySQL_Data_Stream *);
void LogQuery(MySQL_Data_Stream *);

void handler___status_WAITING_CLIENT_DATA___STATE_SLEEP___MYSQL_COM_QUERY___create_mirror_session();
int handler_again___status_PINGING_SERVER();
Expand Down Expand Up @@ -123,10 +127,6 @@ class MySQL_Session
void reset();
void add_ldap_comment_to_pkt(PtrSize_t *);

//this pointer is always initialized inside handler().
// it is an attempt to start simplifying the complexing of handler()
PtrSize_t *pktH;


public:
void * operator new(size_t);
Expand All @@ -151,6 +151,10 @@ class MySQL_Session
MySQL_Data_Stream *server_myds;
char * default_schema;

//this pointer is always initialized inside handler().
// it is an attempt to start simplifying the complexing of handler()
PtrSize_t *pktH;

uint32_t thread_session_id;
unsigned long long last_insert_id;
int last_HG_affected_rows;
Expand Down
2 changes: 2 additions & 0 deletions include/MySQL_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ class MySQL_Threads_Handler
int connpoll_reset_queue_length;
char *eventslog_filename;
int eventslog_filesize;
int eventslog_default_log;
int eventslog_format;
char *auditlog_filename;
int auditlog_filesize;
// SSL related, proxy to server
Expand Down
10 changes: 8 additions & 2 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define PROXYSQL_ENUMS

enum log_event_type {
PROXYSQL_QUERY,
PROXYSQL_COM_QUERY,
PROXYSQL_MYSQL_AUTH_OK,
PROXYSQL_MYSQL_AUTH_ERR,
PROXYSQL_MYSQL_AUTH_CLOSE,
Expand All @@ -26,7 +26,9 @@ enum log_event_type {
PROXYSQL_SQLITE_AUTH_OK,
PROXYSQL_SQLITE_AUTH_ERR,
PROXYSQL_SQLITE_AUTH_CLOSE,
PROXYSQL_SQLITE_AUTH_QUIT
PROXYSQL_SQLITE_AUTH_QUIT,
PROXYSQL_COM_STMT_EXECUTE,
PROXYSQL_COM_STMT_PREPARE
};

enum cred_username_type { USERNAME_BACKEND, USERNAME_FRONTEND };
Expand Down Expand Up @@ -685,6 +687,8 @@ __thread char * mysql_thread___ssl_p2s_cipher;
/* variables used by events log */
__thread char * mysql_thread___eventslog_filename;
__thread int mysql_thread___eventslog_filesize;
__thread int mysql_thread___eventslog_default_log;
__thread int mysql_thread___eventslog_format;

/* variables used by audit log */
__thread char * mysql_thread___auditlog_filename;
Expand Down Expand Up @@ -814,6 +818,8 @@ extern __thread char * mysql_thread___ssl_p2s_cipher;
/* variables used by events log */
extern __thread char * mysql_thread___eventslog_filename;
extern __thread int mysql_thread___eventslog_filesize;
extern __thread int mysql_thread___eventslog_default_log;
extern __thread int mysql_thread___eventslog_format;

/* variables used by audit log */
extern __thread char * mysql_thread___auditlog_filename;
Expand Down
Loading

0 comments on commit 334cbdb

Please sign in to comment.