~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log_event.h

  • Committer: Stewart Smith
  • Date: 2008-09-25 10:04:06 UTC
  • mto: This revision was merged to the branch mainline in revision 408.
  • Revision ID: stewart@flamingspork.com-20080925100406-hld92f4dr4nuar3a
Move compression functions (compress, uncompress and compressed_length) out into modules and fix test

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#ifndef _log_event_h
33
33
#define _log_event_h
34
34
 
35
 
#if defined(USE_PRAGMA_INTERFACE)
 
35
#if defined(USE_PRAGMA_INTERFACE) && !defined(DRIZZLE_CLIENT)
36
36
#pragma interface                       /* gcc class implementation */
37
37
#endif
38
38
 
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"
 
44
#else
 
45
#include "my_decimal.h"
 
46
#endif
43
47
 
44
48
#include <drizzled/sql_string.h>       /* append_query_string() needs String declaration */
45
49
 
455
459
 
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))
459
463
 
460
464
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
461
465
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
547
551
};
548
552
 
549
553
 
 
554
#ifndef DRIZZLE_CLIENT
550
555
class String;
551
556
class DRIZZLE_BIN_LOG;
552
557
class THD;
 
558
#endif
553
559
 
554
560
class Format_description_log_event;
555
561
class Relay_log_info;
556
562
 
 
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
 
571
};
 
572
 
 
573
/*
 
574
  A structure for mysqlbinlog to know how to print events
 
575
 
 
576
  This structure is passed to the event's print() methods,
 
577
 
 
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
 
581
     are printed.
 
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.
 
584
*/
 
585
typedef struct st_print_event_info
 
586
{
 
587
  /*
 
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.
 
591
  */
 
592
  // TODO: have the last catalog here ??
 
593
  char db[FN_REFLEN+1]; // TODO: make this a LEX_STRING when thd->db is
 
594
  bool flags2_inited;
 
595
  uint32_t flags2;
 
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;
 
599
  bool charset_inited;
 
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;
 
604
  uint thread_id;
 
605
  bool thread_id_printed;
 
606
 
 
607
  st_print_event_info();
 
608
 
 
609
  ~st_print_event_info() {
 
610
    close_cached_file(&head_cache);
 
611
    close_cached_file(&body_cache);
 
612
  }
 
613
  bool init_ok() /* tells if construction was successful */
 
614
    { return my_b_inited(&head_cache) && my_b_inited(&body_cache); }
 
615
 
 
616
 
 
617
  /* Settings on how to print the events */
 
618
  bool short_form;
 
619
  enum_base64_output_mode base64_output_mode;
 
620
  /*
 
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.
 
625
  */
 
626
  bool printed_fd_event;
 
627
  my_off_t hexdump_from;
 
628
  uint8_t common_header_len;
 
629
  char delimiter[16];
 
630
 
 
631
  /*
 
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.
 
635
   */
 
636
  IO_CACHE head_cache;
 
637
  IO_CACHE body_cache;
 
638
} PRINT_EVENT_INFO;
 
639
#endif
 
640
 
557
641
/**
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.
787
871
  */
788
872
  ulong slave_exec_mode;
789
873
 
 
874
#ifndef DRIZZLE_CLIENT
790
875
  THD* thd;
791
876
 
792
877
  Log_event();
814
899
    EVENTS.
815
900
  */
816
901
  static void init_show_field_list(List<Item>* field_list);
 
902
#ifdef HAVE_REPLICATION
817
903
  int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
818
904
 
819
905
  /*
823
909
 
824
910
  virtual void pack_info(Protocol *protocol);
825
911
 
 
912
#endif /* HAVE_REPLICATION */
826
913
  virtual const char* get_db()
827
914
  {
828
915
    return thd ? thd->db : 0;
829
916
  }
 
917
#else
 
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
 
922
                                   *description_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,
 
927
                    bool is_more);
 
928
  void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
 
929
                    bool is_more);
 
930
#endif
830
931
 
831
932
  static void *operator new(size_t size)
832
933
  {
836
937
  static void operator delete(void *ptr,
837
938
                              size_t size __attribute__((unused)))
838
939
  {
839
 
    free((unsigned char*) ptr);
 
940
    my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
840
941
  }
841
942
 
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*) { }
845
946
 
 
947
#ifndef DRIZZLE_CLIENT
846
948
  bool write_header(IO_CACHE* file, ulong data_length);
