MCPcopy Create free account
hub / github.com/MariaDB/server / show_engine_binlog_events

Function show_engine_binlog_events

sql/sql_repl.cc:4932–5026  ·  view source on GitHub ↗

Version of mysql_show_binlog_events() for --binlog-storage-engine. */

Source from the content-addressed store, hash-verified

4930
4931/* Version of mysql_show_binlog_events() for --binlog-storage-engine. */
4932static bool
4933show_engine_binlog_events(THD* thd, Protocol *protocol, LEX_MASTER_INFO *lex_mi)
4934{
4935 bool err= false;
4936
4937 DBUG_ASSERT(opt_binlog_engine_hton);
4938 DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS);
4939 handler_binlog_reader *reader=
4940 (*opt_binlog_engine_hton->get_binlog_reader)(false);
4941 if (!reader)
4942 {
4943 my_error(ER_OUT_OF_RESOURCES, MYF(0));
4944 return true;
4945 }
4946
4947 ulonglong pos= lex_mi->pos;
4948 /*
4949 The positions "0" and "4" are unfortunately traditionally used
4950 interchangeably to mean "the start of the binlog". Thus, we might here
4951 easily see a starting position of "4", which is probably not valid in
4952 the engine, but which really means "start of the file".
4953
4954 So here we have this ugly hack where "4" means the same as "0". Well,
4955 use of offsets is discourated anyway in the new binlog (in favour of
4956 GTID), and "4" is not going to be a valid position most likely, or if
4957 it is, "0" will be equivalent (at least it is so for the InnoDB binlog
4958 implementation.
4959 */
4960 if (pos == 4)
4961 pos= 0;
4962 if (reader->init_legacy_pos(thd, lex_mi->log_file_name, pos))
4963 {
4964 err= true;
4965 goto end;
4966 }
4967 /* The engine reader will stop at the end of the requested file. */
4968 reader->enable_single_file();
4969
4970 {
4971 SELECT_LEX_UNIT *unit= &thd->lex->unit;
4972 unit->set_limit(thd->lex->current_select);
4973 uint64_t file_no= reader->cur_file_no;
4974 ha_rows limit= unit->lim.get_select_limit();
4975 String packet;
4976 Format_description_log_event fd(4);
4977 char name_buf[FN_REFLEN];
4978 opt_binlog_engine_hton->get_filename(name_buf, file_no);
4979
4980 for (ha_rows event_count= 0; event_count < limit; ++event_count)
4981 {
4982 packet.length(0);
4983 int reader_error= reader->read_log_event(&packet, 0,
4984 thd->variables.max_allowed_packet + MAX_LOG_EVENT_HEADER);
4985 if (reader_error)
4986 {
4987 if (reader_error != LOG_READ_EOF)
4988 {
4989 my_error(ER_ERROR_WHEN_EXECUTING_COMMAND, MYF(0),

Callers 1

mysql_show_binlog_eventsFunction · 0.85

Calls 11

my_errorFunction · 0.85
my_eofFunction · 0.85
get_select_limitMethod · 0.80
check_offsetMethod · 0.80
net_sendMethod · 0.80
init_legacy_posMethod · 0.45
enable_single_fileMethod · 0.45
set_limitMethod · 0.45
lengthMethod · 0.45
read_log_eventMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected