diff options
Diffstat (limited to 'sql/log_event.h')
-rw-r--r-- | sql/log_event.h | 411 |
1 files changed, 264 insertions, 147 deletions
diff --git a/sql/log_event.h b/sql/log_event.h index 5dcf8c736a1..5c0a82b2dac 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -12,8 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** @addtogroup Replication @@ -30,7 +29,7 @@ #ifndef _log_event_h #define _log_event_h -#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT) +#if defined(USE_PRAGMA_INTERFACE) && defined(MYSQL_SERVER) #pragma interface /* gcc class implementation */ #endif @@ -38,17 +37,22 @@ #include "rpl_constants.h" #ifdef MYSQL_CLIENT +#include "sql_const.h" #include "rpl_utility.h" #include "hash.h" #include "rpl_tblmap.h" #include "rpl_tblmap.cc" #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER #include "rpl_record.h" #include "rpl_reporting.h" +#include "sql_class.h" /* THD */ #endif +/* Forward declarations */ +class String; + #define PREFIX_SQL_LOAD "SQL_LOAD-" /** @@ -253,7 +257,9 @@ struct sql_ex_info #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 +#define HEARTBEAT_HEADER_LEN 0 #define ANNOTATE_ROWS_HEADER_LEN 0 + /* Max number of possible extra bytes in a replication event compared to a packet (i.e. a query) sent from client to master; @@ -605,6 +611,17 @@ enum Log_event_type */ INCIDENT_EVENT= 26, + /* + Heartbeat event to be send by master at its idle time + to ensure master's online status to slave + */ + HEARTBEAT_LOG_EVENT= 27, + + /* + Add new events here - right above this comment! + Existing events (except ENUM_END_EVENT) should never change their numbers + */ + /* New MySQL/Sun events are to be added right above this comment */ MYSQL_EVENTS_END, @@ -612,9 +629,7 @@ enum Log_event_type /* New Maria event numbers start from here */ ANNOTATE_ROWS_EVENT= 160, - /* - Existing events (except ENUM_END_EVENT) should never change their numbers - */ + /* Add new MariaDB events here - right above this comment! */ ENUM_END_EVENT /* end marker */ }; @@ -632,7 +647,7 @@ enum Int_event_type }; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER class String; class MYSQL_BIN_LOG; class THD; @@ -676,7 +691,7 @@ typedef struct st_print_event_info bool flags2_inited; uint32 flags2; bool sql_mode_inited; - ulong sql_mode; /* must be same as THD.variables.sql_mode */ + ulonglong sql_mode; /* must be same as THD.variables.sql_mode */ ulong auto_increment_increment, auto_increment_offset; bool charset_inited; char charset[6]; // 3 variables, each of them storable in 2 bytes @@ -710,11 +725,9 @@ typedef struct st_print_event_info uint8 common_header_len; char delimiter[16]; -#ifdef MYSQL_CLIENT uint verbose; table_mapping m_table_map; table_mapping m_table_map_ignored; -#endif /* These two caches are used by the row-based replication events to @@ -726,6 +739,20 @@ typedef struct st_print_event_info } PRINT_EVENT_INFO; #endif +/** + the struct aggregates two paramenters that identify an event + uniquely in scope of communication of a particular master and slave couple. + I.e there can not be 2 events from the same staying connected master which + have the same coordinates. + @note + Such identifier is not yet unique generally as the event originating master + is resetable. Also the crashed master can be replaced with some other. +*/ +struct event_coordinates +{ + char * file_name; // binlog file name (directories stripped) + my_off_t pos; // event's position in the binlog file +}; /** @class Log_event @@ -886,6 +913,31 @@ public: EVENT_SKIP_COUNT }; + enum enum_event_cache_type + { + EVENT_INVALID_CACHE, + /* + If possible the event should use a non-transactional cache before + being flushed to the binary log. This means that it must be flushed + right after its correspondent statement is completed. + */ + EVENT_STMT_CACHE, + /* + The event should use a transactional cache before being flushed to + the binary log. This means that it must be flushed upon commit or + rollback. + */ + EVENT_TRANSACTIONAL_CACHE, + /* + The event must be written directly to the binary log without going + through a cache. + */ + EVENT_NO_CACHE, + /** + If there is a need for different types, introduce them before this. + */ + EVENT_CACHE_COUNT + }; /* The following type definition is to be used whenever data is placed @@ -945,28 +997,7 @@ public: */ uint16 flags; - bool cache_stmt; - /* - The revid:alfranio.correia@sun.com-20091103190256-637o8qxlveikrt3i commit - ("WL#2687 WL#5072 BUG#40278 BUG#47175") in MySQL 5.5 changes the bool - cache_stmt into an enum cache_type. For the backport of WL#2540 binlog - event checksum, we need this event_type member to know if we are writing - directly to the log, or into a transaction cache. - - Until the cache_type stuff is merged, we temporarily partially backport - the cache_type member, only enough to be able to check if we are writing - directly to log or not. Once MySQL 5.5 is merged, this can be removed, and - replaced with the MySQL 5.5 code. - - Similarly, in MySQL 5.5 the decision on whether to write directly to log - or indirectly through cache is decided differently, and the - pre_55_writing_direct() (and all calls to it) are not needed and can be - removed once 5.5 is merged. - */ - enum enum_event_cache_type { EVENT_INVALID_CACHE, EVENT_STMT_CACHE, - EVENT_TRANSACTIONAL_CACHE, EVENT_NO_CACHE }; uint16 cache_type; - void pre_55_writing_direct() { cache_type= EVENT_NO_CACHE; } /** A storage to cache the global system variable's value. @@ -978,11 +1009,12 @@ public: Placeholder for event checksum while writing to binlog. */ ha_checksum crc; -#ifndef MYSQL_CLIENT + +#ifdef MYSQL_SERVER THD* thd; Log_event(); - Log_event(THD* thd_arg, uint16 flags_arg, bool cache_stmt); + Log_event(THD* thd_arg, uint16 flags_arg, bool is_transactional); /* read_log_event() functions read an event from a binlog or relay log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the @@ -995,12 +1027,12 @@ public: constructor and pass description_event as an argument. */ static Log_event* read_log_event(IO_CACHE* file, - pthread_mutex_t* log_lock, + mysql_mutex_t* log_lock, const Format_description_log_event *description_event, my_bool crc_check); static int read_log_event(IO_CACHE* file, String* packet, - pthread_mutex_t* log_lock, uint8 checksum_alg_arg); + mysql_mutex_t* log_lock, uint8 checksum_alg_arg); /* init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG @@ -1053,7 +1085,7 @@ public: static void operator delete(void *ptr, size_t) { - my_free(ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); + my_free(ptr); } /* Placement version of the above operators */ @@ -1061,7 +1093,7 @@ public: static void operator delete(void*, void*) { } bool wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong data_length); -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_header(IO_CACHE* file, ulong data_length); bool write_footer(IO_CACHE* file); my_bool need_checksum(); @@ -1107,7 +1139,18 @@ public: void set_relay_log_event() { flags |= LOG_EVENT_RELAY_LOG_F; } bool is_artificial_event() const { return flags & LOG_EVENT_ARTIFICIAL_F; } bool is_relay_log_event() const { return flags & LOG_EVENT_RELAY_LOG_F; } - inline bool get_cache_stmt() const { return cache_stmt; } + inline bool use_trans_cache() const + { + return (cache_type == Log_event::EVENT_TRANSACTIONAL_CACHE); + } + inline void set_direct_logging() + { + cache_type = Log_event::EVENT_NO_CACHE; + } + inline bool use_direct_logging() + { + return (cache_type == Log_event::EVENT_NO_CACHE); + } Log_event(const char* buf, const Format_description_log_event *description_event); virtual ~Log_event() { free_temp_buf();} @@ -1121,7 +1164,7 @@ public: if (temp_buf) { if (event_owns_temp_buf) - my_free(temp_buf, MYF(0)); + my_free(temp_buf); temp_buf = 0; } } @@ -1145,7 +1188,7 @@ public: /* Return start of query time or current time */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) public: /** @@ -1449,7 +1492,7 @@ protected: <td>Q_SQL_MODE_CODE == 1</td> <td>8 byte bitfield</td> <td>The @c sql_mode variable. See the section "SQL Modes" in the - MySQL manual, and see mysql_priv.h for a list of the possible + MySQL manual, and see sql_priv.h for a list of the possible flags. Currently (2007-10-04), the following flags are available: <pre> MODE_REAL_AS_FLOAT==0x1 @@ -1712,7 +1755,7 @@ public: uint32 flags2; /* In connections sql_mode is 32 bits now but will be 64 bits soon */ - ulong sql_mode; + ulonglong sql_mode; ulong auto_increment_increment, auto_increment_offset; char charset[6]; uint time_zone_len; /* 0 means uninited */ @@ -1735,10 +1778,10 @@ public: */ uint32 master_data_written; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length, - bool using_trans, bool suppress_use, int error); + bool using_trans, bool direct, bool suppress_use, int error); const char* get_db() { return db; } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -1755,10 +1798,10 @@ public: ~Query_log_event() { if (data_buf) - my_free((uchar*) data_buf, MYF(0)); + my_free(data_buf); } Log_event_type get_type_code() { return QUERY_EVENT; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; } #endif @@ -1772,7 +1815,7 @@ public: /* Writes derived event-specific part of post header. */ public: /* !!! Public in this patch to allow old usage */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); @@ -1869,7 +1912,7 @@ public: int master_log_len; uint16 master_port; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Slave_log_event(THD* thd_arg, Relay_log_info* rli); void pack_info(Protocol* protocol); #else @@ -1883,12 +1926,12 @@ public: int get_data_size(); bool is_valid() const { return master_host != 0; } Log_event_type get_type_code() { return SLAVE_EVENT; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const* rli); #endif }; @@ -2128,6 +2171,17 @@ public: uint32 skip_lines; sql_ex_info sql_ex; bool local_fname; + /** + Indicates that this event corresponds to LOAD DATA CONCURRENT, + + @note Since Load_log_event event coming from the binary log + lacks information whether LOAD DATA on master was concurrent + or not, this flag is only set to TRUE for an auxiliary + Load_log_event object which is used in mysql_load() to + re-construct LOAD DATA statement from function parameters, + for logging. + */ + bool is_concurrent; /* fname doesn't point to memory inside Log_event::temp_buf */ void set_fname_outside_temp_buf(const char *afname, uint alen) @@ -2142,13 +2196,15 @@ public: return local_fname; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER String field_lens_buf; String fields_buf; Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg, const char* table_name_arg, - List<Item>& fields_arg, enum enum_duplicates handle_dup, bool ignore, + List<Item>& fields_arg, + bool is_concurrent_arg, + enum enum_duplicates handle_dup, bool ignore, bool using_trans); void set_fields(const char* db, List<Item> &fields_arg, Name_resolution_context *context); @@ -2175,7 +2231,7 @@ public: { return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_data_header(IO_CACHE* file); bool write_data_body(IO_CACHE* file); #endif @@ -2188,7 +2244,7 @@ public: } public: /* !!! Public in this patch to allow old usage */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const* rli) { return do_apply_event(thd->slave_net,rli,0); @@ -2199,8 +2255,6 @@ public: /* !!! Public in this patch to allow old usage */ #endif }; -extern char server_version[SERVER_VERSION_LENGTH]; - /** @class Start_log_event_v3 @@ -2250,7 +2304,7 @@ public: */ bool dont_set_created; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Start_log_event_v3(); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -2264,7 +2318,7 @@ public: const Format_description_log_event* description_event); ~Start_log_event_v3() {} Log_event_type get_type_code() { return START_EVENT_V3;} -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const { return 1; } @@ -2274,7 +2328,7 @@ public: } protected: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info*) { @@ -2331,10 +2385,10 @@ public: *description_event); ~Format_description_log_event() { - my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR)); + my_free(post_header_len); } Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;} -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const @@ -2354,9 +2408,9 @@ public: } void calc_server_version_split(); - static bool is_version_before_checksum(master_version_split *version_split); + static bool is_version_before_checksum(const master_version_split *version_split); protected: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); @@ -2408,11 +2462,14 @@ public: ulonglong val; uchar type; -#ifndef MYSQL_CLIENT - Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg, - uint16 cache_type_arg) - :Log_event(thd_arg,0,0), val(val_arg), type(type_arg) - { cache_type= cache_type_arg; } +#ifdef MYSQL_SERVER +Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg, + bool using_trans, bool direct) + :Log_event(thd_arg,0,using_trans),val(val_arg),type(type_arg) + { + if (direct) + cache_type= Log_event::EVENT_NO_CACHE; + } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ @@ -2426,13 +2483,13 @@ public: Log_event_type get_type_code() { return INTVAR_EVENT;} const char* get_var_type_name(); int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;} -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const { return 1; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); @@ -2485,11 +2542,14 @@ class Rand_log_event: public Log_event ulonglong seed1; ulonglong seed2; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg, - uint16 cache_type_arg) - :Log_event(thd_arg, 0, 0), seed1(seed1_arg), seed2(seed2_arg) - { cache_type= cache_type_arg; } + bool using_trans, bool direct) + :Log_event(thd_arg,0,using_trans),seed1(seed1_arg),seed2(seed2_arg) + { + if (direct) + cache_type= Log_event::EVENT_NO_CACHE; + } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ @@ -2502,13 +2562,13 @@ class Rand_log_event: public Log_event ~Rand_log_event() {} Log_event_type get_type_code() { return RAND_EVENT;} int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const { return 1; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); @@ -2532,9 +2592,13 @@ class Xid_log_event: public Log_event public: my_xid xid; -#ifndef MYSQL_CLIENT - Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, 0), xid(x) - { cache_type= EVENT_NO_CACHE; } +#ifdef MYSQL_SERVER + Xid_log_event(THD* thd_arg, my_xid x, bool direct): + Log_event(thd_arg, 0, TRUE), xid(x) + { + if (direct) + cache_type= Log_event::EVENT_NO_CACHE; + } #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ @@ -2547,13 +2611,13 @@ class Xid_log_event: public Log_event ~Xid_log_event() {} Log_event_type get_type_code() { return XID_EVENT;} int get_data_size() { return sizeof(xid); } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const { return 1; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); enum_skip_reason do_shall_skip(Relay_log_info *rli); #endif @@ -2571,6 +2635,10 @@ private: class User_var_log_event: public Log_event { public: + enum { + UNDEF_F= 0, + UNSIGNED_F= 1 + }; char *name; uint name_len; char *val; @@ -2578,14 +2646,21 @@ public: Item_result type; uint charset_number; bool is_null; -#ifndef MYSQL_CLIENT + uchar flags; +#ifdef MYSQL_SERVER User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg, char *val_arg, ulong val_len_arg, Item_result type_arg, - uint charset_number_arg, - uint16 cache_type_arg) - :Log_event(thd_arg, 0, 0), name(name_arg), name_len(name_len_arg), val(val_arg), - val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg) - { is_null= !val; cache_type= cache_type_arg; } + uint charset_number_arg, uchar flags_arg, + bool using_trans, bool direct) + :Log_event(thd_arg, 0, using_trans), + name(name_arg), name_len(name_len_arg), val(val_arg), + val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg), + flags(flags_arg) + { + is_null= !val; + if (direct) + cache_type= Log_event::EVENT_NO_CACHE; + } void pack_info(Protocol* protocol); #else void print(FILE* file, PRINT_EVENT_INFO* print_event_info); @@ -2595,13 +2670,13 @@ public: const Format_description_log_event *description_event); ~User_var_log_event() {} Log_event_type get_type_code() { return USER_VAR_EVENT;} -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif bool is_valid() const { return 1; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); @@ -2620,7 +2695,7 @@ private: class Stop_log_event: public Log_event { public: -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Stop_log_event() :Log_event() {} #else @@ -2636,7 +2711,7 @@ public: bool is_valid() const { return 1; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli) { @@ -2712,7 +2787,7 @@ public: ulonglong pos; uint ident_len; uint flags; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Rotate_log_event(const char* new_log_ident_arg, uint ident_len_arg, ulonglong pos_arg, uint flags); @@ -2728,17 +2803,17 @@ public: ~Rotate_log_event() { if (flags & DUP_NAME) - my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR)); + my_free((void*) new_log_ident); } Log_event_type get_type_code() { return ROTATE_EVENT;} int get_data_size() { return ident_len + ROTATE_HEADER_LEN;} bool is_valid() const { return new_log_ident != 0; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); #endif @@ -2769,10 +2844,11 @@ public: uint file_id; bool inited_from_old; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg, const char* table_name_arg, List<Item>& fields_arg, + bool is_concurrent_arg, enum enum_duplicates handle_dup, bool ignore, uchar* block_arg, uint block_len_arg, bool using_trans); @@ -2789,7 +2865,7 @@ public: const Format_description_log_event* description_event); ~Create_file_log_event() { - my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR)); + my_free((void*) event_buf); } Log_event_type get_type_code() @@ -2803,7 +2879,7 @@ public: 4 + 1 + block_len); } bool is_valid() const { return inited_from_old || block != 0; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_data_header(IO_CACHE* file); bool write_data_body(IO_CACHE* file); /* @@ -2814,7 +2890,7 @@ public: #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif }; @@ -2845,7 +2921,7 @@ public: */ const char* db; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg, uint block_len_arg, bool using_trans); #ifdef HAVE_REPLICATION @@ -2863,13 +2939,13 @@ public: Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;} int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;} bool is_valid() const { return block != 0; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); const char* get_db() { return db; } #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif }; @@ -2887,7 +2963,7 @@ public: uint file_id; const char* db; /* see comment in Append_block_log_event */ -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -2904,13 +2980,13 @@ public: Log_event_type get_type_code() { return DELETE_FILE_EVENT;} int get_data_size() { return DELETE_FILE_HEADER_LEN ;} bool is_valid() const { return file_id != 0; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); const char* get_db() { return db; } #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif }; @@ -2928,7 +3004,7 @@ public: uint file_id; const char* db; /* see comment in Append_block_log_event */ -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -2944,13 +3020,13 @@ public: Log_event_type get_type_code() { return EXEC_LOAD_EVENT;} int get_data_size() { return EXEC_LOAD_HEADER_LEN ;} bool is_valid() const { return file_id != 0; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write(IO_CACHE* file); const char* get_db() { return db; } #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif }; @@ -2968,7 +3044,7 @@ private: class Begin_load_query_log_event: public Append_block_log_event { public: -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Begin_load_query_log_event(THD* thd_arg, const char *db_arg, uchar* block_arg, uint block_len_arg, bool using_trans); @@ -2983,7 +3059,7 @@ public: ~Begin_load_query_log_event() {} Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; } private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); #endif }; @@ -3019,13 +3095,13 @@ public: */ enum_load_dup_handling dup_handling; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Execute_load_query_log_event(THD* thd, const char* query_arg, ulong query_length, uint fn_pos_start_arg, uint fn_pos_end_arg, enum_load_dup_handling dup_handling_arg, - bool using_trans, bool suppress_use, - int errcode); + bool using_trans, bool direct, + bool suppress_use, int errcode); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ @@ -3044,12 +3120,12 @@ public: bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; } ulong get_post_header_size_for_derived(); -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_post_header_for_derived(IO_CACHE* file); #endif private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif }; @@ -3097,7 +3173,7 @@ class Annotate_rows_log_event: public Log_event { public: #ifndef MYSQL_CLIENT - Annotate_rows_log_event(THD*, uint16 cache_type_arg); + Annotate_rows_log_event(THD*, bool using_trans, bool direct); #endif Annotate_rows_log_event(const char *buf, uint event_len, const Format_description_log_event*); @@ -3492,7 +3568,7 @@ public: flag_set get_flags(flag_set flag) const { return m_flags & flag; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, bool is_transactional); #endif #ifdef HAVE_REPLICATION @@ -3508,25 +3584,25 @@ public: return new table_def(m_coltype, m_colcnt, m_field_metadata, m_field_metadata_size, m_null_bits, m_flags); } - ulong get_table_id() const { return m_table_id; } - const char *get_table_name() const { return m_tblnam; } - const char *get_db_name() const { return m_dbnam; } int rewrite_db(const char* new_name, size_t new_name_len, const Format_description_log_event*); #endif + ulong get_table_id() const { return m_table_id; } + const char *get_table_name() const { return m_tblnam; } + const char *get_db_name() const { return m_dbnam; } virtual Log_event_type get_type_code() { return TABLE_MAP_EVENT; } virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ } virtual int get_data_size() { return (uint) m_data_size; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER virtual int save_field_metadata(); virtual bool write_data_header(IO_CACHE *file); virtual bool write_data_body(IO_CACHE *file); virtual const char *get_db() { return m_dbnam; } #endif -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual void pack_info(Protocol *protocol); #endif @@ -3536,13 +3612,13 @@ public: private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER TABLE *m_table; #endif char const *m_dbnam; @@ -3638,7 +3714,7 @@ public: void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; } flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; } -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual void pack_info(Protocol *protocol); #endif @@ -3653,7 +3729,7 @@ public: const uchar *ptr, const uchar *prefix); #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER int add_row_data(uchar *data, size_t length) { return do_add_row_data(data,length); @@ -3667,7 +3743,7 @@ public: size_t get_width() const { return m_width; } ulong get_table_id() const { return m_table_id; } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER virtual bool write_data_header(IO_CACHE *file); virtual bool write_data_body(IO_CACHE *file); virtual const char *get_db() { return m_table->s->db.str; } @@ -3690,7 +3766,7 @@ protected: The constructors are protected since you're supposed to inherit this class, not create instances of this class. */ -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Rows_log_event(THD*, TABLE*, ulong table_id, MY_BITMAP const *cols, bool is_transactional); #endif @@ -3702,11 +3778,11 @@ protected: void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name); #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER virtual int do_add_row_data(uchar *data, size_t length); #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER TABLE *m_table; /* The table the rows belong to */ #endif ulong m_table_id; /* Table ID */ @@ -3735,7 +3811,7 @@ protected: /* helper functions */ -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) const uchar *m_curr_row; /* Start of the row being processed */ const uchar *m_curr_row_end; /* One-after the end of the current row */ uchar *m_key; /* Buffer to keep key value during searches */ @@ -3763,7 +3839,7 @@ protected: private: -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); virtual int do_update_pos(Relay_log_info *rli); virtual enum_skip_reason do_shall_skip(Relay_log_info *rli); @@ -3818,7 +3894,7 @@ private: */ virtual int do_exec_row(const Relay_log_info *const rli) = 0; -#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ +#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */ friend class Old_rows_log_event; }; @@ -3841,7 +3917,7 @@ public: TYPE_CODE = WRITE_ROWS_EVENT }; -#if !defined(MYSQL_CLIENT) +#if defined(MYSQL_SERVER) Write_rows_log_event(THD*, TABLE*, ulong table_id, MY_BITMAP const *cols, bool is_transactional); #endif @@ -3849,7 +3925,7 @@ public: Write_rows_log_event(const char *buf, uint event_len, const Format_description_log_event *description_event); #endif -#if !defined(MYSQL_CLIENT) +#if defined(MYSQL_SERVER) static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, MY_BITMAP *cols, @@ -3870,7 +3946,7 @@ private: void print(FILE *file, PRINT_EVENT_INFO *print_event_info); #endif -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_before_row_operations(const Slave_reporting_capability *const); virtual int do_after_row_operations(const Slave_reporting_capability *const,int); virtual int do_exec_row(const Relay_log_info *const); @@ -3899,7 +3975,7 @@ public: TYPE_CODE = UPDATE_ROWS_EVENT }; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Update_rows_log_event(THD*, TABLE*, ulong table_id, MY_BITMAP const *cols_bi, MY_BITMAP const *cols_ai, @@ -3919,7 +3995,7 @@ public: const Format_description_log_event *description_event); #endif -#if !defined(MYSQL_CLIENT) +#ifdef MYSQL_SERVER static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, MY_BITMAP *cols, @@ -3944,11 +4020,11 @@ protected: void print(FILE *file, PRINT_EVENT_INFO *print_event_info); #endif -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_before_row_operations(const Slave_reporting_capability *const); virtual int do_after_row_operations(const Slave_reporting_capability *const,int); virtual int do_exec_row(const Relay_log_info *const); -#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ +#endif /* defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) */ }; /** @@ -3980,7 +4056,7 @@ public: TYPE_CODE = DELETE_ROWS_EVENT }; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Delete_rows_log_event(THD*, TABLE*, ulong, MY_BITMAP const *cols, bool is_transactional); #endif @@ -3988,7 +4064,7 @@ public: Delete_rows_log_event(const char *buf, uint event_len, const Format_description_log_event *description_event); #endif -#if !defined(MYSQL_CLIENT) +#ifdef MYSQL_SERVER static bool binlog_row_logging_function(THD *thd, TABLE *table, bool is_transactional, MY_BITMAP *cols, @@ -4009,7 +4085,7 @@ protected: void print(FILE *file, PRINT_EVENT_INFO *print_event_info); #endif -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_before_row_operations(const Slave_reporting_capability *const); virtual int do_after_row_operations(const Slave_reporting_capability *const,int); virtual int do_exec_row(const Relay_log_info *const); @@ -4057,7 +4133,7 @@ protected: */ class Incident_log_event : public Log_event { public: -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Incident_log_event(THD *thd_arg, Incident incident) : Log_event(thd_arg, 0, FALSE), m_incident(incident) { @@ -4065,6 +4141,7 @@ public: DBUG_PRINT("enter", ("m_incident: %d", m_incident)); m_message.str= NULL; /* Just as a precaution */ m_message.length= 0; + set_direct_logging(); DBUG_VOID_RETURN; } @@ -4074,11 +4151,12 @@ public: DBUG_ENTER("Incident_log_event::Incident_log_event"); DBUG_PRINT("enter", ("m_incident: %d", m_incident)); m_message= msg; + set_direct_logging(); DBUG_VOID_RETURN; } #endif -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER void pack_info(Protocol*); #endif @@ -4091,7 +4169,7 @@ public: virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info); #endif -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) +#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION) virtual int do_apply_event(Relay_log_info const *rli); #endif @@ -4123,6 +4201,45 @@ static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE); } +#ifdef MYSQL_SERVER +/***************************************************************************** + + Heartbeat Log Event class + + Replication event to ensure to slave that master is alive. + The event is originated by master's dump thread and sent straight to + slave without being logged. Slave itself does not store it in relay log + but rather uses a data for immediate checks and throws away the event. + + Two members of the class log_ident and Log_event::log_pos comprise + @see the event_coordinates instance. The coordinates that a heartbeat + instance carries correspond to the last event master has sent from + its binlog. + + ****************************************************************************/ +class Heartbeat_log_event: public Log_event +{ +public: + Heartbeat_log_event(const char* buf, uint event_len, + const Format_description_log_event* description_event); + Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; } + bool is_valid() const + { + return (log_ident != NULL && + log_pos >= BIN_LOG_HEADER_SIZE); + } + const char * get_log_ident() { return log_ident; } + uint get_ident_len() { return ident_len; } + +private: + const char* log_ident; + uint ident_len; +}; +#endif + +int append_query_string(CHARSET_INFO *csinfo, + String const *from, String *to); + bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos, const char **group_relay_log_name, ulonglong *relay_log_pos); |