847
949
  virtual bool write(IO_CACHE* file)
848
950
  {
865
967
      return tmp_thd->start_time;
866
968
    return my_time(0);
867
969
  }
 
970
#endif
868
971
  virtual Log_event_type get_type_code() = 0;
869
972
  virtual bool is_valid() const = 0;
870
973
  virtual bool is_artificial_event() { return 0; }
877
980
  {
878
981
    if (temp_buf)
879
982
    {
880
 
      free(temp_buf);
 
983
      my_free(temp_buf, MYF(0));
881
984
      temp_buf = 0;
882
985
    }
883
986
  }
886
989
    is calculated during write()
887
990
  */
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);
901
1004
 
902
1005
  /* Return start of query time or current time */
903
1006
 
 
1007
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
904
1008
public:
905
1009
 
906
1010
  /**
1039
1143
     non-zero. The caller shall decrease the counter by one.
1040
1144
   */
1041
1145
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
1146
#endif
1042
1147
};
1043
1148
 
1044
1149
 
1406
1511
    concerned) from here.
1407
1512
  */
1408
1513
 
1409
 
  uint32_t catalog_len;                 // <= 255 char; 0 means uninited
 
1514
  uint catalog_len;                     // <= 255 char; 0 means uninited
1410
1515
 
1411
1516
  /*
1412
1517
    We want to be able to store a variable number of N-bit status vars:
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;
1455
1560
 
 
1561
#ifndef DRIZZLE_CLIENT
1456
1562
 
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 */
 
1570
#else
 
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);
 
1573
#endif
1462
1574
 
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()
1468
1580
  {
1469
1581
    if (data_buf)
1470
 
      free((unsigned char*) data_buf);
 
1582
      my_free((uchar*) data_buf, MYF(0));
1471
1583
  }
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; }
 
1589
#endif
1476
1590
  bool is_valid() const { return query != 0; }
1477
1591
 
1478
1592
  /*
1483
1597
  /* Writes derived event-specific part of post header. */
1484
1598
 
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);
1490
1605
  int do_apply_event(Relay_log_info const *rli,
1491
1606
                       const char *query_arg,
1492
1607
                       uint32_t q_len_arg);
 
1608
#endif /* HAVE_REPLICATION */
1493
1609
};
1494
1610
 
1495
1611
 
 
1612
#ifdef HAVE_REPLICATION
 
1613
 
1496
1614
/**
1497
1615
  @class Slave_log_event
1498
1616
 
1554
1672
  int master_log_len;
1555
1673
  uint16_t master_port;
1556
1674
 
 
1675
#ifndef DRIZZLE_CLIENT
1557
1676
  Slave_log_event(THD* thd_arg, Relay_log_info* rli);
1558
1677
  void pack_info(Protocol* protocol);
 
1678
#else
 
1679
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1680
#endif
1559
1681
 
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);
 
1689
#endif
1566
1690
 
1567
1691
private:
 
1692
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1568
1693
  virtual int do_apply_event(Relay_log_info const* rli);
 
1694
#endif
1569
1695
};
1570
1696
 
 
1697
#endif /* HAVE_REPLICATION */
 
1698
 
1571
1699
 
1572
1700
/**
1573
1701
  @class Load_log_event
1771
1899
class Load_log_event: public Log_event
1772
1900
{
1773
1901
private:
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);
1777
1905
protected:
1792
1920
  uint32_t fname_len;
1793
1921
  uint32_t num_fields;
1794
1922
  const char* fields;
1795
 
  const unsigned char* field_lens;
 
1923
  const uchar* field_lens;
1796
1924
  uint32_t field_block_len;
1797
1925
 
1798
1926
  const char* table_name;
1803
1931
  bool local_fname;
1804
1932
 
1805
1933
  /* fname doesn't point to memory inside Log_event::temp_buf  */
1806
 
  void set_fname_outside_temp_buf(const char *afname, uint32_t alen)
 
1934
  void set_fname_outside_temp_buf(const char *afname, uint alen)
1807
1935
  {
1808
1936
    fname= afname;
1809
1937
    fname_len= alen;
1815
1943
    return local_fname;
1816
1944
  }
1817
1945
 
 
1946
#ifndef DRIZZLE_CLIENT
1818
1947
  String field_lens_buf;
1819
1948
  String fields_buf;
