MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid
register changes of last_gtid
This commit is contained in:
parent
73de63e898
commit
517d718201
@ -1,46 +1,30 @@
|
||||
SELECT @@session.character_set_client, @@session.character_set_results, @@session.character_set_connection;
|
||||
@@session.character_set_client @@session.character_set_results @@session.character_set_connection
|
||||
latin1 latin1 latin1
|
||||
SET @@session.session_track_system_variables='character_set_client,character_set_results,character_set_connection';
|
||||
SELECT @@session.character_set_connection;
|
||||
@@session.character_set_connection
|
||||
latin1
|
||||
SET @@session.session_track_system_variables='character_set_connection';
|
||||
# tracking info on
|
||||
SET NAMES 'utf8';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- character_set_client
|
||||
-- utf8
|
||||
-- character_set_connection
|
||||
-- utf8
|
||||
-- character_set_results
|
||||
-- utf8
|
||||
|
||||
SET NAMES 'big5';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- character_set_client
|
||||
-- big5
|
||||
-- character_set_connection
|
||||
-- big5
|
||||
-- character_set_results
|
||||
-- big5
|
||||
|
||||
# tracking info on once
|
||||
SET NAMES 'utf8';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- character_set_client
|
||||
-- utf8
|
||||
-- character_set_connection
|
||||
-- utf8
|
||||
-- character_set_results
|
||||
-- utf8
|
||||
|
||||
SET NAMES 'big5';
|
||||
# tracking info on
|
||||
SET NAMES 'utf8';
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- character_set_client
|
||||
-- utf8
|
||||
-- character_set_connection
|
||||
-- utf8
|
||||
-- character_set_results
|
||||
-- utf8
|
||||
|
||||
# tracking info off once
|
||||
SET NAMES 'big5';
|
||||
|
34
mysql-test/r/session_tracker_last_gtid.result
Normal file
34
mysql-test/r/session_tracker_last_gtid.result
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid
|
||||
#
|
||||
SET gtid_seq_no=1000;
|
||||
SET @@session.session_track_system_variables='last_gtid';
|
||||
create table t1 (a int) engine=innodb;
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- last_gtid
|
||||
-- 0-1-1000
|
||||
|
||||
select @@last_gtid;
|
||||
@@last_gtid
|
||||
0-1-1000
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- last_gtid
|
||||
-- 0-1-1000
|
||||
|
||||
insert into t1 values (1);
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- last_gtid
|
||||
-- 0-1-1001
|
||||
|
||||
select @@last_gtid;
|
||||
@@last_gtid
|
||||
0-1-1001
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- last_gtid
|
||||
-- 0-1-1001
|
||||
|
||||
drop table t1;
|
||||
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
|
||||
-- last_gtid
|
||||
-- 0-1-1002
|
||||
|
@ -2,8 +2,8 @@
|
||||
--source include/no_protocol.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
SELECT @@session.character_set_client, @@session.character_set_results, @@session.character_set_connection;
|
||||
SET @@session.session_track_system_variables='character_set_client,character_set_results,character_set_connection';
|
||||
SELECT @@session.character_set_connection;
|
||||
SET @@session.session_track_system_variables='character_set_connection';
|
||||
|
||||
--echo # tracking info on
|
||||
--enable_session_track_info
|
||||
|
19
mysql-test/t/session_tracker_last_gtid.test
Normal file
19
mysql-test/t/session_tracker_last_gtid.test
Normal file
@ -0,0 +1,19 @@
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_binlog_format_statement.inc
|
||||
|
||||
--enable_session_track_info
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid
|
||||
--echo #
|
||||
|
||||
SET gtid_seq_no=1000;
|
||||
SET @@session.session_track_system_variables='last_gtid';
|
||||
create table t1 (a int) engine=innodb;
|
||||
select @@last_gtid;
|
||||
insert into t1 values (1);
|
||||
select @@last_gtid;
|
||||
drop table t1;
|
||||
|
||||
--disable_session_track_info
|
@ -46,6 +46,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <m_ctype.h> // For test_if_number
|
||||
|
||||
#include <set_var.h> // for Sys_last_gtid_ptr
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "message.h"
|
||||
#endif
|
||||
@ -5945,7 +5947,8 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone,
|
||||
}
|
||||
if (err)
|
||||
DBUG_RETURN(true);
|
||||
thd->last_commit_gtid= gtid;
|
||||
|
||||
thd->set_last_commit_gtid(gtid);
|
||||
|
||||
Gtid_log_event gtid_event(thd, seq_no, domain_id, standalone,
|
||||
LOG_EVENT_SUPPRESS_USE_F, is_transactional,
|
||||
|
@ -430,7 +430,7 @@ sql_mode_t expand_sql_mode(sql_mode_t sql_mode);
|
||||
bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls);
|
||||
int default_regex_flags_pcre(const THD *thd);
|
||||
|
||||
extern sys_var *Sys_autocommit_ptr;
|
||||
extern sys_var *Sys_autocommit_ptr, *Sys_last_gtid_ptr;
|
||||
|
||||
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
|
||||
|
||||
|
@ -1190,7 +1190,7 @@ void THD::init(void)
|
||||
bzero((char *) &org_status_var, sizeof(org_status_var));
|
||||
status_in_global= 0;
|
||||
start_bytes_received= 0;
|
||||
last_commit_gtid.seq_no= 0;
|
||||
m_last_commit_gtid.seq_no= 0;
|
||||
last_stmt= NULL;
|
||||
/* Reset status of last insert id */
|
||||
arg_of_last_insert_id_function= FALSE;
|
||||
@ -6972,6 +6972,21 @@ THD::signal_wakeup_ready()
|
||||
mysql_cond_signal(&COND_wakeup_ready);
|
||||
}
|
||||
|
||||
void THD::set_last_commit_gtid(rpl_gtid >id)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
bool changed_gtid= (m_last_commit_gtid.seq_no != gtid.seq_no);
|
||||
#endif
|
||||
m_last_commit_gtid= gtid;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (changed_gtid &&
|
||||
session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->is_enabled())
|
||||
{
|
||||
session_tracker.get_tracker(SESSION_SYSVARS_TRACKER)->
|
||||
mark_as_changed(this, (LEX_CSTRING*)Sys_last_gtid_ptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
wait_for_commit::reinit()
|
||||
|
@ -4255,7 +4255,13 @@ public:
|
||||
The GTID assigned to the last commit. If no GTID was assigned to any commit
|
||||
so far, this is indicated by last_commit_gtid.seq_no == 0.
|
||||
*/
|
||||
rpl_gtid last_commit_gtid;
|
||||
private:
|
||||
rpl_gtid m_last_commit_gtid;
|
||||
|
||||
public:
|
||||
rpl_gtid get_last_commit_gtid() { return m_last_commit_gtid; }
|
||||
void set_last_commit_gtid(rpl_gtid >id);
|
||||
|
||||
|
||||
LF_PINS *tdc_hash_pins;
|
||||
LF_PINS *xid_hash_pins;
|
||||
|
@ -1828,6 +1828,8 @@ static Sys_var_last_gtid Sys_last_gtid(
|
||||
"or the empty string if none.",
|
||||
READ_ONLY sys_var::ONLY_SESSION, NO_CMD_LINE);
|
||||
|
||||
export sys_var *Sys_last_gtid_ptr= &Sys_last_gtid; // for check changing
|
||||
|
||||
|
||||
uchar *
|
||||
Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_STRING *base)
|
||||
@ -1838,8 +1840,9 @@ Sys_var_last_gtid::session_value_ptr(THD *thd, const LEX_STRING *base)
|
||||
bool first= true;
|
||||
|
||||
str.length(0);
|
||||
if ((thd->last_commit_gtid.seq_no > 0 &&
|
||||
rpl_slave_state_tostring_helper(&str, &thd->last_commit_gtid, &first)) ||
|
||||
rpl_gtid gtid= thd->get_last_commit_gtid();
|
||||
if ((gtid.seq_no > 0 &&
|
||||
rpl_slave_state_tostring_helper(&str, >id, &first)) ||
|
||||
!(p= thd->strmake(str.ptr(), str.length())))
|
||||
{
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0));
|
||||
|
Loading…
x
Reference in New Issue
Block a user