summaryrefslogtreecommitdiff
path: root/sql/log_event.h
diff options
context:
space:
mode:
authormats@romeo.(none) <>2007-03-29 20:31:09 +0200
committermats@romeo.(none) <>2007-03-29 20:31:09 +0200
commit7c187c2c9b0e5ba8796f5499d14ee13543a941ec (patch)
tree94a9332e96292bf9e0fa153652b4fe3ab60db14c /sql/log_event.h
parentb3ade670a681b312437dc29c2c51f1f6344ab3f4 (diff)
downloadmariadb-git-7c187c2c9b0e5ba8796f5499d14ee13543a941ec.tar.gz
WL#3464: Add replication event to denote gap in replication
Adding an event that can be used to denote that an incident occured on the master. The event can be used to denote a gap in the replication stream, but can also be used to denote other incidents. In addition, the injector interface is extended with functions to generate an incident event. The function will also rotate the binary log after generating an incident event to get a fresh binary log.
Diffstat (limited to 'sql/log_event.h')
-rw-r--r--sql/log_event.h98
1 files changed, 97 insertions, 1 deletions
diff --git a/sql/log_event.h b/sql/log_event.h
index 5994beb0df3..9a38bfb51fd 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -22,6 +22,7 @@
#endif
#include <my_bitmap.h>
+#include "rpl_constants.h"
#define LOG_READ_EOF -1
#define LOG_READ_BOGUS -2
@@ -198,7 +199,7 @@ struct sql_ex_info
#define TABLE_MAP_HEADER_LEN 8
#define EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN (4 + 4 + 4 + 1)
#define EXECUTE_LOAD_QUERY_HEADER_LEN (QUERY_HEADER_LEN + EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN)
-
+#define INCIDENT_HEADER_LEN 2
/*
Max number of possible extra bytes in a replication event compared to a
packet (i.e. a query) sent from client to master;
@@ -473,6 +474,11 @@ enum Log_event_type
DELETE_ROWS_EVENT = 22,
/*
+ Something out of the ordinary happened on the master
+ */
+ INCIDENT_EVENT= 23,
+
+ /*
Add new events here - right above this comment!
Existing events (except ENUM_END_EVENT) should never change their numbers
*/
@@ -2207,4 +2213,94 @@ private:
#endif
};
+
+/**
+ Class representing an incident, an occurance out of the ordinary,
+ that happened on the master.
+
+ The event is used to inform the slave that something out of the
+ ordinary happened on the master that might cause the database to be
+ in an inconsistent state.
+
+ <table id="IncidentFormat">
+ <caption>Incident event format</caption>
+ <tr>
+ <th>Symbol</th>
+ <th>Size<br/>(bytes)</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>INCIDENT</td>
+ <td align="right">2</td>
+ <td>Incident number as an unsigned integer</td>
+ </tr>
+ <tr>
+ <td>MSGLEN</td>
+ <td align="right">1</td>
+ <td>Message length as an unsigned integer</td>
+ </tr>
+ <tr>
+ <td>MESSAGE</td>
+ <td align="right">MSGLEN</td>
+ <td>The message, if present. Not null terminated.</td>
+ </tr>
+ </table>
+ */
+class Incident_log_event : public Log_event {
+public:
+#ifndef MYSQL_CLIENT
+ Incident_log_event(THD *thd_arg, Incident incident)
+ : Log_event(thd_arg, 0, FALSE), m_incident(incident)
+ {
+ DBUG_ENTER("Incident_log_event::Incident_log_event");
+ DBUG_PRINT("enter", ("m_incident: %d", m_incident));
+ m_message.str= NULL; /* Just as a precaution */
+ m_message.length= 0;
+ DBUG_VOID_RETURN;
+ }
+
+ Incident_log_event(THD *thd_arg, Incident incident, LEX_STRING const msg)
+ : Log_event(thd_arg, 0, FALSE), m_incident(incident)
+ {
+ DBUG_ENTER("Incident_log_event::Incident_log_event");
+ DBUG_PRINT("enter", ("m_incident: %d", m_incident));
+ m_message= msg;
+ DBUG_VOID_RETURN;
+ }
+#endif
+
+#ifndef MYSQL_CLIENT
+ void pack_info(Protocol*);
+#endif
+
+ Incident_log_event(const char *buf, uint event_len,
+ const Format_description_log_event *descr_event);
+
+ virtual ~Incident_log_event();
+
+#ifdef MYSQL_CLIENT
+ virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
+#endif
+
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+ virtual int exec_event(struct st_relay_log_info *rli);
+#endif
+
+ virtual bool write_data_header(IO_CACHE *file);
+ virtual bool write_data_body(IO_CACHE *file);
+
+ virtual Log_event_type get_type_code() { return INCIDENT_EVENT; }
+
+ virtual bool is_valid() const { return 1; }
+ virtual int get_data_size() {
+ return INCIDENT_HEADER_LEN + 1 + m_message.length;
+ }
+
+private:
+ const char *description() const;
+
+ Incident m_incident;
+ LEX_STRING m_message;
+};
+
#endif /* _log_event_h */