1820
1949
 
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 */
 
1960
#else
 
1961
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1962
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool commented);
 
1963
#endif
1829
1964
 
1830
1965
  /*
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).
1835
1970
  */
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()
1839
1974
  {}
1841
1976
  {
1842
1977
    return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
1843
1978
  }
 
1979
#ifndef DRIZZLE_CLIENT
1844
1980
  bool write_data_header(IO_CACHE* file);
1845
1981
  bool write_data_body(IO_CACHE* file);
 
1982
#endif
1846
1983
  bool is_valid() const { return table_name != 0; }
1847
1984
  int get_data_size()
1848
1985
  {
1852
1989
  }
1853
1990
 
1854
1991
public:        /* !!! Public in this patch to allow old usage */
 
1992
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1855
1993
  virtual int do_apply_event(Relay_log_info const* rli)
1856
1994
  {
1857
1995
    return do_apply_event(thd->slave_net,rli,0);
1859
1997
 
1860
1998
  int do_apply_event(NET *net, Relay_log_info const *rli,
1861
1999
                     bool use_rli_only_for_errors);
 
2000
#endif
1862
2001
};
1863
2002
 
1864
2003
extern char server_version[SERVER_VERSION_LENGTH];
1918
2057
  */
1919
2058
  bool dont_set_created;
1920
2059
 
 
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 */
 
2065
#else
 
2066
  Start_log_event_v3() {}
 
2067
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2068
#endif
1923
2069
 
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);
 
2076
#endif
1929
2077
  bool is_valid() const { return 1; }
1930
2078
  int get_data_size()
1931
2079
  {
1934
2082
  virtual bool is_artificial_event() { return artificial_event; }
1935
2083
 
1936
2084
protected:
 
2085
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1937
2086
  virtual int do_apply_event(Relay_log_info const *rli);
1938
2087
  virtual enum_skip_reason do_shall_skip(Relay_log_info*)
1939
2088
  {
1946
2095
    else
1947
2096
      return Log_event::EVENT_SKIP_NOT;
1948
2097
  }
 
2098
#endif
1949
2099
};
1950
2100
 
1951
2101
 
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;
1977
2127
 
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()
1983
2133
  {
1984
 
    free((unsigned char*)post_header_len);
 
2134
    my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
1985
2135
  }
1986
2136
  Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
 
2137
#ifndef DRIZZLE_CLIENT
1987
2138
  bool write(IO_CACHE* file);
 
2139
#endif
1988
2140
  bool is_valid() const
1989
2141
  {
1990
2142
    return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
2004
2156
  void calc_server_version_split();
2005
2157
 
2006
2158
protected:
 
2159
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2007
2160
  virtual int do_apply_event(Relay_log_info const *rli);
2008
2161
  virtual int do_update_pos(Relay_log_info *rli);
2009
2162
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2163
#endif
2010
2164
};
2011
2165
 
2012
2166
 
2051
2205
{
2052
2206
public:
2053
2207
  uint64_t val;
2054
 
  unsigned char type;
 
2208
  uchar type;
2055
2209
 
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)
2058
2213
  {}
 
2214
#ifdef HAVE_REPLICATION
2059
2215
  void pack_info(Protocol* protocol);
 
2216
#endif /* HAVE_REPLICATION */
 
2217
#else
 
2218
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2219
#endif
2060
2220
 
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);
 
2229
#endif
2068
2230
  bool is_valid() const { return 1; }
2069
2231
 
2070
2232
private:
 
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);
 
2237
#endif
2074
2238
};
2075
2239
 
2076
2240
 
2118
2282
  uint64_t seed1;
2119
2283
  uint64_t seed2;
2120
2284
 
 
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)
2123
2288
  {}
 
2289
#ifdef HAVE_REPLICATION
2124
2290
  void pack_info(Protocol* protocol);
 
2291
#endif /* HAVE_REPLICATION */
 
2292
#else
 
2293
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2294
#endif
2125
2295
 
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);
 
2303
#endif
2132
2304
  bool is_valid() const { return 1; }
2133
2305
 
2134
2306
private:
 
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);
 
2311
#endif
2138
2312
};
2139
2313
 
2140
2314
/**
2145
2319
 
2146
2320
  @section Xid_log_event_binary_format Binary Format  
2147
2321
*/
 
2322
#ifdef DRIZZLE_CLIENT
 
