Commit cf2a7c5b authored by unknown's avatar unknown

lp:697174: Do not put absolute path in status variable binlog_snapshot_file.

Omit the directory part to make the output the same as SHOW MASTER STATUS.
parent fea75f40
......@@ -6,7 +6,7 @@ File Position Binlog_Do_DB Binlog_Ignore_DB
master-bin.000001 241
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file ./master-bin.000001
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 241
BEGIN;
INSERT INTO t1 VALUES (0, "");
......@@ -37,7 +37,7 @@ a b
0
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file ./master-bin.000001
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 540
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
......@@ -59,7 +59,7 @@ a b
0
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file ./master-bin.000001
binlog_snapshot_file master-bin.000001
binlog_snapshot_position 540
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
......@@ -67,7 +67,7 @@ master-bin.000002 106
COMMIT;
SHOW STATUS LIKE 'binlog_snapshot_%';
Variable_name Value
binlog_snapshot_file ./master-bin.000002
binlog_snapshot_file master-bin.000002
binlog_snapshot_position 106
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
......
......@@ -6650,6 +6650,18 @@ static struct st_mysql_sys_var *binlog_sys_vars[]=
#endif
/*
Copy out the non-directory part of binlog position filename for the
`binlog_snapshot_file' status variable, same way as it is done for
SHOW MASTER STATUS.
*/
static void
set_binlog_snapshot_file(const char *src)
{
int dir_len = dirname_length(src);
strmake(binlog_snapshot_file, src + dir_len, sizeof(binlog_snapshot_file)-1);
}
/*
Copy out current values of status variables, for SHOW STATUS or
information_schema.global_status.
......@@ -6666,21 +6678,21 @@ TC_LOG_BINLOG::set_status_variables(THD *thd)
else
trx_data= NULL;
bool have_snapshot=
(trx_data && 0 != strcmp(trx_data->last_commit_pos_file, ""));
pthread_mutex_lock(&LOCK_commit_ordered);
binlog_status_var_num_commits= this->num_commits;
binlog_status_var_num_group_commits= this->num_group_commits;
if (!trx_data || 0 == strcmp(trx_data->last_commit_pos_file, ""))
if (!have_snapshot)
{
strmake(binlog_snapshot_file, last_commit_pos_file,
sizeof(binlog_snapshot_file)-1);
set_binlog_snapshot_file(last_commit_pos_file);
binlog_snapshot_position= last_commit_pos_offset;
}
pthread_mutex_unlock(&LOCK_commit_ordered);
if (trx_data && 0 != strcmp(trx_data->last_commit_pos_file, ""))
if (have_snapshot)
{
strmake(binlog_snapshot_file, trx_data->last_commit_pos_file,
sizeof(binlog_snapshot_file)-1);
set_binlog_snapshot_file(trx_data->last_commit_pos_file);
binlog_snapshot_position= trx_data->last_commit_pos_offset;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment