diff options
Diffstat (limited to 'sql/log_event.h')
-rw-r--r-- | sql/log_event.h | 339 |
1 files changed, 230 insertions, 109 deletions
diff --git a/sql/log_event.h b/sql/log_event.h index 39cd55f313e..548541a8767 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1,5 +1,4 @@ -/* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,8 +11,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 +28,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,18 +36,24 @@ #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-" +#define LONG_FIND_ROW_THRESHOLD 60 /* seconds */ /** Either assert or return an error. @@ -252,6 +256,7 @@ 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 /* Max number of possible extra bytes in a replication event compared to a packet (i.e. a query) sent from client to master; @@ -592,6 +597,12 @@ 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 */ @@ -612,7 +623,7 @@ enum Int_event_type }; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER class String; class MYSQL_BIN_LOG; class THD; @@ -690,11 +701,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 @@ -706,6 +715,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. +*/ +typedef struct event_coordinates +{ + char * file_name; // binlog file name (directories stripped) + my_off_t pos; // event's position in the binlog file +} LOG_POS_COORD; /** @class Log_event @@ -866,6 +889,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 @@ -916,8 +964,12 @@ public: LOG_EVENT_SUPPRESS_USE_F for notes. */ uint16 flags; - - bool cache_stmt; + + /* + Defines the type of the cache, if any, where the event will be + stored before being flushed to disk. + */ + uint16 cache_type; /** A storage to cache the global system variable's value. @@ -925,11 +977,11 @@ public: */ ulong slave_exec_mode; -#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 @@ -942,11 +994,11 @@ 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); static int read_log_event(IO_CACHE* file, String* packet, - pthread_mutex_t* log_lock); + mysql_mutex_t* log_lock); /* init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG @@ -990,14 +1042,14 @@ 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 */ static void *operator new(size_t, void* ptr) { return ptr; } static void operator delete(void*, void*) { } -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER bool write_header(IO_CACHE* file, ulong data_length); virtual bool write(IO_CACHE* file) { @@ -1027,7 +1079,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();} @@ -1036,7 +1099,7 @@ public: { if (temp_buf) { - my_free(temp_buf, MYF(0)); + my_free(temp_buf); temp_buf = 0; } } @@ -1060,7 +1123,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: /** @@ -1364,7 +1427,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 @@ -1650,10 +1713,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); @@ -1670,10 +1733,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 @@ -1687,7 +1750,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); @@ -1784,7 +1847,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 @@ -1798,12 +1861,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 }; @@ -2043,6 +2106,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) @@ -2057,13 +2131,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); @@ -2090,7 +2166,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 @@ -2103,7 +2179,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); @@ -2165,7 +2241,7 @@ public: */ bool dont_set_created; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Start_log_event_v3(); #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); @@ -2179,7 +2255,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; } @@ -2189,7 +2265,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*) { @@ -2238,10 +2314,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 @@ -2263,7 +2339,7 @@ public: void calc_server_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); @@ -2315,7 +2391,7 @@ public: ulonglong val; uchar type; -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg) :Log_event(thd_arg,0,0),val(val_arg),type(type_arg) {} @@ -2332,13 +2408,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); @@ -2391,7 +2467,7 @@ 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) :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg) {} @@ -2407,13 +2483,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); @@ -2437,8 +2513,8 @@ 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) {} +#ifdef MYSQL_SERVER + Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, TRUE), xid(x) {} #ifdef HAVE_REPLICATION void pack_info(Protocol* protocol); #endif /* HAVE_REPLICATION */ @@ -2451,13 +2527,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 @@ -2475,6 +2551,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; @@ -2482,12 +2562,14 @@ 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) + uint charset_number_arg, uchar flags_arg) :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg), - val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg) + val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg), + flags(flags_arg) { is_null= !val; } void pack_info(Protocol* protocol); #else @@ -2498,13 +2580,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); @@ -2523,7 +2605,7 @@ private: class Stop_log_event: public Log_event { public: -#ifndef MYSQL_CLIENT +#ifdef MYSQL_SERVER Stop_log_event() :Log_event() {} #else @@ -2539,7 +2621,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) { @@ -2615,7 +2697,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); @@ -2631,17 +2713,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 @@ -2672,10 +2754,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); @@ -2692,7 +2775,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() @@ -2706,7 +2789,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); /* @@ -2717,7 +2800,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 }; @@ -2748,7 +2831,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 @@ -2766,13 +2849,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 }; @@ -2790,7 +2873,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); @@ -2807,13 +2890,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 }; @@ -2831,7 +2914,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); @@ -2847,13 +2930,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 }; @@ -2871,7 +2954,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); @@ -2886,7 +2969,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 }; @@ -2922,13 +3005,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 */ @@ -2947,12 +3030,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 }; @@ -3342,7 +3425,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 @@ -3358,23 +3441,23 @@ public: return new table_def(m_coltype, m_colcnt, m_field_metadata, m_field_metadata_size, m_null_bits, m_flags); } +#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; } -#endif 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 @@ -3384,13 +3467,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; @@ -3486,7 +3569,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 @@ -3501,7 +3584,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); @@ -3515,7 +3598,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; } @@ -3538,7 +3621,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 @@ -3550,11 +3633,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 */ @@ -3583,7 +3666,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 */ @@ -3608,7 +3691,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); @@ -3663,7 +3746,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; }; @@ -3686,7 +3769,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 @@ -3694,7 +3777,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, @@ -3715,7 +3798,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); @@ -3744,7 +3827,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, @@ -3764,7 +3847,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, @@ -3789,11 +3872,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) */ }; /** @@ -3825,7 +3908,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 @@ -3833,7 +3916,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, @@ -3854,7 +3937,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); @@ -3902,7 +3985,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) { @@ -3910,6 +3993,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; } @@ -3919,11 +4003,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 @@ -3936,7 +4021,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 @@ -3968,7 +4053,41 @@ static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE); } -#ifndef MYSQL_CLIENT +#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; +}; + /** The function is called by slave applier in case there are active table filtering rules to force gathering events associated @@ -3978,6 +4097,8 @@ static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, bool slave_execute_deferred_events(THD *thd); #endif +int append_query_string(THD *thd, CHARSET_INFO *csinfo, + String const *from, String *to); /** @} (end of group Replication) */ |