2323
typedef uint64_t my_xid; // this line is the same as in handler.h
 
2324
#endif
 
2325
 
2148
2326
class Xid_log_event: public Log_event
2149
2327
{
2150
2328
 public:
2151
2329
   my_xid xid;
2152
2330
 
 
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 */
 
2336
#else
 
2337
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2338
#endif
2155
2339
 
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);
 
2347
#endif
2162
2348
  bool is_valid() const { return 1; }
2163
2349
 
2164
2350
private:
 
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);
 
2354
#endif
2167
2355
};
2168
2356
 
2169
2357
/**
2179
2367
{
2180
2368
public:
2181
2369
  char *name;
2182
 
  uint32_t name_len;
 
2370
  uint name_len;
2183
2371
  char *val;
2184
2372
  ulong val_len;
2185
2373
  Item_result type;
2186
 
  uint32_t charset_number;
 
2374
  uint charset_number;
2187
2375
  bool is_null;
 
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);
 
2385
#else
 
2386
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2387
#endif
2196
2388
 
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);
 
2395
#endif
2202
2396
  bool is_valid() const { return 1; }
2203
2397
 
2204
2398
private:
 
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);
 
2403
#endif
2208
2404
};
2209
2405
 
2210
2406
 
2219
2415
class Stop_log_event: public Log_event
2220
2416
{
2221
2417
public:
 
2418
#ifndef DRIZZLE_CLIENT
2222
2419
  Stop_log_event() :Log_event()
2223
2420
  {}
 
2421
#else
 
2422
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2423
#endif
2224
2424
 
2225
2425
  Stop_log_event(const char* buf,
2226
2426
                 const Format_description_log_event *description_event):
2231
2431
  bool is_valid() const { return 1; }
2232
2432
 
2233
2433
private:
 
2434
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2234
2435
  virtual int do_update_pos(Relay_log_info *rli);
2235
2436
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli __attribute__((unused)))
2236
2437
  {
2243
2444
    else
2244
2445
      return Log_event::EVENT_SKIP_NOT;
2245
2446
  }
 
2447
#endif
2246
2448
};
2247
2449
 
2248
2450
/**
2302
2504
  };
2303
2505
  const char* new_log_ident;
2304
2506
  uint64_t pos;
2305
 
  uint32_t ident_len;
2306
 
  uint32_t flags;
 
2507
  uint ident_len;
 
2508
  uint flags;
 
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);
 
2511
                   uint ident_len_arg,
 
2512
                   uint64_t pos_arg, uint flags);
 
2513
#ifdef HAVE_REPLICATION
2310
2514
  void pack_info(Protocol* protocol);
 
2515
#endif /* HAVE_REPLICATION */
 
2516
#else
 
2517
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2518
#endif
2311
2519
 
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()
2315
2523
  {
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));
2318
2526
  }
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);
 
2532
#endif
2323
2533
 
2324
2534
private:
 
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);
 
2538
#endif
2327
2539
};
2328
2540
 
2329
2541
 
2345
2557
  */
2346
2558
  bool fake_base;
2347
2559
public:
2348
 
  unsigned char* block;
 
2560
  uchar* block;
2349
2561
  const char *event_buf;
2350
 
  uint32_t block_len;
2351
 
  uint32_t file_id;
 
2562
  uint block_len;
 
2563
  uint file_id;
2352
2564
  bool inited_from_old;
2353
2565
 
 
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 */
 
2576
#else
 
2577
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2578
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
 
2579
             bool enable_local);
 
2580
#endif
2361
2581
 
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()
2365
2585
  {
2366
 
    free((char*) event_buf);
 
2586
    my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
2367
2587
  }
2368
2588
 
2369
2589
  Log_event_type get_type_code()
2377
2597
            4 + 1 + block_len);
2378
2598
  }
2379
2599
  bool is_valid() const { return inited_from_old || block != 0; }
 
2600
#ifndef DRIZZLE_CLIENT
2380
2601
  bool write_data_header(IO_CACHE* file);
2381
2602
  bool write_data_body(IO_CACHE* file);
2382
2603
  /*
2384
2605
    write it as Load event - used on the slave
2385
2606
  */
2386
2607
  bool write_base(IO_CACHE* file);
 
2608
#endif
2387
2609
 
2388
2610
private:
 
2611
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2389
2612
  virtual int do_apply_event(Relay_log_info const *rli);
 
