mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-34705: Binlog-in-engine: Implement legacy SHOW MASTER STATUS
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
@@ -14,6 +14,9 @@ DROP TABLE t1;
|
||||
SELECT @@GLOBAL.binlog_checksum;
|
||||
@@GLOBAL.binlog_checksum
|
||||
NONE
|
||||
SHOW MASTER STATUS;
|
||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||
binlog-000000.ibb 767
|
||||
CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(2048)) ENGINE=InnoDB;
|
||||
SET SESSION binlog_format= ROW;
|
||||
*** Do 1500 transactions ...
|
||||
|
@@ -19,6 +19,16 @@ SELECT * FROM t1 ORDER BY a;
|
||||
DROP TABLE t1;
|
||||
SELECT @@GLOBAL.binlog_checksum;
|
||||
|
||||
# This output will depend on exact size of events, which might change over time.
|
||||
# If it changes, make the test abort after the SHOW MASTER STATUS, and check
|
||||
# that the reported new binlog position is correct, it should be the point
|
||||
# where the file starts containing only zero bytes.
|
||||
#
|
||||
# If this gets too annoying to do, we can replace this with something that
|
||||
# checks that the reported file and position is within some reasonable range
|
||||
# of the value left by current code.
|
||||
SHOW MASTER STATUS;
|
||||
|
||||
CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(2048)) ENGINE=InnoDB;
|
||||
|
||||
SET SESSION binlog_format= ROW;
|
||||
|
@@ -1564,7 +1564,12 @@ struct handlerton
|
||||
void (*binlog_oob_free)(THD *thd, void *engine_data);
|
||||
/* Obtain an object to allow reading from the binlog. */
|
||||
handler_binlog_reader * (*get_binlog_reader)();
|
||||
/* Obtain list of binlog files (SHOw BINARY LOGS). */
|
||||
/*
|
||||
Obtain the current position in the binlog.
|
||||
Used to support legacy SHOW MASTER STATUS.
|
||||
*/
|
||||
void (*binlog_status)(char out_filename[FN_REFLEN], ulonglong *out_pos);
|
||||
/* Obtain list of binlog files (SHOW BINARY LOGS). */
|
||||
binlog_file_entry * (*get_binlog_file_list)(MEM_ROOT *mem_root);
|
||||
/*
|
||||
End the current binlog file, and create and switch to a new one.
|
||||
|
@@ -5153,14 +5153,28 @@ bool show_binlog_info(THD* thd)
|
||||
protocol->prepare_for_resend();
|
||||
|
||||
if (mysql_bin_log.is_open())
|
||||
{
|
||||
const char *base;
|
||||
ulonglong pos;
|
||||
if (opt_binlog_engine_hton)
|
||||
{
|
||||
char buf[FN_REFLEN];
|
||||
mysql_mutex_lock(mysql_bin_log.get_log_lock());
|
||||
(*opt_binlog_engine_hton->binlog_status)(buf, &pos);
|
||||
mysql_mutex_unlock(mysql_bin_log.get_log_lock());
|
||||
base= buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO li;
|
||||
mysql_bin_log.get_current_log(&li);
|
||||
pos= (ulonglong) li.pos;
|
||||
size_t dir_len = dirname_length(li.log_file_name);
|
||||
const char *base= li.log_file_name + dir_len;
|
||||
base= li.log_file_name + dir_len;
|
||||
}
|
||||
|
||||
protocol->store(base, strlen(base), &my_charset_bin);
|
||||
protocol->store((ulonglong) li.pos);
|
||||
protocol->store(pos);
|
||||
protocol->store(binlog_filter->get_do_db());
|
||||
protocol->store(binlog_filter->get_ignore_db());
|
||||
if (protocol->write())
|
||||
|
@@ -4135,6 +4135,7 @@ static int innodb_init(void* p)
|
||||
innobase_hton->binlog_oob_free= innodb_free_oob;
|
||||
innobase_hton->get_binlog_reader= innodb_get_binlog_reader;
|
||||
innobase_hton->get_binlog_file_list= innodb_get_binlog_file_list;
|
||||
innobase_hton->binlog_status= innodb_binlog_status;
|
||||
innobase_hton->binlog_flush= innodb_binlog_flush;
|
||||
innobase_hton->binlog_get_init_state= innodb_binlog_get_init_state;
|
||||
innobase_hton->reset_binlogs= innodb_reset_binlogs;
|
||||
|
@@ -2219,6 +2219,19 @@ innodb_find_binlogs(uint64_t *out_first, uint64_t *out_last)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
innodb_binlog_status(char out_filename[FN_REFLEN], ulonglong *out_pos)
|
||||
{
|
||||
static_assert(BINLOG_NAME_MAX_LEN <= FN_REFLEN,
|
||||
"FN_REFLEN too shot to hold InnoDB binlog name");
|
||||
uint64_t file_no= active_binlog_file_no.load(std::memory_order_relaxed);
|
||||
uint32_t page_no= binlog_cur_page_no;
|
||||
uint32_t in_page_offset= binlog_cur_page_offset;
|
||||
binlog_name_make_short(out_filename, file_no);
|
||||
*out_pos= ((ulonglong)page_no << srv_page_size_shift) | in_page_offset;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
innodb_binlog_get_init_state(rpl_binlog_state_base *out_state)
|
||||
{
|
||||
|
@@ -135,6 +135,8 @@ extern bool innobase_binlog_write_direct
|
||||
(IO_CACHE *cache, handler_binlog_event_group_info *binlog_info,
|
||||
const rpl_gtid *gtid);
|
||||
extern bool innodb_find_binlogs(uint64_t *out_first, uint64_t *out_last);
|
||||
extern void innodb_binlog_status(char out_filename[FN_REFLEN],
|
||||
ulonglong *out_pos);
|
||||
extern bool innodb_binlog_get_init_state(rpl_binlog_state_base *out_state);
|
||||
extern bool innodb_reset_binlogs();
|
||||
extern int innodb_binlog_purge(handler_binlog_purge_info *purge_info);
|
||||
|
Reference in New Issue
Block a user