32
32
#ifndef _log_event_h
33
33
#define _log_event_h
35
#if defined(USE_PRAGMA_INTERFACE)
35
#if defined(USE_PRAGMA_INTERFACE) && !defined(DRIZZLE_CLIENT)
36
36
#pragma interface /* gcc class implementation */
39
39
#include <mysys/my_bitmap.h>
40
40
#include "rpl_constants.h"
41
#ifndef DRIZZLE_CLIENT
41
42
#include "rpl_record.h"
42
43
#include "rpl_reporting.h"
45
#include "my_decimal.h"
44
48
#include <drizzled/sql_string.h> /* append_query_string() needs String declaration */
456
460
/* Shouldn't be defined before */
457
461
#define EXPECTED_OPTIONS \
458
((1U << 14) | (1U << 26) | (1U << 27) | (1U << 19))
462
((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19))
460
464
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
461
465
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
554
#ifndef DRIZZLE_CLIENT
551
556
class DRIZZLE_BIN_LOG;
554
560
class Format_description_log_event;
555
561
class Relay_log_info;
563
#ifdef DRIZZLE_CLIENT
564
enum enum_base64_output_mode {
565
BASE64_OUTPUT_NEVER= 0,
566
BASE64_OUTPUT_AUTO= 1,
567
BASE64_OUTPUT_ALWAYS= 2,
568
BASE64_OUTPUT_UNSPEC= 3,
569
/* insert new output modes here */
570
BASE64_OUTPUT_MODE_COUNT
574
A structure for mysqlbinlog to know how to print events
576
This structure is passed to the event's print() methods,
578
There are two types of settings stored here:
579
1. Last db, flags2, sql_mode etc comes from the last printed event.
580
They are stored so that only the necessary USE and SET commands
582
2. Other information on how to print the events, e.g. short_form,
583
hexdump_from. These are not dependent on the last event.
585
typedef struct st_print_event_info
588
Settings for database, sql_mode etc that comes from the last event
589
that was printed. We cache these so that we don't have to print
590
them if they are unchanged.
592
// TODO: have the last catalog here ??
593
char db[FN_REFLEN+1]; // TODO: make this a LEX_STRING when thd->db is
596
bool sql_mode_inited;
597
ulong sql_mode; /* must be same as THD.variables.sql_mode */
598
ulong auto_increment_increment, auto_increment_offset;
600
char charset[6]; // 3 variables, each of them storable in 2 bytes
601
char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
602
uint32_t lc_time_names_number;
603
uint charset_database_number;
605
bool thread_id_printed;
607
st_print_event_info();
609
~st_print_event_info() {
610
close_cached_file(&head_cache);
611
close_cached_file(&body_cache);
613
bool init_ok() /* tells if construction was successful */
614
{ return my_b_inited(&head_cache) && my_b_inited(&body_cache); }
617
/* Settings on how to print the events */
619
enum_base64_output_mode base64_output_mode;
621
This is set whenever a Format_description_event is printed.
622
Later, when an event is printed in base64, this flag is tested: if
623
no Format_description_event has been seen, it is unsafe to print
624
the base64 event, so an error message is generated.
626
bool printed_fd_event;
627
my_off_t hexdump_from;
628
uint8_t common_header_len;
632
These two caches are used by the row-based replication events to
633
collect the header information and the main body of the events
634
making up a statement.
558
642
the struct aggregates two paramenters that identify an event
559
643
uniquely in scope of communication of a particular master and slave couple.
824
910
virtual void pack_info(Protocol *protocol);
912
#endif /* HAVE_REPLICATION */
826
913
virtual const char* get_db()
828
915
return thd ? thd->db : 0;
918
Log_event() : temp_buf(0) {}
919
/* avoid having to link mysqlbinlog against libpthread */
920
static Log_event* read_log_event(IO_CACHE* file,
921
const Format_description_log_event
923
/* print*() functions are used by mysqlbinlog */
924
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
925
void print_timestamp(IO_CACHE* file, time_t *ts = 0);
926
void print_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
928
void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
831
932
static void *operator new(size_t size)
836
937
static void operator delete(void *ptr,
837
938
size_t size __attribute__((unused)))
839
free((unsigned char*) ptr);
940
my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
842
943
/* Placement version of the above operators */
843
944
static void *operator new(size_t, void* ptr) { return ptr; }
844
945
static void operator delete(void*, void*) { }
947
#ifndef DRIZZLE_CLIENT
846
948
bool write_header(IO_CACHE* file, ulong data_length);
847
949
virtual bool write(IO_CACHE* file)
886
989
is calculated during write()
888
991
virtual int get_data_size() { return 0;}
889
static Log_event* read_log_event(const char* buf, uint32_t event_len,
992
static Log_event* read_log_event(const char* buf, uint event_len,
890
993
const char **error,
891
994
const Format_description_log_event
892
995
*description_event);
1448
1553
ulong sql_mode;
1449
1554
ulong auto_increment_increment, auto_increment_offset;
1450
1555
char charset[6];
1451
uint32_t time_zone_len; /* 0 means uninited */
1556
uint time_zone_len; /* 0 means uninited */
1452
1557
const char *time_zone_str;
1453
uint32_t lc_time_names_number; /* 0 means en_US */
1454
uint32_t charset_database_number;
1558
uint lc_time_names_number; /* 0 means en_US */
1559
uint charset_database_number;
1561
#ifndef DRIZZLE_CLIENT
1457
1563
Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
1458
1564
bool using_trans, bool suppress_use,
1459
1565
THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
1460
1566
const char* get_db() { return db; }
1567
#ifdef HAVE_REPLICATION
1461
1568
void pack_info(Protocol* protocol);
1569
#endif /* HAVE_REPLICATION */
1571
void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
1572
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1463
1575
Query_log_event();
1464
Query_log_event(const char* buf, uint32_t event_len,
1576
Query_log_event(const char* buf, uint event_len,
1465
1577
const Format_description_log_event *description_event,
1466
1578
Log_event_type event_type);
1467
1579
~Query_log_event()
1470
free((unsigned char*) data_buf);
1582
my_free((uchar*) data_buf, MYF(0));
1472
1584
Log_event_type get_type_code() { return QUERY_EVENT; }
1585
#ifndef DRIZZLE_CLIENT
1473
1586
bool write(IO_CACHE* file);
1474
1587
virtual bool write_post_header_for_derived(IO_CACHE* file __attribute__((unused)))
1475
1588
{ return false; }
1476
1590
bool is_valid() const { return query != 0; }
1483
1597
/* Writes derived event-specific part of post header. */
1485
1599
public: /* !!! Public in this patch to allow old usage */
1600
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1486
1601
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
1487
1602
virtual int do_apply_event(Relay_log_info const *rli);
1488
1603
virtual int do_update_pos(Relay_log_info *rli);
1554
1672
int master_log_len;
1555
1673
uint16_t master_port;
1675
#ifndef DRIZZLE_CLIENT
1557
1676
Slave_log_event(THD* thd_arg, Relay_log_info* rli);
1558
1677
void pack_info(Protocol* protocol);
1679
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1560
Slave_log_event(const char* buf, uint32_t event_len);
1682
Slave_log_event(const char* buf, uint event_len);
1561
1683
~Slave_log_event();
1562
1684
int get_data_size();
1563
1685
bool is_valid() const { return master_host != 0; }
1564
1686
Log_event_type get_type_code() { return SLAVE_EVENT; }
1687
#ifndef DRIZZLE_CLIENT
1565
1688
bool write(IO_CACHE* file);
1692
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1568
1693
virtual int do_apply_event(Relay_log_info const* rli);
1697
#endif /* HAVE_REPLICATION */
1573
1701
@class Load_log_event
1771
1899
class Load_log_event: public Log_event
1774
uint32_t get_query_buffer_length();
1902
uint get_query_buffer_length();
1775
1903
void print_query(bool need_db, char *buf, char **end,
1776
1904
char **fn_start, char **fn_end);
1825
1954
void set_fields(const char* db, List<Item> &fields_arg,
1826
1955
Name_resolution_context *context);
1827
1956
const char* get_db() { return db; }
1957
#ifdef HAVE_REPLICATION
1828
1958
void pack_info(Protocol* protocol);
1959
#endif /* HAVE_REPLICATION */
1961
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1962
void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool commented);
1831
1966
Note that for all the events related to LOAD DATA (Load_log_event,
1833
1968
logging of LOAD DATA is going to be changed in 4.1 or 5.0, this is only used
1834
1969
for the common_header_len (post_header_len will not be changed).
1836
Load_log_event(const char* buf, uint32_t event_len,
1971
Load_log_event(const char* buf, uint event_len,
1837
1972
const Format_description_log_event* description_event);
1838
1973
~Load_log_event()
1919
2058
bool dont_set_created;
2060
#ifndef DRIZZLE_CLIENT
1921
2061
Start_log_event_v3();
2062
#ifdef HAVE_REPLICATION
1922
2063
void pack_info(Protocol* protocol);
2064
#endif /* HAVE_REPLICATION */
2066
Start_log_event_v3() {}
2067
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
1924
2070
Start_log_event_v3(const char* buf,
1925
2071
const Format_description_log_event* description_event);
1926
2072
~Start_log_event_v3() {}
1927
2073
Log_event_type get_type_code() { return START_EVENT_V3;}
2074
#ifndef DRIZZLE_CLIENT
1928
2075
bool write(IO_CACHE* file);
1929
2077
bool is_valid() const { return 1; }
1930
2078
int get_data_size()
1972
2122
uint8_t number_of_event_types;
1973
2123
/* The list of post-headers' lengthes */
1974
2124
uint8_t *post_header_len;
1975
unsigned char server_version_split[3];
2125
uchar server_version_split[3];
1976
2126
const uint8_t *event_type_permutation;
1978
2128
Format_description_log_event(uint8_t binlog_ver, const char* server_ver=0);
1979
Format_description_log_event(const char* buf, uint32_t event_len,
2129
Format_description_log_event(const char* buf, uint event_len,
1980
2130
const Format_description_log_event
1981
2131
*description_event);
1982
2132
~Format_description_log_event()
1984
free((unsigned char*)post_header_len);
2134
my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
1986
2136
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
2137
#ifndef DRIZZLE_CLIENT
1987
2138
bool write(IO_CACHE* file);
1988
2140
bool is_valid() const
1990
2142
return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
2056
Intvar_log_event(THD* thd_arg,unsigned char type_arg, uint64_t val_arg)
2210
#ifndef DRIZZLE_CLIENT
2211
Intvar_log_event(THD* thd_arg,uchar type_arg, uint64_t val_arg)
2057
2212
:Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
2214
#ifdef HAVE_REPLICATION
2059
2215
void pack_info(Protocol* protocol);
2216
#endif /* HAVE_REPLICATION */
2218
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2061
2221
Intvar_log_event(const char* buf,
2062
2222
const Format_description_log_event *description_event);
2064
2224
Log_event_type get_type_code() { return INTVAR_EVENT;}
2065
2225
const char* get_var_type_name();
2066
2226
int get_data_size() { return 9; /* sizeof(type) + sizeof(val) */;}
2227
#ifndef DRIZZLE_CLIENT
2067
2228
bool write(IO_CACHE* file);
2068
2230
bool is_valid() const { return 1; }
2233
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2071
2234
virtual int do_apply_event(Relay_log_info const *rli);
2072
2235
virtual int do_update_pos(Relay_log_info *rli);
2073
2236
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2118
2282
uint64_t seed1;
2119
2283
uint64_t seed2;
2285
#ifndef DRIZZLE_CLIENT
2121
2286
Rand_log_event(THD* thd_arg, uint64_t seed1_arg, uint64_t seed2_arg)
2122
2287
:Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
2289
#ifdef HAVE_REPLICATION
2124
2290
void pack_info(Protocol* protocol);
2291
#endif /* HAVE_REPLICATION */
2293
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2126
2296
Rand_log_event(const char* buf,
2127
2297
const Format_description_log_event *description_event);
2128
2298
~Rand_log_event() {}
2129
2299
Log_event_type get_type_code() { return RAND_EVENT;}
2130
2300
int get_data_size() { return 16; /* sizeof(uint64_t) * 2*/ }
2301
#ifndef DRIZZLE_CLIENT
2131
2302
bool write(IO_CACHE* file);
2132
2304
bool is_valid() const { return 1; }
2307
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2135
2308
virtual int do_apply_event(Relay_log_info const *rli);
2136
2309
virtual int do_update_pos(Relay_log_info *rli);
2137
2310
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2146
2320
@section Xid_log_event_binary_format Binary Format
2322
#ifdef DRIZZLE_CLIENT
2323
typedef uint64_t my_xid; // this line is the same as in handler.h
2148
2326
class Xid_log_event: public Log_event
2331
#ifndef DRIZZLE_CLIENT
2153
2332
Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
2333
#ifdef HAVE_REPLICATION
2154
2334
void pack_info(Protocol* protocol);
2335
#endif /* HAVE_REPLICATION */
2337
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2156
2340
Xid_log_event(const char* buf,
2157
2341
const Format_description_log_event *description_event);
2158
2342
~Xid_log_event() {}
2159
2343
Log_event_type get_type_code() { return XID_EVENT;}
2160
2344
int get_data_size() { return sizeof(xid); }
2345
#ifndef DRIZZLE_CLIENT
2161
2346
bool write(IO_CACHE* file);
2162
2348
bool is_valid() const { return 1; }
2351
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2165
2352
virtual int do_apply_event(Relay_log_info const *rli);
2166
2353
enum_skip_reason do_shall_skip(Relay_log_info *rli);
2185
2373
Item_result type;
2186
uint32_t charset_number;
2374
uint charset_number;
2376
#ifndef DRIZZLE_CLIENT
2188
2377
User_var_log_event(THD* thd_arg __attribute__((unused)),
2189
char *name_arg, uint32_t name_len_arg,
2378
char *name_arg, uint name_len_arg,
2190
2379
char *val_arg, ulong val_len_arg, Item_result type_arg,
2191
uint32_t charset_number_arg)
2380
uint charset_number_arg)
2192
2381
:Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
2193
2382
val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
2194
2383
{ is_null= !val; }
2195
2384
void pack_info(Protocol* protocol);
2386
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2197
2389
User_var_log_event(const char* buf,
2198
2390
const Format_description_log_event *description_event);
2199
2391
~User_var_log_event() {}
2200
2392
Log_event_type get_type_code() { return USER_VAR_EVENT;}
2393
#ifndef DRIZZLE_CLIENT
2201
2394
bool write(IO_CACHE* file);
2202
2396
bool is_valid() const { return 1; }
2399
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2205
2400
virtual int do_apply_event(Relay_log_info const *rli);
2206
2401
virtual int do_update_pos(Relay_log_info *rli);
2207
2402
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2219
2415
class Stop_log_event: public Log_event
2418
#ifndef DRIZZLE_CLIENT
2222
2419
Stop_log_event() :Log_event()
2422
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2225
2425
Stop_log_event(const char* buf,
2226
2426
const Format_description_log_event *description_event):
2303
2505
const char* new_log_ident;
2509
#ifndef DRIZZLE_CLIENT
2307
2510
Rotate_log_event(const char* new_log_ident_arg,
2308
uint32_t ident_len_arg,
2309
uint64_t pos_arg, uint32_t flags);
2512
uint64_t pos_arg, uint flags);
2513
#ifdef HAVE_REPLICATION
2310
2514
void pack_info(Protocol* protocol);
2515
#endif /* HAVE_REPLICATION */
2517
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2312
Rotate_log_event(const char* buf, uint32_t event_len,
2520
Rotate_log_event(const char* buf, uint event_len,
2313
2521
const Format_description_log_event* description_event);
2314
2522
~Rotate_log_event()
2316
2524
if (flags & DUP_NAME)
2317
free((unsigned char*) new_log_ident);
2525
my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR));
2319
2527
Log_event_type get_type_code() { return ROTATE_EVENT;}
2320
2528
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
2321
2529
bool is_valid() const { return new_log_ident != 0; }
2530
#ifndef DRIZZLE_CLIENT
2322
2531
bool write(IO_CACHE* file);
2535
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2325
2536
virtual int do_update_pos(Relay_log_info *rli);
2326
2537
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2346
2558
bool fake_base;
2348
unsigned char* block;
2349
2561
const char *event_buf;
2352
2564
bool inited_from_old;
2566
#ifndef DRIZZLE_CLIENT
2354
2567
Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
2355
2568
const char* table_name_arg,
2356
2569
List<Item>& fields_arg,
2357
2570
enum enum_duplicates handle_dup, bool ignore,
2358
unsigned char* block_arg, uint32_t block_len_arg,
2571
uchar* block_arg, uint block_len_arg,
2359
2572
bool using_trans);
2573
#ifdef HAVE_REPLICATION
2360
2574
void pack_info(Protocol* protocol);
2575
#endif /* HAVE_REPLICATION */
2577
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2578
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
2362
Create_file_log_event(const char* buf, uint32_t event_len,
2582
Create_file_log_event(const char* buf, uint event_len,
2363
2583
const Format_description_log_event* description_event);
2364
2584
~Create_file_log_event()
2366
free((char*) event_buf);
2586
my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
2369
2589
Log_event_type get_type_code()
2416
2640
const char* db;
2418
Append_block_log_event(THD* thd, const char* db_arg, unsigned char* block_arg,
2419
uint32_t block_len_arg, bool using_trans);
2642
#ifndef DRIZZLE_CLIENT
2643
Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
2644
uint block_len_arg, bool using_trans);
2645
#ifdef HAVE_REPLICATION
2420
2646
void pack_info(Protocol* protocol);
2421
2647
virtual int get_create_or_append() const;
2648
#endif /* HAVE_REPLICATION */
2650
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2423
Append_block_log_event(const char* buf, uint32_t event_len,
2653
Append_block_log_event(const char* buf, uint event_len,
2424
2654
const Format_description_log_event
2425
2655
*description_event);
2426
2656
~Append_block_log_event() {}
2427
2657
Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
2428
2658
int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;}
2429
2659
bool is_valid() const { return block != 0; }
2660
#ifndef DRIZZLE_CLIENT
2430
2661
bool write(IO_CACHE* file);
2431
2662
const char* get_db() { return db; }
2666
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2434
2667
virtual int do_apply_event(Relay_log_info const *rli);
2444
2678
class Delete_file_log_event: public Log_event
2448
2682
const char* db; /* see comment in Append_block_log_event */
2684
#ifndef DRIZZLE_CLIENT
2450
2685
Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
2686
#ifdef HAVE_REPLICATION
2451
2687
void pack_info(Protocol* protocol);
2688
#endif /* HAVE_REPLICATION */
2690
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2691
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
2453
Delete_file_log_event(const char* buf, uint32_t event_len,
2695
Delete_file_log_event(const char* buf, uint event_len,
2454
2696
const Format_description_log_event* description_event);
2455
2697
~Delete_file_log_event() {}
2456
2698
Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
2457
2699
int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
2458
2700
bool is_valid() const { return file_id != 0; }
2701
#ifndef DRIZZLE_CLIENT
2459
2702
bool write(IO_CACHE* file);
2460
2703
const char* get_db() { return db; }
2707
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2463
2708
virtual int do_apply_event(Relay_log_info const *rli);
2473
2719
class Execute_load_log_event: public Log_event
2477
2723
const char* db; /* see comment in Append_block_log_event */
2725
#ifndef DRIZZLE_CLIENT
2479
2726
Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
2727
#ifdef HAVE_REPLICATION
2480
2728
void pack_info(Protocol* protocol);
2729
#endif /* HAVE_REPLICATION */
2731
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2482
Execute_load_log_event(const char* buf, uint32_t event_len,
2734
Execute_load_log_event(const char* buf, uint event_len,
2483
2735
const Format_description_log_event
2484
2736
*description_event);
2485
2737
~Execute_load_log_event() {}
2486
2738
Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
2487
2739
int get_data_size() { return EXEC_LOAD_HEADER_LEN ;}
2488
2740
bool is_valid() const { return file_id != 0; }
2741
#ifndef DRIZZLE_CLIENT
2489
2742
bool write(IO_CACHE* file);
2490
2743
const char* get_db() { return db; }
2747
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2493
2748
virtual int do_apply_event(Relay_log_info const *rli);
2506
2762
class Begin_load_query_log_event: public Append_block_log_event
2765
#ifndef DRIZZLE_CLIENT
2509
2766
Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
2510
unsigned char* block_arg, uint32_t block_len_arg,
2767
uchar* block_arg, uint block_len_arg,
2511
2768
bool using_trans);
2769
#ifdef HAVE_REPLICATION
2512
2770
Begin_load_query_log_event(THD* thd);
2513
2771
int get_create_or_append() const;
2514
Begin_load_query_log_event(const char* buf, uint32_t event_len,
2772
#endif /* HAVE_REPLICATION */
2774
Begin_load_query_log_event(const char* buf, uint event_len,
2515
2775
const Format_description_log_event
2516
2776
*description_event);
2517
2777
~Begin_load_query_log_event() {}
2518
2778
Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
2780
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2520
2781
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
2539
2801
class Execute_load_query_log_event: public Query_log_event
2542
uint32_t file_id; // file_id of temporary file
2543
uint32_t fn_pos_start; // pointer to the part of the query that should
2804
uint file_id; // file_id of temporary file
2805
uint fn_pos_start; // pointer to the part of the query that should
2544
2806
// be substituted
2545
uint32_t fn_pos_end; // pointer to the end of this part of query
2807
uint fn_pos_end; // pointer to the end of this part of query
2547
2809
We have to store type of duplicate handling explicitly, because
2548
2810
for LOAD DATA it also depends on LOCAL option. And this part
2552
2814
enum_load_dup_handling dup_handling;
2816
#ifndef DRIZZLE_CLIENT
2554
2817
Execute_load_query_log_event(THD* thd, const char* query_arg,
2555
ulong query_length, uint32_t fn_pos_start_arg,
2556
uint32_t fn_pos_end_arg,
2818
ulong query_length, uint fn_pos_start_arg,
2819
uint fn_pos_end_arg,
2557
2820
enum_load_dup_handling dup_handling_arg,
2558
2821
bool using_trans, bool suppress_use,
2559
2822
THD::killed_state
2560
2823
killed_err_arg= THD::KILLED_NO_VALUE);
2824
#ifdef HAVE_REPLICATION
2561
2825
void pack_info(Protocol* protocol);
2562
Execute_load_query_log_event(const char* buf, uint32_t event_len,
2826
#endif /* HAVE_REPLICATION */
2828
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2829
/* Prints the query as LOAD DATA LOCAL and with rewritten filename */
2830
void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
2831
const char *local_fname);
2833
Execute_load_query_log_event(const char* buf, uint event_len,
2563
2834
const Format_description_log_event
2564
2835
*description_event);
2565
2836
~Execute_load_query_log_event() {}
2568
2839
bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
2570
2841
ulong get_post_header_size_for_derived();
2842
#ifndef DRIZZLE_CLIENT
2571
2843
bool write_post_header_for_derived(IO_CACHE* file);
2847
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2574
2848
virtual int do_apply_event(Relay_log_info const *rli);
2578
char *str_to_hex(char *to, const char *from, uint32_t len);
2853
#ifdef DRIZZLE_CLIENT
2855
@class Unknown_log_event
2857
@section Unknown_log_event_binary_format Binary Format
2859
class Unknown_log_event: public Log_event
2863
Even if this is an unknown event, we still pass description_event to
2864
Log_event's ctor, this way we can extract maximum information from the
2865
event's header (the unique ID for example).
2867
Unknown_log_event(const char* buf,
2868
const Format_description_log_event *description_event):
2869
Log_event(buf, description_event)
2871
~Unknown_log_event() {}
2872
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
2873
Log_event_type get_type_code() { return UNKNOWN_EVENT;}
2874
bool is_valid() const { return 1; }
2877
char *str_to_hex(char *to, const char *from, uint len);
2581
2880
@class Table_map_log_event
2868
3167
void clear_flags(flag_set flag) { m_flags &= ~flag; }
2869
3168
flag_set get_flags(flag_set flag) const { return m_flags & flag; }
3170
#ifndef DRIZZLE_CLIENT
2871
3171
Table_map_log_event(THD *thd, Table *tbl, ulong tid,
2872
3172
bool is_transactional, uint16_t flags);
2873
Table_map_log_event(const char *buf, uint32_t event_len,
3174
#ifdef HAVE_REPLICATION
3175
Table_map_log_event(const char *buf, uint event_len,
2874
3176
const Format_description_log_event *description_event);
2876
3179
~Table_map_log_event();
2879
3182
virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
2881
3184
virtual int get_data_size() { return m_data_size; }
3185
#ifndef DRIZZLE_CLIENT
2882
3186
virtual int save_field_metadata();
2883
3187
virtual bool write_data_header(IO_CACHE *file);
2884
3188
virtual bool write_data_body(IO_CACHE *file);
2885
3189
virtual const char *get_db() { return m_dbnam; }
3192
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2886
3193
virtual void pack_info(Protocol *protocol);
3196
#ifdef DRIZZLE_CLIENT
3197
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3202
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2889
3203
virtual int do_apply_event(Relay_log_info const *rli);
2890
3204
virtual int do_update_pos(Relay_log_info *rli);
2891
3205
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3208
#ifndef DRIZZLE_CLIENT
2893
3209
Table *m_table;
2894
3211
char const *m_dbnam;
2895
3212
size_t m_dblen;
2896
3213
char const *m_tblnam;
2897
3214
size_t m_tbllen;
2898
3215
ulong m_colcnt;
2899
unsigned char *m_coltype;
2901
unsigned char *m_memory;
2902
3219
ulong m_table_id;
2903
3220
flag_set m_flags;
2905
3222
size_t m_data_size;
2907
unsigned char *m_field_metadata; // buffer for field metadata
3224
uchar *m_field_metadata; // buffer for field metadata
2909
3226
The size of field metadata buffer set by calling save_field_metadata()
2911
3228
ulong m_field_metadata_size;
2912
unsigned char *m_null_bits;
2913
unsigned char *m_meta_memory;
3230
uchar *m_meta_memory;
2984
3301
void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2985
3302
flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
3304
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2987
3305
virtual void pack_info(Protocol *protocol);
2989
int add_row_data(unsigned char *data, size_t length)
3308
#ifdef DRIZZLE_CLIENT
3309
/* not for direct call, each derived has its own ::print() */
3310
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info)= 0;
3313
#ifndef DRIZZLE_CLIENT
3314
int add_row_data(uchar *data, size_t length)
2991
3316
return do_add_row_data(data,length);
2994
3320
/* Member functions to implement superclass interface */
2995
3321
virtual int get_data_size();
2998
3324
size_t get_width() const { return m_width; }
2999
3325
ulong get_table_id() const { return m_table_id; }
3327
#ifndef DRIZZLE_CLIENT
3001
3328
virtual bool write_data_header(IO_CACHE *file);
3002
3329
virtual bool write_data_body(IO_CACHE *file);
3003
3330
virtual const char *get_db() { return m_table->s->db.str; }
3005
3333
Check that malloc() succeeded in allocating memory for the rows
3006
3334
buffer and the COLS vector. Checking that an Update_rows_log_event
3012
3340
return m_rows_buf && m_cols.bitmap;
3015
uint32_t m_row_count; /* The number of rows added to the event */
3343
uint m_row_count; /* The number of rows added to the event */
3019
3347
The constructors are protected since you're supposed to inherit
3020
3348
this class, not create instances of this class.
3350
#ifndef DRIZZLE_CLIENT
3022
3351
Rows_log_event(THD*, Table*, ulong table_id,
3023
3352
MY_BITMAP const *cols, bool is_transactional);
3024
Rows_log_event(const char *row_data, uint32_t event_len,
3354
Rows_log_event(const char *row_data, uint event_len,
3025
3355
Log_event_type event_type,
3026
3356
const Format_description_log_event *description_event);
3028
virtual int do_add_row_data(unsigned char *data, size_t length);
3358
#ifdef DRIZZLE_CLIENT
3359
void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
3362
#ifndef DRIZZLE_CLIENT
3363
virtual int do_add_row_data(uchar *data, size_t length);
3366
#ifndef DRIZZLE_CLIENT
3030
3367
Table *m_table; /* The table the rows belong to */
3031
3369
ulong m_table_id; /* Table ID */
3032
3370
MY_BITMAP m_cols; /* Bitmap denoting columns available */
3033
3371
ulong m_width; /* The width of the columns bitmap */
3046
3384
uint32_t m_bitbuf[128/(sizeof(uint32_t)*8)];
3047
3385
uint32_t m_bitbuf_ai[128/(sizeof(uint32_t)*8)];
3049
unsigned char *m_rows_buf; /* The rows in packed format */
3050
unsigned char *m_rows_cur; /* One-after the end of the data */
3051
unsigned char *m_rows_end; /* One-after the end of the allocated space */
3387
uchar *m_rows_buf; /* The rows in packed format */
3388
uchar *m_rows_cur; /* One-after the end of the data */
3389
uchar *m_rows_end; /* One-after the end of the allocated space */
3053
3391
flag_set m_flags; /* Flags for row-level events */
3055
3393
/* helper functions */
3057
const unsigned char *m_curr_row; /* Start of the row being processed */
3058
const unsigned char *m_curr_row_end; /* One-after the end of the current row */
3059
unsigned char *m_key; /* Buffer to keep key value during searches */
3395
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3396
const uchar *m_curr_row; /* Start of the row being processed */
3397
const uchar *m_curr_row_end; /* One-after the end of the current row */
3398
uchar *m_key; /* Buffer to keep key value during searches */
3061
3400
int find_row(const Relay_log_info *const);
3062
3401
int write_row(const Relay_log_info *const, const bool);
3074
3413
ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
3420
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3080
3421
virtual int do_apply_event(Relay_log_info const *rli);
3081
3422
virtual int do_update_pos(Relay_log_info *rli);
3082
3423
virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3153
3495
TYPE_CODE = WRITE_ROWS_EVENT
3498
#if !defined(DRIZZLE_CLIENT)
3156
3499
Write_rows_log_event(THD*, Table*, ulong table_id,
3157
3500
bool is_transactional);
3158
Write_rows_log_event(const char *buf, uint32_t event_len,
3502
#ifdef HAVE_REPLICATION
3503
Write_rows_log_event(const char *buf, uint event_len,
3159
3504
const Format_description_log_event *description_event);
3506
#if !defined(DRIZZLE_CLIENT)
3160
3507
static bool binlog_row_logging_function(THD *thd, Table *table,
3161
3508
bool is_transactional,
3162
const unsigned char *before_record
3509
const uchar *before_record
3163
3510
__attribute__((unused)),
3164
const unsigned char *after_record)
3511
const uchar *after_record)
3166
3513
return thd->binlog_write_row(table, is_transactional, after_record);
3170
3518
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3520
#ifdef DRIZZLE_CLIENT
3521
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3524
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3172
3525
virtual int do_before_row_operations(const Slave_reporting_capability *const);
3173
3526
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3174
3527
virtual int do_exec_row(const Relay_log_info *const);
3196
3550
TYPE_CODE = UPDATE_ROWS_EVENT
3553
#ifndef DRIZZLE_CLIENT
3199
3554
Update_rows_log_event(THD*, Table*, ulong table_id,
3200
3555
bool is_transactional);
3202
3557
void init(MY_BITMAP const *cols);
3204
3560
virtual ~Update_rows_log_event();
3206
Update_rows_log_event(const char *buf, uint32_t event_len,
3562
#ifdef HAVE_REPLICATION
3563
Update_rows_log_event(const char *buf, uint event_len,
3207
3564
const Format_description_log_event *description_event);
3567
#if !defined(DRIZZLE_CLIENT)
3209
3568
static bool binlog_row_logging_function(THD *thd, Table *table,
3210
3569
bool is_transactional,
3211
const unsigned char *before_record,
3212
const unsigned char *after_record)
3570
const uchar *before_record,
3571
const uchar *after_record)
3214
3573
return thd->binlog_update_row(table, is_transactional,
3215
3574
before_record, after_record);
3218
3578
virtual bool is_valid() const
3224
3584
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3586
#ifdef DRIZZLE_CLIENT
3587
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3590
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3226
3591
virtual int do_before_row_operations(const Slave_reporting_capability *const);
3227
3592
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3228
3593
virtual int do_exec_row(const Relay_log_info *const);
3594
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
3257
3623
TYPE_CODE = DELETE_ROWS_EVENT
3626
#ifndef DRIZZLE_CLIENT
3260
3627
Delete_rows_log_event(THD*, Table*, ulong,
3261
3628
bool is_transactional);
3262
Delete_rows_log_event(const char *buf, uint32_t event_len,
3630
#ifdef HAVE_REPLICATION
3631
Delete_rows_log_event(const char *buf, uint event_len,
3263
3632
const Format_description_log_event *description_event);
3634
#if !defined(DRIZZLE_CLIENT)
3264
3635
static bool binlog_row_logging_function(THD *thd, Table *table,
3265
3636
bool is_transactional,
3266
const unsigned char *before_record,
3267
const unsigned char *after_record
3637
const uchar *before_record,
3638
const uchar *after_record
3268
3639
__attribute__((unused)))
3270
3641
return thd->binlog_delete_row(table, is_transactional, before_record);
3274
3646
virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3648
#ifdef DRIZZLE_CLIENT
3649
void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3652
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3276
3653
virtual int do_before_row_operations(const Slave_reporting_capability *const);
3277
3654
virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3278
3655
virtual int do_exec_row(const Relay_log_info *const);
3331
3710
m_message= msg;
3715
#ifndef DRIZZLE_CLIENT
3335
3716
void pack_info(Protocol*);
3337
Incident_log_event(const char *buf, uint32_t event_len,
3719
Incident_log_event(const char *buf, uint event_len,
3338
3720
const Format_description_log_event *descr_event);
3340
3722
virtual ~Incident_log_event();
3724
#ifdef DRIZZLE_CLIENT
3725
virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
3728
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3342
3729
virtual int do_apply_event(Relay_log_info const *rli);
3344
3732
virtual bool write_data_header(IO_CACHE *file);
3345
3733
virtual bool write_data_body(IO_CACHE *file);
3387
3776
class Heartbeat_log_event: public Log_event
3390
Heartbeat_log_event(const char* buf, uint32_t event_len,
3779
Heartbeat_log_event(const char* buf, uint event_len,
3391
3780
const Format_description_log_event* description_event);
3392
3781
Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; }
3393
3782
bool is_valid() const