2613
#endif
2390
2614
};
2391
2615
 
2392
2616
 
2399
2623
class Append_block_log_event: public Log_event
2400
2624
{
2401
2625
public:
2402
 
  unsigned char* block;
2403
 
  uint32_t block_len;
2404
 
  uint32_t file_id;
 
2626
  uchar* block;
 
2627
  uint block_len;
 
2628
  uint file_id;
2405
2629
  /*
2406
2630
    'db' is filled when the event is created in mysql_load() (the
2407
2631
    event needs to have a 'db' member to be well filtered by
2415
2639
  */
2416
2640
  const char* db;
2417
2641
 
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 */
 
2649
#else
 
2650
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2651
#endif
2422
2652
 
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; }
 
2663
#endif
2432
2664
 
2433
2665
private:
 
2666
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2434
2667
  virtual int do_apply_event(Relay_log_info const *rli);
 
2668
#endif
2435
2669
};
2436
2670
 
2437
2671
 
2444
2678
class Delete_file_log_event: public Log_event
2445
2679
{
2446
2680
public:
2447
 
  uint32_t file_id;
 
2681
  uint file_id;
2448
2682
  const char* db; /* see comment in Append_block_log_event */
2449
2683
 
 
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 */
 
2689
#else
 
2690
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2691
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
 
2692
             bool enable_local);
 
2693
#endif
2452
2694
 
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; }
 
2704
#endif
2461
2705
 
2462
2706
private:
 
2707
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2463
2708
  virtual int do_apply_event(Relay_log_info const *rli);
 
2709
#endif
2464
2710
};
2465
2711
 
2466
2712
 
2473
2719
class Execute_load_log_event: public Log_event
2474
2720
{
2475
2721
public:
2476
 
  uint32_t file_id;
 
2722
  uint file_id;
2477
2723
  const char* db; /* see comment in Append_block_log_event */
2478
2724
 
 
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 */
 
2730
#else
 
2731
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2732
#endif
2481
2733
 
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; }
 
2744
#endif
2491
2745
 
2492
2746
private:
 
2747
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2493
2748
  virtual int do_apply_event(Relay_log_info const *rli);
 
2749
#endif
2494
2750
};
2495
2751
 
2496
2752
 
2506
2762
class Begin_load_query_log_event: public Append_block_log_event
2507
2763
{
2508
2764
public:
 
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 */
 
2773
#endif
 
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; }
2519
2779
private:
 
2780
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2520
2781
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2782
#endif
2521
2783
};
2522
2784
 
2523
2785
 
2539
2801
class Execute_load_query_log_event: public Query_log_event
2540
2802
{
2541
2803
public:
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
2546
2808
  /*
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
2551
2813
  */
2552
2814
  enum_load_dup_handling dup_handling;
2553
2815
 
 
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 */
 
2827
#else
 
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);
 
2832
#endif
 
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; }
2569
2840
 
2570
2841
  ulong get_post_header_size_for_derived();
 
2842
#ifndef DRIZZLE_CLIENT
2571
2843
  bool write_post_header_for_derived(IO_CACHE* file);
 
2844
#endif
2572
2845
 
2573
2846
private:
 
2847
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2574
2848
  virtual int do_apply_event(Relay_log_info const *rli);
2575
 
};
2576
 
 
2577
 
 
2578
 
char *str_to_hex(char *to, const char *from, uint32_t len);
 
2849
#endif
 
2850
};
 
2851
 
 
2852
 
 
2853
#ifdef DRIZZLE_CLIENT
 
2854
/**
 
2855
  @class Unknown_log_event
 
2856
 
 
2857
  @section Unknown_log_event_binary_format Binary Format
 
2858
*/
 
2859
class Unknown_log_event: public Log_event
 
2860
{
 
2861
public:
 
2862
  /*
 
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).
 
2866
  */
 
2867
  Unknown_log_event(const char* buf,
 
2868
                    const Format_description_log_event *description_event):
 
2869
    Log_event(buf, description_event)
 
2870
  {}
 
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; }
 
2875
};
 
2876
#endif
 
2877
char *str_to_hex(char *to, const char *from, uint len);
2579
2878
 
