diff --git a/include/mysql_backend.h b/include/mysql_backend.h index df80ecf74..b78d223ba 100644 --- a/include/mysql_backend.h +++ b/include/mysql_backend.h @@ -10,6 +10,8 @@ class MySQL_Backend void * operator new(size_t); void operator delete(void *); int hostgroup_id; + char gtid_uuid[48]; + uint64_t gtid_trxid; MySQL_Data_Stream *server_myds; // mysql_cp_entry_t *server_mycpe; bytes_stats_t server_bytes_at_cmd; diff --git a/include/mysql_connection.h b/include/mysql_connection.h index 71b6bd74c..9aa498820 100644 --- a/include/mysql_connection.h +++ b/include/mysql_connection.h @@ -178,5 +178,7 @@ class MySQL_Connection { void set_is_client(); // used for local_stmts void reset(); + + bool get_gtid(char *buff, uint64_t *trx_id); }; #endif /* __CLASS_MYSQL_CONNECTION_H */ diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index cd987524e..5b08da8d2 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -2621,6 +2621,7 @@ handler_again: (begint.tv_sec*1000000000+begint.tv_nsec); } if (rc==0) { + myconn->get_gtid(mybe->gtid_uuid,&mybe->gtid_trxid); // check if multiplexing needs to be disabled char *qdt=CurrentQuery.get_digest_text(); if (qdt) diff --git a/lib/mysql_backend.cpp b/lib/mysql_backend.cpp index 9b8d0b5c4..9f5cee46e 100644 --- a/lib/mysql_backend.cpp +++ b/lib/mysql_backend.cpp @@ -14,6 +14,8 @@ MySQL_Backend::MySQL_Backend() { server_myds=NULL; server_bytes_at_cmd.bytes_recv=0; server_bytes_at_cmd.bytes_sent=0; + memset(gtid_uuid,0,sizeof(gtid_uuid)); + gtid_trxid=0; } MySQL_Backend::~MySQL_Backend() { diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index e864b97b5..5a888c452 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -1706,3 +1706,22 @@ void MySQL_Connection::reset() { local_stmts=new MySQL_STMTs_local_v14(false); #endif } + +bool MySQL_Connection::get_gtid(char *buff, uint64_t *trx_id) { + // note: current implementation for for OWN GTID only! + bool ret = false; + if (buff==NULL || trx_id == NULL) { + return ret; + } + if (mysql) { + const char *data; + size_t length; + if (mysql_session_track_get_first(mysql, SESSION_TRACK_GTIDS, &data, &length) == 0) { + memcpy(buff,data,length); + buff[length]=0; + fprintf(stderr,"GTID=%s\n",buff); + ret = true; + } + } + return ret; +}