2580
2879
/**
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; }
2870
3169
 
 
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, 
 
3173
#endif
 
3174
#ifdef HAVE_REPLICATION
 
3175
  Table_map_log_event(const char *buf, uint event_len, 
2874
3176
                      const Format_description_log_event *description_event);
 
3177
#endif
2875
3178
 
2876
3179
  ~Table_map_log_event();
2877
3180
 
2879
3182
  virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
2880
3183
 
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; }
 
3190
#endif
 
3191
 
 
3192
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2886
3193
  virtual void pack_info(Protocol *protocol);
 
3194
#endif
 
3195
 
 
3196
#ifdef DRIZZLE_CLIENT
 
3197
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3198
#endif
 
3199
 
2887
3200
 
2888
3201
private:
 
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);
 
3206
#endif
2892
3207
 
 
3208
#ifndef DRIZZLE_CLIENT
2893
3209
  Table         *m_table;
 
3210
#endif
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;
 
3216
  uchar         *m_coltype;
2900
3217
 
2901
 
  unsigned char         *m_memory;
 
3218
  uchar         *m_memory;
2902
3219
  ulong          m_table_id;
2903
3220
  flag_set       m_flags;
2904
3221
 
2905
3222
  size_t         m_data_size;
2906
3223
 
2907
 
  unsigned char          *m_field_metadata;        // buffer for field metadata
 
3224
  uchar          *m_field_metadata;        // buffer for field metadata
2908
3225
  /*
2909
3226
    The size of field metadata buffer set by calling save_field_metadata()
2910
3227
  */
2911
3228
  ulong          m_field_metadata_size;   
2912
 
  unsigned char         *m_null_bits;
2913
 
  unsigned char         *m_meta_memory;
 
3229
  uchar         *m_null_bits;
 
3230
  uchar         *m_meta_memory;
2914
3231
};
2915
3232
 
2916
3233
 
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; }
2986
3303
 
 
3304
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
2987
3305
  virtual void pack_info(Protocol *protocol);
2988
 
 
2989
 
  int add_row_data(unsigned char *data, size_t length)
 
3306
#endif
 
3307
 
 
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;
 
3311
#endif
 
3312
 
 
3313
#ifndef DRIZZLE_CLIENT
 
3314
  int add_row_data(uchar *data, size_t length)
2990
3315
  {
2991
3316
    return do_add_row_data(data,length); 
2992
3317
  }
 
3318
#endif
2993
3319
 
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; }
3000
3326
 
 
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; }
 
3331
#endif
3004
3332
  /*
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;
3013
3341
  }
3014
3342
 
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 */
3016
3344
 
3017
3345
protected:
3018
3346
  /* 
3019
3347
     The constructors are protected since you're supposed to inherit
3020
3348
     this class, not create instances of this class.
3021
3349
  */
 
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, 
 
3353
#endif
 
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);
3027
3357
 
3028
 
  virtual int do_add_row_data(unsigned char *data, size_t length);
3029
 
 
 
3358
#ifdef DRIZZLE_CLIENT
 
3359
  void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
 
3360
#endif
 
3361
 
 
3362
#ifndef DRIZZLE_CLIENT
 
3363
  virtual int do_add_row_data(uchar *data, size_t length);
 
3364
#endif
 
3365
 
 
3366
#ifndef DRIZZLE_CLIENT
3030
3367
  Table *m_table;               /* The table the rows belong to */
 
3368
#endif
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)];
3048
3386
 
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 */
3052
3390
 
3053
3391
  flag_set m_flags;             /* Flags for row-level events */
3054
3392
 
3055
3393
  /* helper functions */
3056
3394
 
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 */
3060
3399
 
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);
3075
3414
    return result;
3076
3415
  }
 
3416
#endif
3077
3417
 
3078
3418
private:
3079
3419
 
 
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);
3131
3472
      
3132
3473
  */
3133
3474
  virtual int do_exec_row(const Relay_log_info *const rli) = 0;
 
3475
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
3134
3476
 
3135
3477
  friend class Old_rows_log_event;
3136
3478
};
3153
3495
    TYPE_CODE = WRITE_ROWS_EVENT
3154
3496
  };
3155
3497
 
 
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, 
 
3501
#endif
 
3502
#ifdef HAVE_REPLICATION
 
3503
  Write_rows_log_event(const char *buf, uint event_len, 
3159
3504
                       const Format_description_log_event *description_event);
 
3505
#endif
 
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)
3165
3512
  {
3166
3513
    return thd->binlog_write_row(table, is_transactional, after_record);
3167
3514
  }
 
3515
#endif
3168
3516
 
3169
3517
private:
3170
3518
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3171
3519
 
 
3520
#ifdef DRIZZLE_CLIENT
 
3521
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3522
#endif
 
3523
 
 
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);
 
3528
#endif
3175
3529
};
3176
3530
 
3177
3531
 
3196
3550
    TYPE_CODE = UPDATE_ROWS_EVENT
3197
3551
  };
3198
3552
 
 
3553
#ifndef DRIZZLE_CLIENT
3199
3554
  Update_rows_log_event(THD*, Table*, ulong table_id,
3200
3555
                        bool is_transactional);
3201
3556
 
3202
3557
  void init(MY_BITMAP const *cols);
 
3558
#endif
3203
3559
 
3204
3560
  virtual ~Update_rows_log_event();
3205
3561
 
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);
 
3565
#endif
3208
3566
 
 
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)
3213
3572
  {
3214
3573
    return thd->binlog_update_row(table, is_transactional,
3215
3574
                                  before_record, after_record);
3216
3575
  }
 
3576
#endif
3217
3577
 
3218
3578
  virtual bool is_valid() const
3219
3579
  {
3223
3583
protected:
3224
3584
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3225
3585
 
 
3586
#ifdef DRIZZLE_CLIENT
 
3587
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3588
#endif
 
3589
 
 
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) */
3229
3595
};
3230
3596
 
3231
3597
/**
3257
3623
    TYPE_CODE = DELETE_ROWS_EVENT
3258
3624
  };
3259
3625
 
 
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, 
 
3629
#endif
 
3630
#ifdef HAVE_REPLICATION
 
3631
  Delete_rows_log_event(const char *buf, uint event_len, 
3263
3632
                        const Format_description_log_event *description_event);
 
3633
#endif
 
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)))
3269
3640
  {
3270
3641
    return thd->binlog_delete_row(table, is_transactional, before_record);
3271
3642
  }
 
3643
#endif
3272
3644
  
3273
3645
protected:
3274
3646
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3275
3647
 
 
3648
#ifdef DRIZZLE_CLIENT
 
3649
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3650
#endif
 
3651
 
 
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);
 
3656
#endif
3279
3657
};
3280
3658
 
3281
3659
 
3317
3695
*/
3318
3696
class Incident_log_event : public Log_event {
3319
3697
public:
 
3698
#ifndef DRIZZLE_CLIENT
3320
3699
  Incident_log_event(THD *thd_arg, Incident incident)
3321
3700
    : Log_event(thd_arg, 0, false), m_incident(incident)
3322
3701
  {
3331
3710
    m_message= msg;
3332
3711
    return;
3333
3712
  }
 
3713
#endif
3334
3714
 
 
3715
#ifndef DRIZZLE_CLIENT
3335
3716
  void pack_info(Protocol*);
 
3717
#endif
3336
3718
 
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);
3339
3721
 
3340
3722
  virtual ~Incident_log_event();
3341
3723
 
 
3724
#ifdef DRIZZLE_CLIENT
 
3725
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3726
#endif
 
3727
 
 
3728
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
3342
3729
  virtual int do_apply_event(Relay_log_info const *rli);
 
3730
#endif
3343
3731
 
3344
3732
  virtual bool write_data_header(IO_CACHE *file);
3345
3733
  virtual bool write_data_body(IO_CACHE *file);
3369
3757
    reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3370
3758
}
3371
3759
 
 
3760
#ifndef DRIZZLE_CLIENT
3372
3761
/*****************************************************************************
3373
3762
 
3374
3763
  Heartbeat Log Event class
3387
3776
class Heartbeat_log_event: public Log_event
3388
3777
{
3389
3778
public:
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
3396
3785
              log_pos >= BIN_LOG_HEADER_SIZE);
3397
3786
    }
3398
3787
  const char * get_log_ident() { return log_ident; }
3399
 
  uint32_t get_ident_len() { return ident_len; }
 
3788
  uint get_ident_len() { return ident_len; }
3400
3789
  
3401
3790
private:
3402
3791
  const char* log_ident;
3403
 
  uint32_t ident_len;
 
3792
  uint ident_len;
3404
3793
};
 
3794
#endif
3405
3795
 
3406
3796
/**
3407
3797
  @} (end of group Replication)