~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/log_event.h

Removed/replaced DBUG symbols and standardized TRUE/FALSE

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
 
1
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
/**
21
17
  @addtogroup Replication
32
28
#ifndef _log_event_h
33
29
#define _log_event_h
34
30
 
35
 
#if defined(USE_PRAGMA_INTERFACE)
 
31
#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT)
36
32
#pragma interface                       /* gcc class implementation */
37
33
#endif
38
34
 
39
 
#include <mysys/my_bitmap.h>
 
35
#include <my_bitmap.h>
40
36
#include "rpl_constants.h"
 
37
#ifndef MYSQL_CLIENT
41
38
#include "rpl_record.h"
42
39
#include "rpl_reporting.h"
43
 
 
44
 
#include <drizzled/sql_string.h>       /* append_query_string() needs String declaration */
 
40
#else
 
41
#include "my_decimal.h"
 
42
#endif
45
43
 
46
44
/**
47
45
   Either assert or return an error.
157
155
  const char* line_start;
158
156
  const char* escaped;
159
157
  int cached_new_format;
160
 
  uint8_t field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len;
 
158
  uint8 field_term_len,enclosed_len,line_term_len,line_start_len, escaped_len;
161
159
  char opt_flags;
162
160
  char empty_flags;
163
161
 
211
209
   event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but
212
210
   LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.
213
211
*/
214
 
#define LOG_EVENT_MINIMAL_HEADER_LEN (uint8_t)19
 
212
#define LOG_EVENT_MINIMAL_HEADER_LEN 19
215
213
 
216
214
/* event-specific post-header sizes */
217
215
// where 3.23, 4.x and 5.0 agree
400
398
/**
401
399
  @def LOG_EVENT_THREAD_SPECIFIC_F
402
400
 
403
 
  If the query depends on the thread (for example: TEMPORARY Table).
 
401
  If the query depends on the thread (for example: TEMPORARY TABLE).
404
402
  Currently this is used by mysqlbinlog to know it must print
405
403
  SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it
406
404
  for every query but this would be slow).
455
453
 
456
454
/* Shouldn't be defined before */
457
455
#define EXPECTED_OPTIONS \
458
 
  ((1U << 14) | (1U << 26) | (1U << 27) | (1U << 19))
 
456
  ((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19))
459
457
 
460
458
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
461
459
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
547
545
};
548
546
 
549
547
 
 
548
#ifndef MYSQL_CLIENT
550
549
class String;
551
 
class DRIZZLE_BIN_LOG;
 
550
class MYSQL_BIN_LOG;
552
551
class THD;
 
552
#endif
553
553
 
554
554
class Format_description_log_event;
555
555
class Relay_log_info;
556
556
 
 
557
#ifdef MYSQL_CLIENT
 
558
enum enum_base64_output_mode {
 
559
  BASE64_OUTPUT_NEVER= 0,
 
560
  BASE64_OUTPUT_AUTO= 1,
 
561
  BASE64_OUTPUT_ALWAYS= 2,
 
562
  BASE64_OUTPUT_UNSPEC= 3,
 
563
  /* insert new output modes here */
 
564
  BASE64_OUTPUT_MODE_COUNT
 
565
};
 
566
 
 
567
/*
 
568
  A structure for mysqlbinlog to know how to print events
 
569
 
 
570
  This structure is passed to the event's print() methods,
 
571
 
 
572
  There are two types of settings stored here:
 
573
  1. Last db, flags2, sql_mode etc comes from the last printed event.
 
574
     They are stored so that only the necessary USE and SET commands
 
575
     are printed.
 
576
  2. Other information on how to print the events, e.g. short_form,
 
577
     hexdump_from.  These are not dependent on the last event.
 
578
*/
 
579
typedef struct st_print_event_info
 
580
{
 
581
  /*
 
582
    Settings for database, sql_mode etc that comes from the last event
 
583
    that was printed.  We cache these so that we don't have to print
 
584
    them if they are unchanged.
 
585
  */
 
586
  // TODO: have the last catalog here ??
 
587
  char db[FN_REFLEN+1]; // TODO: make this a LEX_STRING when thd->db is
 
588
  bool flags2_inited;
 
589
  uint32 flags2;
 
590
  bool sql_mode_inited;
 
591
  ulong sql_mode;               /* must be same as THD.variables.sql_mode */
 
592
  ulong auto_increment_increment, auto_increment_offset;
 
593
  bool charset_inited;
 
594
  char charset[6]; // 3 variables, each of them storable in 2 bytes
 
595
  char time_zone_str[MAX_TIME_ZONE_NAME_LENGTH];
 
596
  uint lc_time_names_number;
 
597
  uint charset_database_number;
 
598
  uint thread_id;
 
599
  bool thread_id_printed;
 
600
 
 
601
  st_print_event_info();
 
602
 
 
603
  ~st_print_event_info() {
 
604
    close_cached_file(&head_cache);
 
605
    close_cached_file(&body_cache);
 
606
  }
 
607
  bool init_ok() /* tells if construction was successful */
 
608
    { return my_b_inited(&head_cache) && my_b_inited(&body_cache); }
 
609
 
 
610
 
 
611
  /* Settings on how to print the events */
 
612
  bool short_form;
 
613
  enum_base64_output_mode base64_output_mode;
 
614
  /*
 
615
    This is set whenever a Format_description_event is printed.
 
616
    Later, when an event is printed in base64, this flag is tested: if
 
617
    no Format_description_event has been seen, it is unsafe to print
 
618
    the base64 event, so an error message is generated.
 
619
  */
 
620
  bool printed_fd_event;
 
621
  my_off_t hexdump_from;
 
622
  uint8 common_header_len;
 
623
  char delimiter[16];
 
624
 
 
625
  /*
 
626
     These two caches are used by the row-based replication events to
 
627
     collect the header information and the main body of the events
 
628
     making up a statement.
 
629
   */
 
630
  IO_CACHE head_cache;
 
631
  IO_CACHE body_cache;
 
632
} PRINT_EVENT_INFO;
 
633
#endif
 
634
 
557
635
/**
558
636
  the struct aggregates two paramenters that identify an event
559
637
  uniquely in scope of communication of a particular master and slave couple.
770
848
    The master's server id (is preserved in the relay log; used to
771
849
    prevent from infinite loops in circular replication).
772
850
  */
773
 
  uint32_t server_id;
 
851
  uint32 server_id;
774
852
 
775
853
  /**
776
854
    Some 16 flags. See the definitions above for LOG_EVENT_TIME_F,
777
855
    LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F, and
778
856
    LOG_EVENT_SUPPRESS_USE_F for notes.
779
857
  */
780
 
  uint16_t flags;
 
858
  uint16 flags;
781
859
 
782
860
  bool cache_stmt;
783
861
 
787
865
  */
788
866
  ulong slave_exec_mode;
789
867
 
 
868
#ifndef MYSQL_CLIENT
790
869
  THD* thd;
791
870
 
792
871
  Log_event();
793
 
  Log_event(THD* thd_arg, uint16_t flags_arg, bool cache_stmt);
 
872
  Log_event(THD* thd_arg, uint16 flags_arg, bool cache_stmt);
794
873
  /*
795
874
    read_log_event() functions read an event from a binlog or relay
796
875
    log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the
814
893
    EVENTS.
815
894
  */
816
895
  static void init_show_field_list(List<Item>* field_list);
 
896
#ifdef HAVE_REPLICATION
817
897
  int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
818
898
 
819
899
  /*
823
903
 
824
904
  virtual void pack_info(Protocol *protocol);
825
905
 
 
906
#endif /* HAVE_REPLICATION */
826
907
  virtual const char* get_db()
827
908
  {
828
909
    return thd ? thd->db : 0;
829
910
  }
 
911
#else
 
912
  Log_event() : temp_buf(0) {}
 
913
    /* avoid having to link mysqlbinlog against libpthread */
 
914
  static Log_event* read_log_event(IO_CACHE* file,
 
915
                                   const Format_description_log_event
 
916
                                   *description_event);
 
917
  /* print*() functions are used by mysqlbinlog */
 
918
  virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
 
919
  void print_timestamp(IO_CACHE* file, time_t *ts = 0);
 
920
  void print_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
 
921
                    bool is_more);
 
922
  void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
 
923
                    bool is_more);
 
924
#endif
830
925
 
831
926
  static void *operator new(size_t size)
832
927
  {
834
929
  }
835
930
 
836
931
  static void operator delete(void *ptr,
837
 
                              size_t size __attribute__((unused)))
 
932
                              size_t size __attribute__((__unused__)))
838
933
  {
839
 
    free((unsigned char*) ptr);
 
934
    my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
840
935
  }
841
936
 
842
937
  /* Placement version of the above operators */
843
938
  static void *operator new(size_t, void* ptr) { return ptr; }
844
939
  static void operator delete(void*, void*) { }
845
940
 
 
941
#ifndef MYSQL_CLIENT
846
942
  bool write_header(IO_CACHE* file, ulong data_length);
847
943
  virtual bool write(IO_CACHE* file)
848
944
  {
850
946
            write_data_header(file) ||
851
947
            write_data_body(file));
852
948
  }
853
 
  virtual bool write_data_header(IO_CACHE* file __attribute__((unused)))
 
949
  virtual bool write_data_header(IO_CACHE* file __attribute__((__unused__)))
854
950
  { return 0; }
855
951
  virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
856
952
  { return 0; }
865
961
      return tmp_thd->start_time;
866
962
    return my_time(0);
867
963
  }
 
964
#endif
868
965
  virtual Log_event_type get_type_code() = 0;
869
966
  virtual bool is_valid() const = 0;
870
967
  virtual bool is_artificial_event() { return 0; }
877
974
  {
878
975
    if (temp_buf)
879
976
    {
880
 
      free(temp_buf);
 
977
      my_free(temp_buf, MYF(0));
881
978
      temp_buf = 0;
882
979
    }
883
980
  }
886
983
    is calculated during write()
887
984
  */
888
985
  virtual int get_data_size() { return 0;}
889
 
  static Log_event* read_log_event(const char* buf, uint32_t event_len,
 
986
  static Log_event* read_log_event(const char* buf, uint event_len,
890
987
                                   const char **error,
891
988
                                   const Format_description_log_event
892
989
                                   *description_event);
901
998
 
902
999
  /* Return start of query time or current time */
903
1000
 
 
1001
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
904
1002
public:
905
1003
 
906
1004
  /**
977
1075
    @retval 0     Event applied successfully
978
1076
    @retval errno Error code if event application failed
979
1077
  */
980
 
  virtual int do_apply_event(Relay_log_info const *rli __attribute__((unused)))
 
1078
  virtual int do_apply_event(Relay_log_info const *rli __attribute__((__unused__)))
981
1079
  {
982
1080
    return 0;                /* Default implementation does nothing */
983
1081
  }
1039
1137
     non-zero. The caller shall decrease the counter by one.
1040
1138
   */
1041
1139
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
1140
#endif
1042
1141
};
1043
1142
 
1044
1143
 
1389
1488
    we pass it with q_len, so we would not have to call strlen()
1390
1489
    otherwise, set it to 0, in which case, we compute it with strlen()
1391
1490
  */
1392
 
  uint32_t q_len;
1393
 
  uint32_t db_len;
1394
 
  uint16_t error_code;
 
1491
  uint32 q_len;
 
1492
  uint32 db_len;
 
1493
  uint16 error_code;
1395
1494
  ulong thread_id;
1396
1495
  /*
1397
1496
    For events created by Query_log_event::do_apply_event (and
1406
1505
    concerned) from here.
1407
1506
  */
1408
1507
 
1409
 
  uint32_t catalog_len;                 // <= 255 char; 0 means uninited
 
1508
  uint catalog_len;                     // <= 255 char; 0 means uninited
1410
1509
 
1411
1510
  /*
1412
1511
    We want to be able to store a variable number of N-bit status vars:
1428
1527
    Query_log_event, so automatically benefit from the work already done for
1429
1528
    status variables in Query_log_event.
1430
1529
 */
1431
 
  uint16_t status_vars_len;
 
1530
  uint16 status_vars_len;
1432
1531
 
1433
1532
  /*
1434
1533
    'flags2' is a second set of flags (on top of those in Log_event), for
1443
1542
  bool sql_mode_inited;
1444
1543
  bool charset_inited;
1445
1544
 
1446
 
  uint32_t flags2;
 
1545
  uint32 flags2;
1447
1546
  /* In connections sql_mode is 32 bits now but will be 64 bits soon */
1448
1547
  ulong sql_mode;
1449
1548
  ulong auto_increment_increment, auto_increment_offset;
1450
1549
  char charset[6];
1451
 
  uint32_t time_zone_len; /* 0 means uninited */
 
1550
  uint time_zone_len; /* 0 means uninited */
1452
1551
  const char *time_zone_str;
1453
 
  uint32_t lc_time_names_number; /* 0 means en_US */
1454
 
  uint32_t charset_database_number;
 
1552
  uint lc_time_names_number; /* 0 means en_US */
 
1553
  uint charset_database_number;
1455
1554
 
 
1555
#ifndef MYSQL_CLIENT
1456
1556
 
1457
1557
  Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
1458
1558
                  bool using_trans, bool suppress_use,
1459
1559
                  THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
1460
1560
  const char* get_db() { return db; }
 
1561
#ifdef HAVE_REPLICATION
1461
1562
  void pack_info(Protocol* protocol);
 
1563
#endif /* HAVE_REPLICATION */
 
1564
#else
 
1565
  void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
 
1566
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1567
#endif
1462
1568
 
1463
1569
  Query_log_event();
1464
 
  Query_log_event(const char* buf, uint32_t event_len,
 
1570
  Query_log_event(const char* buf, uint event_len,
1465
1571
                  const Format_description_log_event *description_event,
1466
1572
                  Log_event_type event_type);
1467
1573
  ~Query_log_event()
1468
1574
  {
1469
1575
    if (data_buf)
1470
 
      free((unsigned char*) data_buf);
 
1576
      my_free((uchar*) data_buf, MYF(0));
1471
1577
  }
1472
1578
  Log_event_type get_type_code() { return QUERY_EVENT; }
 
1579
#ifndef MYSQL_CLIENT
1473
1580
  bool write(IO_CACHE* file);
1474
 
  virtual bool write_post_header_for_derived(IO_CACHE* file __attribute__((unused)))
 
1581
  virtual bool write_post_header_for_derived(IO_CACHE* file __attribute__((__unused__)))
1475
1582
  { return false; }
 
1583
#endif
1476
1584
  bool is_valid() const { return query != 0; }
1477
1585
 
1478
1586
  /*
1483
1591
  /* Writes derived event-specific part of post header. */
1484
1592
 
1485
1593
public:        /* !!! Public in this patch to allow old usage */
 
1594
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1486
1595
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
1487
1596
  virtual int do_apply_event(Relay_log_info const *rli);
1488
1597
  virtual int do_update_pos(Relay_log_info *rli);
1489
1598
 
1490
1599
  int do_apply_event(Relay_log_info const *rli,
1491
1600
                       const char *query_arg,
1492
 
                       uint32_t q_len_arg);
 
1601
                       uint32 q_len_arg);
 
1602
#endif /* HAVE_REPLICATION */
1493
1603
};
1494
1604
 
1495
1605
 
 
1606
#ifdef HAVE_REPLICATION
 
1607
 
1496
1608
/**
1497
1609
  @class Slave_log_event
1498
1610
 
1552
1664
  char* master_log;
1553
1665
  int master_host_len;
1554
1666
  int master_log_len;
1555
 
  uint16_t master_port;
 
1667
  uint16 master_port;
1556
1668
 
 
1669
#ifndef MYSQL_CLIENT
1557
1670
  Slave_log_event(THD* thd_arg, Relay_log_info* rli);
1558
1671
  void pack_info(Protocol* protocol);
 
1672
#else
 
1673
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1674
#endif
1559
1675
 
1560
 
  Slave_log_event(const char* buf, uint32_t event_len);
 
1676
  Slave_log_event(const char* buf, uint event_len);
1561
1677
  ~Slave_log_event();
1562
1678
  int get_data_size();
1563
1679
  bool is_valid() const { return master_host != 0; }
1564
1680
  Log_event_type get_type_code() { return SLAVE_EVENT; }
 
1681
#ifndef MYSQL_CLIENT
1565
1682
  bool write(IO_CACHE* file);
 
1683
#endif
1566
1684
 
1567
1685
private:
 
1686
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1568
1687
  virtual int do_apply_event(Relay_log_info const* rli);
 
1688
#endif
1569
1689
};
1570
1690
 
 
1691
#endif /* HAVE_REPLICATION */
 
1692
 
1571
1693
 
1572
1694
/**
1573
1695
  @class Load_log_event
1579
1701
   (1)    USE db;
1580
1702
   (2)    LOAD DATA [LOCAL] INFILE 'file_name'
1581
1703
   (3)    [REPLACE | IGNORE]
1582
 
   (4)    INTO Table 'table_name'
 
1704
   (4)    INTO TABLE 'table_name'
1583
1705
   (5)    [FIELDS
1584
1706
   (6)      [TERMINATED BY 'field_term']
1585
1707
   (7)      [[OPTIONALLY] ENCLOSED BY 'enclosed']
1771
1893
class Load_log_event: public Log_event
1772
1894
{
1773
1895
private:
1774
 
  uint32_t get_query_buffer_length();
 
1896
  uint get_query_buffer_length();
1775
1897
  void print_query(bool need_db, char *buf, char **end,
1776
1898
                   char **fn_start, char **fn_end);
1777
1899
protected:
1782
1904
public:
1783
1905
  ulong thread_id;
1784
1906
  ulong slave_proxy_id;
1785
 
  uint32_t table_name_len;
 
1907
  uint32 table_name_len;
1786
1908
  /*
1787
1909
    No need to have a catalog, as these events can only come from 4.x.
1788
1910
    TODO: this may become false if Dmitri pushes his new LOAD DATA INFILE in
1789
1911
    5.0 only (not in 4.x).
1790
1912
  */
1791
 
  uint32_t db_len;
1792
 
  uint32_t fname_len;
1793
 
  uint32_t num_fields;
 
1913
  uint32 db_len;
 
1914
  uint32 fname_len;
 
1915
  uint32 num_fields;
1794
1916
  const char* fields;
1795
 
  const unsigned char* field_lens;
1796
 
  uint32_t field_block_len;
 
1917
  const uchar* field_lens;
 
1918
  uint32 field_block_len;
1797
1919
 
1798
1920
  const char* table_name;
1799
1921
  const char* db;
1800
1922
  const char* fname;
1801
 
  uint32_t skip_lines;
 
1923
  uint32 skip_lines;
1802
1924
  sql_ex_info sql_ex;
1803
1925
  bool local_fname;
1804
1926
 
1805
1927
  /* fname doesn't point to memory inside Log_event::temp_buf  */
1806
 
  void set_fname_outside_temp_buf(const char *afname, uint32_t alen)
 
1928
  void set_fname_outside_temp_buf(const char *afname, uint alen)
1807
1929
  {
1808
1930
    fname= afname;
1809
1931
    fname_len= alen;
1815
1937
    return local_fname;
1816
1938
  }
1817
1939
 
 
1940
#ifndef MYSQL_CLIENT
1818
1941
  String field_lens_buf;
1819
1942
  String fields_buf;
1820
1943
 
1825
1948
  void set_fields(const char* db, List<Item> &fields_arg,
1826
1949
                  Name_resolution_context *context);
1827
1950
  const char* get_db() { return db; }
 
1951
#ifdef HAVE_REPLICATION
1828
1952
  void pack_info(Protocol* protocol);
 
1953
#endif /* HAVE_REPLICATION */
 
1954
#else
 
1955
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1956
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool commented);
 
1957
#endif
1829
1958
 
1830
1959
  /*
1831
1960
    Note that for all the events related to LOAD DATA (Load_log_event,
1833
1962
    logging of LOAD DATA is going to be changed in 4.1 or 5.0, this is only used
1834
1963
    for the common_header_len (post_header_len will not be changed).
1835
1964
  */
1836
 
  Load_log_event(const char* buf, uint32_t event_len,
 
1965
  Load_log_event(const char* buf, uint event_len,
1837
1966
                 const Format_description_log_event* description_event);
1838
1967
  ~Load_log_event()
1839
1968
  {}
1841
1970
  {
1842
1971
    return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
1843
1972
  }
 
1973
#ifndef MYSQL_CLIENT
1844
1974
  bool write_data_header(IO_CACHE* file);
1845
1975
  bool write_data_body(IO_CACHE* file);
 
1976
#endif
1846
1977
  bool is_valid() const { return table_name != 0; }
1847
1978
  int get_data_size()
1848
1979
  {
1852
1983
  }
1853
1984
 
1854
1985
public:        /* !!! Public in this patch to allow old usage */
 
1986
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1855
1987
  virtual int do_apply_event(Relay_log_info const* rli)
1856
1988
  {
1857
1989
    return do_apply_event(thd->slave_net,rli,0);
1859
1991
 
1860
1992
  int do_apply_event(NET *net, Relay_log_info const *rli,
1861
1993
                     bool use_rli_only_for_errors);
 
1994
#endif
1862
1995
};
1863
1996
 
1864
1997
extern char server_version[SERVER_VERSION_LENGTH];
1904
2037
     fixed.
1905
2038
  */
1906
2039
  time_t created;
1907
 
  uint16_t binlog_version;
 
2040
  uint16 binlog_version;
1908
2041
  char server_version[ST_SERVER_VER_LEN];
1909
2042
  /*
1910
2043
    artifical_event is 1 in the case where this is a generated event that
1918
2051
  */
1919
2052
  bool dont_set_created;
1920
2053
 
 
2054
#ifndef MYSQL_CLIENT
1921
2055
  Start_log_event_v3();
 
2056
#ifdef HAVE_REPLICATION
1922
2057
  void pack_info(Protocol* protocol);
 
2058
#endif /* HAVE_REPLICATION */
 
2059
#else
 
2060
  Start_log_event_v3() {}
 
2061
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2062
#endif
1923
2063
 
1924
2064
  Start_log_event_v3(const char* buf,
1925
2065
                     const Format_description_log_event* description_event);
1926
2066
  ~Start_log_event_v3() {}
1927
2067
  Log_event_type get_type_code() { return START_EVENT_V3;}
 
2068
#ifndef MYSQL_CLIENT
1928
2069
  bool write(IO_CACHE* file);
 
2070
#endif
1929
2071
  bool is_valid() const { return 1; }
1930
2072
  int get_data_size()
1931
2073
  {
1934
2076
  virtual bool is_artificial_event() { return artificial_event; }
1935
2077
 
1936
2078
protected:
 
2079
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1937
2080
  virtual int do_apply_event(Relay_log_info const *rli);
1938
2081
  virtual enum_skip_reason do_shall_skip(Relay_log_info*)
1939
2082
  {
1946
2089
    else
1947
2090
      return Log_event::EVENT_SKIP_NOT;
1948
2091
  }
 
2092
#endif
1949
2093
};
1950
2094
 
1951
2095
 
1968
2112
     LOG_EVENT_HEADER_LEN), except FORMAT_DESCRIPTION_EVENT and ROTATE_EVENT
1969
2113
     (those have a header of size LOG_EVENT_MINIMAL_HEADER_LEN).
1970
2114
  */
1971
 
  uint8_t common_header_len;
1972
 
  uint8_t number_of_event_types;
 
2115
  uint8 common_header_len;
 
2116
  uint8 number_of_event_types;
1973
2117
  /* The list of post-headers' lengthes */
1974
 
  uint8_t *post_header_len;
1975
 
  unsigned char server_version_split[3];
1976
 
  const uint8_t *event_type_permutation;
 
2118
  uint8 *post_header_len;
 
2119
  uchar server_version_split[3];
 
2120
  const uint8 *event_type_permutation;
1977
2121
 
1978
 
  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,
 
2122
  Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
 
2123
  Format_description_log_event(const char* buf, uint event_len,
1980
2124
                               const Format_description_log_event
1981
2125
                               *description_event);
1982
2126
  ~Format_description_log_event()
1983
2127
  {
1984
 
    free((unsigned char*)post_header_len);
 
2128
    my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
1985
2129
  }
1986
2130
  Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
 
2131
#ifndef MYSQL_CLIENT
1987
2132
  bool write(IO_CACHE* file);
 
2133
#endif
1988
2134
  bool is_valid() const
1989
2135
  {
1990
2136
    return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
2004
2150
  void calc_server_version_split();
2005
2151
 
2006
2152
protected:
 
2153
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2007
2154
  virtual int do_apply_event(Relay_log_info const *rli);
2008
2155
  virtual int do_update_pos(Relay_log_info *rli);
2009
2156
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2157
#endif
2010
2158
};
2011
2159
 
2012
2160
 
2050
2198
class Intvar_log_event: public Log_event
2051
2199
{
2052
2200
public:
2053
 
  uint64_t val;
2054
 
  unsigned char type;
 
2201
  ulonglong val;
 
2202
  uchar type;
2055
2203
 
2056
 
  Intvar_log_event(THD* thd_arg,unsigned char type_arg, uint64_t val_arg)
 
2204
#ifndef MYSQL_CLIENT
 
2205
  Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
2057
2206
    :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
2058
2207
  {}
 
2208
#ifdef HAVE_REPLICATION
2059
2209
  void pack_info(Protocol* protocol);
 
2210
#endif /* HAVE_REPLICATION */
 
2211
#else
 
2212
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2213
#endif
2060
2214
 
2061
2215
  Intvar_log_event(const char* buf,
2062
2216
                   const Format_description_log_event *description_event);
2064
2218
  Log_event_type get_type_code() { return INTVAR_EVENT;}
2065
2219
  const char* get_var_type_name();
2066
2220
  int get_data_size() { return  9; /* sizeof(type) + sizeof(val) */;}
 
2221
#ifndef MYSQL_CLIENT
2067
2222
  bool write(IO_CACHE* file);
 
2223
#endif
2068
2224
  bool is_valid() const { return 1; }
2069
2225
 
2070
2226
private:
 
2227
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2071
2228
  virtual int do_apply_event(Relay_log_info const *rli);
2072
2229
  virtual int do_update_pos(Relay_log_info *rli);
2073
2230
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2231
#endif
2074
2232
};
2075
2233
 
2076
2234
 
2115
2273
class Rand_log_event: public Log_event
2116
2274
{
2117
2275
 public:
2118
 
  uint64_t seed1;
2119
 
  uint64_t seed2;
 
2276
  ulonglong seed1;
 
2277
  ulonglong seed2;
2120
2278
 
2121
 
  Rand_log_event(THD* thd_arg, uint64_t seed1_arg, uint64_t seed2_arg)
 
2279
#ifndef MYSQL_CLIENT
 
2280
  Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
2122
2281
    :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
2123
2282
  {}
 
2283
#ifdef HAVE_REPLICATION
2124
2284
  void pack_info(Protocol* protocol);
 
2285
#endif /* HAVE_REPLICATION */
 
2286
#else
 
2287
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2288
#endif
2125
2289
 
2126
2290
  Rand_log_event(const char* buf,
2127
2291
                 const Format_description_log_event *description_event);
2128
2292
  ~Rand_log_event() {}
2129
2293
  Log_event_type get_type_code() { return RAND_EVENT;}
2130
 
  int get_data_size() { return 16; /* sizeof(uint64_t) * 2*/ }
 
2294
  int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
 
2295
#ifndef MYSQL_CLIENT
2131
2296
  bool write(IO_CACHE* file);
 
2297
#endif
2132
2298
  bool is_valid() const { return 1; }
2133
2299
 
2134
2300
private:
 
2301
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2135
2302
  virtual int do_apply_event(Relay_log_info const *rli);
2136
2303
  virtual int do_update_pos(Relay_log_info *rli);
2137
2304
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2305
#endif
2138
2306
};
2139
2307
 
2140
2308
/**
2145
2313
 
2146
2314
  @section Xid_log_event_binary_format Binary Format  
2147
2315
*/
 
2316
#ifdef MYSQL_CLIENT
 
2317
typedef ulonglong my_xid; // this line is the same as in handler.h
 
2318
#endif
 
2319
 
2148
2320
class Xid_log_event: public Log_event
2149
2321
{
2150
2322
 public:
2151
2323
   my_xid xid;
2152
2324
 
 
2325
#ifndef MYSQL_CLIENT
2153
2326
  Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
 
2327
#ifdef HAVE_REPLICATION
2154
2328
  void pack_info(Protocol* protocol);
 
2329
#endif /* HAVE_REPLICATION */
 
2330
#else
 
2331
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2332
#endif
2155
2333
 
2156
2334
  Xid_log_event(const char* buf,
2157
2335
                const Format_description_log_event *description_event);
2158
2336
  ~Xid_log_event() {}
2159
2337
  Log_event_type get_type_code() { return XID_EVENT;}
2160
2338
  int get_data_size() { return sizeof(xid); }
 
2339
#ifndef MYSQL_CLIENT
2161
2340
  bool write(IO_CACHE* file);
 
2341
#endif
2162
2342
  bool is_valid() const { return 1; }
2163
2343
 
2164
2344
private:
 
2345
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2165
2346
  virtual int do_apply_event(Relay_log_info const *rli);
2166
2347
  enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2348
#endif
2167
2349
};
2168
2350
 
2169
2351
/**
2179
2361
{
2180
2362
public:
2181
2363
  char *name;
2182
 
  uint32_t name_len;
 
2364
  uint name_len;
2183
2365
  char *val;
2184
2366
  ulong val_len;
2185
2367
  Item_result type;
2186
 
  uint32_t charset_number;
 
2368
  uint charset_number;
2187
2369
  bool is_null;
2188
 
  User_var_log_event(THD* thd_arg __attribute__((unused)),
2189
 
                     char *name_arg, uint32_t name_len_arg,
 
2370
#ifndef MYSQL_CLIENT
 
2371
  User_var_log_event(THD* thd_arg __attribute__((__unused__)),
 
2372
                     char *name_arg, uint name_len_arg,
2190
2373
                     char *val_arg, ulong val_len_arg, Item_result type_arg,
2191
 
                     uint32_t charset_number_arg)
 
2374
                     uint charset_number_arg)
2192
2375
    :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
2193
2376
    val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
2194
2377
    { is_null= !val; }
2195
2378
  void pack_info(Protocol* protocol);
 
2379
#else
 
2380
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2381
#endif
2196
2382
 
2197
2383
  User_var_log_event(const char* buf,
2198
2384
                     const Format_description_log_event *description_event);
2199
2385
  ~User_var_log_event() {}
2200
2386
  Log_event_type get_type_code() { return USER_VAR_EVENT;}
 
2387
#ifndef MYSQL_CLIENT
2201
2388
  bool write(IO_CACHE* file);
 
2389
#endif
2202
2390
  bool is_valid() const { return 1; }
2203
2391
 
2204
2392
private:
 
2393
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2205
2394
  virtual int do_apply_event(Relay_log_info const *rli);
2206
2395
  virtual int do_update_pos(Relay_log_info *rli);
2207
2396
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2397
#endif
2208
2398
};
2209
2399
 
2210
2400
 
2219
2409
class Stop_log_event: public Log_event
2220
2410
{
2221
2411
public:
 
2412
#ifndef MYSQL_CLIENT
2222
2413
  Stop_log_event() :Log_event()
2223
2414
  {}
 
2415
#else
 
2416
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2417
#endif
2224
2418
 
2225
2419
  Stop_log_event(const char* buf,
2226
2420
                 const Format_description_log_event *description_event):
2231
2425
  bool is_valid() const { return 1; }
2232
2426
 
2233
2427
private:
 
2428
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2234
2429
  virtual int do_update_pos(Relay_log_info *rli);
2235
 
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli __attribute__((unused)))
 
2430
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli __attribute__((__unused__)))
2236
2431
  {
2237
2432
    /*
2238
2433
      Events from ourself should be skipped, but they should not
2243
2438
    else
2244
2439
      return Log_event::EVENT_SKIP_NOT;
2245
2440
  }
 
2441
#endif
2246
2442
};
2247
2443
 
2248
2444
/**
2301
2497
    DUP_NAME= 2 // if constructor should dup the string argument
2302
2498
  };
2303
2499
  const char* new_log_ident;
2304
 
  uint64_t pos;
2305
 
  uint32_t ident_len;
2306
 
  uint32_t flags;
 
2500
  ulonglong pos;
 
2501
  uint ident_len;
 
2502
  uint flags;
 
2503
#ifndef MYSQL_CLIENT
2307
2504
  Rotate_log_event(const char* new_log_ident_arg,
2308
 
                   uint32_t ident_len_arg,
2309
 
                   uint64_t pos_arg, uint32_t flags);
 
2505
                   uint ident_len_arg,
 
2506
                   ulonglong pos_arg, uint flags);
 
2507
#ifdef HAVE_REPLICATION
2310
2508
  void pack_info(Protocol* protocol);
 
2509
#endif /* HAVE_REPLICATION */
 
2510
#else
 
2511
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2512
#endif
2311
2513
 
2312
 
  Rotate_log_event(const char* buf, uint32_t event_len,
 
2514
  Rotate_log_event(const char* buf, uint event_len,
2313
2515
                   const Format_description_log_event* description_event);
2314
2516
  ~Rotate_log_event()
2315
2517
  {
2316
2518
    if (flags & DUP_NAME)
2317
 
      free((unsigned char*) new_log_ident);
 
2519
      my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR));
2318
2520
  }
2319
2521
  Log_event_type get_type_code() { return ROTATE_EVENT;}
2320
2522
  int get_data_size() { return  ident_len + ROTATE_HEADER_LEN;}
2321
2523
  bool is_valid() const { return new_log_ident != 0; }
 
2524
#ifndef MYSQL_CLIENT
2322
2525
  bool write(IO_CACHE* file);
 
2526
#endif
2323
2527
 
2324
2528
private:
 
2529
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2325
2530
  virtual int do_update_pos(Relay_log_info *rli);
2326
2531
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2532
#endif
2327
2533
};
2328
2534
 
2329
2535
 
2345
2551
  */
2346
2552
  bool fake_base;
2347
2553
public:
2348
 
  unsigned char* block;
 
2554
  uchar* block;
2349
2555
  const char *event_buf;
2350
 
  uint32_t block_len;
2351
 
  uint32_t file_id;
 
2556
  uint block_len;
 
2557
  uint file_id;
2352
2558
  bool inited_from_old;
2353
2559
 
 
2560
#ifndef MYSQL_CLIENT
2354
2561
  Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
2355
2562
                        const char* table_name_arg,
2356
2563
                        List<Item>& fields_arg,
2357
2564
                        enum enum_duplicates handle_dup, bool ignore,
2358
 
                        unsigned char* block_arg, uint32_t block_len_arg,
 
2565
                        uchar* block_arg, uint block_len_arg,
2359
2566
                        bool using_trans);
 
2567
#ifdef HAVE_REPLICATION
2360
2568
  void pack_info(Protocol* protocol);
 
2569
#endif /* HAVE_REPLICATION */
 
2570
#else
 
2571
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2572
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
 
2573
             bool enable_local);
 
2574
#endif
2361
2575
 
2362
 
  Create_file_log_event(const char* buf, uint32_t event_len,
 
2576
  Create_file_log_event(const char* buf, uint event_len,
2363
2577
                        const Format_description_log_event* description_event);
2364
2578
  ~Create_file_log_event()
2365
2579
  {
2366
 
    free((char*) event_buf);
 
2580
    my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
2367
2581
  }
2368
2582
 
2369
2583
  Log_event_type get_type_code()
2377
2591
            4 + 1 + block_len);
2378
2592
  }
2379
2593
  bool is_valid() const { return inited_from_old || block != 0; }
 
2594
#ifndef MYSQL_CLIENT
2380
2595
  bool write_data_header(IO_CACHE* file);
2381
2596
  bool write_data_body(IO_CACHE* file);
2382
2597
  /*
2384
2599
    write it as Load event - used on the slave
2385
2600
  */
2386
2601
  bool write_base(IO_CACHE* file);
 
2602
#endif
2387
2603
 
2388
2604
private:
 
2605
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2389
2606
  virtual int do_apply_event(Relay_log_info const *rli);
 
2607
#endif
2390
2608
};
2391
2609
 
2392
2610
 
2399
2617
class Append_block_log_event: public Log_event
2400
2618
{
2401
2619
public:
2402
 
  unsigned char* block;
2403
 
  uint32_t block_len;
2404
 
  uint32_t file_id;
 
2620
  uchar* block;
 
2621
  uint block_len;
 
2622
  uint file_id;
2405
2623
  /*
2406
2624
    'db' is filled when the event is created in mysql_load() (the
2407
2625
    event needs to have a 'db' member to be well filtered by
2415
2633
  */
2416
2634
  const char* db;
2417
2635
 
2418
 
  Append_block_log_event(THD* thd, const char* db_arg, unsigned char* block_arg,
2419
 
                         uint32_t block_len_arg, bool using_trans);
 
2636
#ifndef MYSQL_CLIENT
 
2637
  Append_block_log_event(THD* thd, const char* db_arg, uchar* block_arg,
 
2638
                         uint block_len_arg, bool using_trans);
 
2639
#ifdef HAVE_REPLICATION
2420
2640
  void pack_info(Protocol* protocol);
2421
2641
  virtual int get_create_or_append() const;
 
2642
#endif /* HAVE_REPLICATION */
 
2643
#else
 
2644
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2645
#endif
2422
2646
 
2423
 
  Append_block_log_event(const char* buf, uint32_t event_len,
 
2647
  Append_block_log_event(const char* buf, uint event_len,
2424
2648
                         const Format_description_log_event
2425
2649
                         *description_event);
2426
2650
  ~Append_block_log_event() {}
2427
2651
  Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
2428
2652
  int get_data_size() { return  block_len + APPEND_BLOCK_HEADER_LEN ;}
2429
2653
  bool is_valid() const { return block != 0; }
 
2654
#ifndef MYSQL_CLIENT
2430
2655
  bool write(IO_CACHE* file);
2431
2656
  const char* get_db() { return db; }
 
2657
#endif
2432
2658
 
2433
2659
private:
 
2660
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2434
2661
  virtual int do_apply_event(Relay_log_info const *rli);
 
2662
#endif
2435
2663
};
2436
2664
 
2437
2665
 
2444
2672
class Delete_file_log_event: public Log_event
2445
2673
{
2446
2674
public:
2447
 
  uint32_t file_id;
 
2675
  uint file_id;
2448
2676
  const char* db; /* see comment in Append_block_log_event */
2449
2677
 
 
2678
#ifndef MYSQL_CLIENT
2450
2679
  Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
 
2680
#ifdef HAVE_REPLICATION
2451
2681
  void pack_info(Protocol* protocol);
 
2682
#endif /* HAVE_REPLICATION */
 
2683
#else
 
2684
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2685
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
 
2686
             bool enable_local);
 
2687
#endif
2452
2688
 
2453
 
  Delete_file_log_event(const char* buf, uint32_t event_len,
 
2689
  Delete_file_log_event(const char* buf, uint event_len,
2454
2690
                        const Format_description_log_event* description_event);
2455
2691
  ~Delete_file_log_event() {}
2456
2692
  Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
2457
2693
  int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
2458
2694
  bool is_valid() const { return file_id != 0; }
 
2695
#ifndef MYSQL_CLIENT
2459
2696
  bool write(IO_CACHE* file);
2460
2697
  const char* get_db() { return db; }
 
2698
#endif
2461
2699
 
2462
2700
private:
 
2701
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2463
2702
  virtual int do_apply_event(Relay_log_info const *rli);
 
2703
#endif
2464
2704
};
2465
2705
 
2466
2706
 
2473
2713
class Execute_load_log_event: public Log_event
2474
2714
{
2475
2715
public:
2476
 
  uint32_t file_id;
 
2716
  uint file_id;
2477
2717
  const char* db; /* see comment in Append_block_log_event */
2478
2718
 
 
2719
#ifndef MYSQL_CLIENT
2479
2720
  Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
 
2721
#ifdef HAVE_REPLICATION
2480
2722
  void pack_info(Protocol* protocol);
 
2723
#endif /* HAVE_REPLICATION */
 
2724
#else
 
2725
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2726
#endif
2481
2727
 
2482
 
  Execute_load_log_event(const char* buf, uint32_t event_len,
 
2728
  Execute_load_log_event(const char* buf, uint event_len,
2483
2729
                         const Format_description_log_event
2484
2730
                         *description_event);
2485
2731
  ~Execute_load_log_event() {}
2486
2732
  Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
2487
2733
  int get_data_size() { return  EXEC_LOAD_HEADER_LEN ;}
2488
2734
  bool is_valid() const { return file_id != 0; }
 
2735
#ifndef MYSQL_CLIENT
2489
2736
  bool write(IO_CACHE* file);
2490
2737
  const char* get_db() { return db; }
 
2738
#endif
2491
2739
 
2492
2740
private:
 
2741
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2493
2742
  virtual int do_apply_event(Relay_log_info const *rli);
 
2743
#endif
2494
2744
};
2495
2745
 
2496
2746
 
2506
2756
class Begin_load_query_log_event: public Append_block_log_event
2507
2757
{
2508
2758
public:
 
2759
#ifndef MYSQL_CLIENT
2509
2760
  Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
2510
 
                             unsigned char* block_arg, uint32_t block_len_arg,
 
2761
                             uchar* block_arg, uint block_len_arg,
2511
2762
                             bool using_trans);
 
2763
#ifdef HAVE_REPLICATION
2512
2764
  Begin_load_query_log_event(THD* thd);
2513
2765
  int get_create_or_append() const;
2514
 
  Begin_load_query_log_event(const char* buf, uint32_t event_len,
 
2766
#endif /* HAVE_REPLICATION */
 
2767
#endif
 
2768
  Begin_load_query_log_event(const char* buf, uint event_len,
2515
2769
                             const Format_description_log_event
2516
2770
                             *description_event);
2517
2771
  ~Begin_load_query_log_event() {}
2518
2772
  Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
2519
2773
private:
 
2774
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2520
2775
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2776
#endif
2521
2777
};
2522
2778
 
2523
2779
 
2539
2795
class Execute_load_query_log_event: public Query_log_event
2540
2796
{
2541
2797
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
 
2798
  uint file_id;       // file_id of temporary file
 
2799
  uint fn_pos_start;  // pointer to the part of the query that should
2544
2800
                      // be substituted
2545
 
  uint32_t fn_pos_end;    // pointer to the end of this part of query
 
2801
  uint fn_pos_end;    // pointer to the end of this part of query
2546
2802
  /*
2547
2803
    We have to store type of duplicate handling explicitly, because
2548
2804
    for LOAD DATA it also depends on LOCAL option. And this part
2551
2807
  */
2552
2808
  enum_load_dup_handling dup_handling;
2553
2809
 
 
2810
#ifndef MYSQL_CLIENT
2554
2811
  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,
 
2812
                               ulong query_length, uint fn_pos_start_arg,
 
2813
                               uint fn_pos_end_arg,
2557
2814
                               enum_load_dup_handling dup_handling_arg,
2558
2815
                               bool using_trans, bool suppress_use,
2559
2816
                               THD::killed_state
2560
2817
                               killed_err_arg= THD::KILLED_NO_VALUE);
 
2818
#ifdef HAVE_REPLICATION
2561
2819
  void pack_info(Protocol* protocol);
2562
 
  Execute_load_query_log_event(const char* buf, uint32_t event_len,
 
2820
#endif /* HAVE_REPLICATION */
 
2821
#else
 
2822
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2823
  /* Prints the query as LOAD DATA LOCAL and with rewritten filename */
 
2824
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
 
2825
             const char *local_fname);
 
2826
#endif
 
2827
  Execute_load_query_log_event(const char* buf, uint event_len,
2563
2828
                               const Format_description_log_event
2564
2829
                               *description_event);
2565
2830
  ~Execute_load_query_log_event() {}
2568
2833
  bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
2569
2834
 
2570
2835
  ulong get_post_header_size_for_derived();
 
2836
#ifndef MYSQL_CLIENT
2571
2837
  bool write_post_header_for_derived(IO_CACHE* file);
 
2838
#endif
2572
2839
 
2573
2840
private:
 
2841
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2574
2842
  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);
 
2843
#endif
 
2844
};
 
2845
 
 
2846
 
 
2847
#ifdef MYSQL_CLIENT
 
2848
/**
 
2849
  @class Unknown_log_event
 
2850
 
 
2851
  @section Unknown_log_event_binary_format Binary Format
 
2852
*/
 
2853
class Unknown_log_event: public Log_event
 
2854
{
 
2855
public:
 
2856
  /*
 
2857
    Even if this is an unknown event, we still pass description_event to
 
2858
    Log_event's ctor, this way we can extract maximum information from the
 
2859
    event's header (the unique ID for example).
 
2860
  */
 
2861
  Unknown_log_event(const char* buf,
 
2862
                    const Format_description_log_event *description_event):
 
2863
    Log_event(buf, description_event)
 
2864
  {}
 
2865
  ~Unknown_log_event() {}
 
2866
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2867
  Log_event_type get_type_code() { return UNKNOWN_EVENT;}
 
2868
  bool is_valid() const { return 1; }
 
2869
};
 
2870
#endif
 
2871
char *str_to_hex(char *to, const char *from, uint len);
2579
2872
 
2580
2873
/**
2581
2874
  @class Table_map_log_event
2704
2997
  </tr>
2705
2998
 
2706
2999
  <tr>
2707
 
    <td>DRIZZLE_TYPE_TINY</td><td>1</td>
2708
 
    <td>0</td>
2709
 
    <td>No column metadata.</td>
2710
 
  </tr>
2711
 
 
2712
 
  <tr>
2713
 
    <td>DRIZZLE_TYPE_SHORT</td><td>2</td>
2714
 
    <td>0</td>
2715
 
    <td>No column metadata.</td>
2716
 
  </tr>
2717
 
 
2718
 
  <tr>
2719
 
    <td>DRIZZLE_TYPE_LONG</td><td>3</td>
2720
 
    <td>0</td>
2721
 
    <td>No column metadata.</td>
2722
 
  </tr>
2723
 
 
2724
 
  <tr>
2725
 
    <td>DRIZZLE_TYPE_DOUBLE</td><td>5</td>
 
3000
    <td>MYSQL_TYPE_TINY</td><td>1</td>
 
3001
    <td>0</td>
 
3002
    <td>No column metadata.</td>
 
3003
  </tr>
 
3004
 
 
3005
  <tr>
 
3006
    <td>MYSQL_TYPE_SHORT</td><td>2</td>
 
3007
    <td>0</td>
 
3008
    <td>No column metadata.</td>
 
3009
  </tr>
 
3010
 
 
3011
  <tr>
 
3012
    <td>MYSQL_TYPE_LONG</td><td>3</td>
 
3013
    <td>0</td>
 
3014
    <td>No column metadata.</td>
 
3015
  </tr>
 
3016
 
 
3017
  <tr>
 
3018
    <td>MYSQL_TYPE_FLOAT</td><td>4</td>
 
3019
    <td>1 byte</td>
 
3020
    <td>1 byte unsigned integer, representing the "pack_length", which
 
3021
    is equal to sizeof(float) on the server from which the event
 
3022
    originates.</td>
 
3023
  </tr>
 
3024
 
 
3025
  <tr>
 
3026
    <td>MYSQL_TYPE_DOUBLE</td><td>5</td>
2726
3027
    <td>1 byte</td>
2727
3028
    <td>1 byte unsigned integer, representing the "pack_length", which
2728
3029
    is equal to sizeof(double) on the server from which the event
2730
3031
  </tr>
2731
3032
 
2732
3033
  <tr>
2733
 
    <td>DRIZZLE_TYPE_NULL</td><td>6</td>
2734
 
    <td>0</td>
2735
 
    <td>No column metadata.</td>
2736
 
  </tr>
2737
 
 
2738
 
  <tr>
2739
 
    <td>DRIZZLE_TYPE_TIMESTAMP</td><td>7</td>
2740
 
    <td>0</td>
2741
 
    <td>No column metadata.</td>
2742
 
  </tr>
2743
 
 
2744
 
  <tr>
2745
 
    <td>DRIZZLE_TYPE_LONGLONG</td><td>8</td>
2746
 
    <td>0</td>
2747
 
    <td>No column metadata.</td>
2748
 
  </tr>
2749
 
 
2750
 
  <tr>
2751
 
    <td>DRIZZLE_TYPE_DATE</td><td>10</td>
2752
 
    <td>0</td>
2753
 
    <td>No column metadata.</td>
2754
 
  </tr>
2755
 
 
2756
 
  <tr>
2757
 
    <td>DRIZZLE_TYPE_TIME</td><td>11</td>
2758
 
    <td>0</td>
2759
 
    <td>No column metadata.</td>
2760
 
  </tr>
2761
 
 
2762
 
  <tr>
2763
 
    <td>DRIZZLE_TYPE_DATETIME</td><td>12</td>
2764
 
    <td>0</td>
2765
 
    <td>No column metadata.</td>
2766
 
  </tr>
2767
 
 
2768
 
  <tr>
2769
 
    <td>DRIZZLE_TYPE_YEAR</td><td>13</td>
2770
 
    <td>0</td>
2771
 
    <td>No column metadata.</td>
2772
 
  </tr>
2773
 
 
2774
 
  <tr>
2775
 
    <td><i>DRIZZLE_TYPE_NEWDATE</i></td><td><i>14</i></td>
 
3034
    <td>MYSQL_TYPE_NULL</td><td>6</td>
 
3035
    <td>0</td>
 
3036
    <td>No column metadata.</td>
 
3037
  </tr>
 
3038
 
 
3039
  <tr>
 
3040
    <td>MYSQL_TYPE_TIMESTAMP</td><td>7</td>
 
3041
    <td>0</td>
 
3042
    <td>No column metadata.</td>
 
3043
  </tr>
 
3044
 
 
3045
  <tr>
 
3046
    <td>MYSQL_TYPE_LONGLONG</td><td>8</td>
 
3047
    <td>0</td>
 
3048
    <td>No column metadata.</td>
 
3049
  </tr>
 
3050
 
 
3051
  <tr>
 
3052
    <td>MYSQL_TYPE_DATE</td><td>10</td>
 
3053
    <td>0</td>
 
3054
    <td>No column metadata.</td>
 
3055
  </tr>
 
3056
 
 
3057
  <tr>
 
3058
    <td>MYSQL_TYPE_TIME</td><td>11</td>
 
3059
    <td>0</td>
 
3060
    <td>No column metadata.</td>
 
3061
  </tr>
 
3062
 
 
3063
  <tr>
 
3064
    <td>MYSQL_TYPE_DATETIME</td><td>12</td>
 
3065
    <td>0</td>
 
3066
    <td>No column metadata.</td>
 
3067
  </tr>
 
3068
 
 
3069
  <tr>
 
3070
    <td>MYSQL_TYPE_YEAR</td><td>13</td>
 
3071
    <td>0</td>
 
3072
    <td>No column metadata.</td>
 
3073
  </tr>
 
3074
 
 
3075
  <tr>
 
3076
    <td><i>MYSQL_TYPE_NEWDATE</i></td><td><i>14</i></td>
2776
3077
    <td>&ndash;</td>
2777
3078
    <td><i>This enumeration value is only used internally and cannot
2778
3079
    exist in a binlog.</i></td>
2779
3080
  </tr>
2780
3081
 
2781
3082
  <tr>
2782
 
    <td>DRIZZLE_TYPE_VARCHAR</td><td>15</td>
 
3083
    <td>MYSQL_TYPE_VARCHAR</td><td>15</td>
2783
3084
    <td>2 bytes</td>
2784
3085
    <td>2 byte unsigned integer representing the maximum length of
2785
3086
    the string.</td>
2786
3087
  </tr>
2787
3088
 
2788
3089
  <tr>
2789
 
    <td>DRIZZLE_TYPE_NEWDECIMAL</td><td>246</td>
 
3090
    <td>MYSQL_TYPE_NEWDECIMAL</td><td>246</td>
2790
3091
    <td>2 bytes</td>
2791
3092
    <td>A 1 byte unsigned int representing the precision, followed
2792
3093
    by a 1 byte unsigned int representing the number of decimals.</td>
2793
3094
  </tr>
2794
3095
 
2795
3096
  <tr>
2796
 
    <td><i>DRIZZLE_TYPE_ENUM</i></td><td><i>247</i></td>
2797
 
    <td>&ndash;</td>
2798
 
    <td><i>This enumeration value is only used internally and cannot
2799
 
    exist in a binlog.</i></td>
2800
 
  </tr>
2801
 
 
2802
 
  <tr>
2803
 
    <td><i>DRIZZLE_TYPE_SET</i></td><td><i>248</i></td>
2804
 
    <td>&ndash;</td>
2805
 
    <td><i>This enumeration value is only used internally and cannot
2806
 
    exist in a binlog.</i></td>
2807
 
  </tr>
2808
 
 
2809
 
  <tr>
2810
 
    <td>DRIZZLE_TYPE_BLOB</td><td>252</td>
 
3097
    <td><i>MYSQL_TYPE_ENUM</i></td><td><i>247</i></td>
 
3098
    <td>&ndash;</td>
 
3099
    <td><i>This enumeration value is only used internally and cannot
 
3100
    exist in a binlog.</i></td>
 
3101
  </tr>
 
3102
 
 
3103
  <tr>
 
3104
    <td><i>MYSQL_TYPE_SET</i></td><td><i>248</i></td>
 
3105
    <td>&ndash;</td>
 
3106
    <td><i>This enumeration value is only used internally and cannot
 
3107
    exist in a binlog.</i></td>
 
3108
  </tr>
 
3109
 
 
3110
  <tr>
 
3111
    <td>MYSQL_TYPE_BLOB</td><td>252</td>
2811
3112
    <td>1 byte</td>
2812
3113
    <td>The pack length, i.e., the number of bytes needed to represent
2813
3114
    the length of the blob: 1, 2, 3, or 4.</td>
2814
3115
  </tr>
2815
3116
 
2816
3117
  <tr>
2817
 
    <td>DRIZZLE_TYPE_STRING</td><td>254</td>
 
3118
    <td>MYSQL_TYPE_STRING</td><td>254</td>
2818
3119
    <td>2 bytes</td>
2819
 
    <td>The first byte is always DRIZZLE_TYPE_VAR_STRING (i.e., 253).
 
3120
    <td>The first byte is always MYSQL_TYPE_VAR_STRING (i.e., 253).
2820
3121
    The second byte is the field size, i.e., the number of bytes in
2821
3122
    the representation of size of the string: 3 or 4.</td>
2822
3123
  </tr>
2856
3157
    ENUM_FLAG_COUNT
2857
3158
  };
2858
3159
 
2859
 
  typedef uint16_t flag_set;
 
3160
  typedef uint16 flag_set;
2860
3161
 
2861
3162
  /* Special constants representing sets of flags */
2862
3163
  enum 
2868
3169
  void clear_flags(flag_set flag) { m_flags &= ~flag; }
2869
3170
  flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2870
3171
 
2871
 
  Table_map_log_event(THD *thd, Table *tbl, ulong tid, 
2872
 
                      bool is_transactional, uint16_t flags);
2873
 
  Table_map_log_event(const char *buf, uint32_t event_len, 
 
3172
#ifndef MYSQL_CLIENT
 
3173
  Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, 
 
3174
                      bool is_transactional, uint16 flags);
 
3175
#endif
 
3176
#ifdef HAVE_REPLICATION
 
3177
  Table_map_log_event(const char *buf, uint event_len, 
2874
3178
                      const Format_description_log_event *description_event);
 
3179
#endif
2875
3180
 
2876
3181
  ~Table_map_log_event();
2877
3182
 
2879
3184
  virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
2880
3185
 
2881
3186
  virtual int get_data_size() { return m_data_size; } 
 
3187
#ifndef MYSQL_CLIENT
2882
3188
  virtual int save_field_metadata();
2883
3189
  virtual bool write_data_header(IO_CACHE *file);
2884
3190
  virtual bool write_data_body(IO_CACHE *file);
2885
3191
  virtual const char *get_db() { return m_dbnam; }
 
3192
#endif
 
3193
 
 
3194
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2886
3195
  virtual void pack_info(Protocol *protocol);
 
3196
#endif
 
3197
 
 
3198
#ifdef MYSQL_CLIENT
 
3199
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3200
#endif
 
3201
 
2887
3202
 
2888
3203
private:
 
3204
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2889
3205
  virtual int do_apply_event(Relay_log_info const *rli);
2890
3206
  virtual int do_update_pos(Relay_log_info *rli);
2891
3207
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
3208
#endif
2892
3209
 
2893
 
  Table         *m_table;
 
3210
#ifndef MYSQL_CLIENT
 
3211
  TABLE         *m_table;
 
3212
#endif
2894
3213
  char const    *m_dbnam;
2895
3214
  size_t         m_dblen;
2896
3215
  char const    *m_tblnam;
2897
3216
  size_t         m_tbllen;
2898
3217
  ulong          m_colcnt;
2899
 
  unsigned char         *m_coltype;
 
3218
  uchar         *m_coltype;
2900
3219
 
2901
 
  unsigned char         *m_memory;
 
3220
  uchar         *m_memory;
2902
3221
  ulong          m_table_id;
2903
3222
  flag_set       m_flags;
2904
3223
 
2905
3224
  size_t         m_data_size;
2906
3225
 
2907
 
  unsigned char          *m_field_metadata;        // buffer for field metadata
 
3226
  uchar          *m_field_metadata;        // buffer for field metadata
2908
3227
  /*
2909
3228
    The size of field metadata buffer set by calling save_field_metadata()
2910
3229
  */
2911
3230
  ulong          m_field_metadata_size;   
2912
 
  unsigned char         *m_null_bits;
2913
 
  unsigned char         *m_meta_memory;
 
3231
  uchar         *m_null_bits;
 
3232
  uchar         *m_meta_memory;
2914
3233
};
2915
3234
 
2916
3235
 
2970
3289
    COMPLETE_ROWS_F = (1U << 3)
2971
3290
  };
2972
3291
 
2973
 
  typedef uint16_t flag_set;
 
3292
  typedef uint16 flag_set;
2974
3293
 
2975
3294
  /* Special constants representing sets of flags */
2976
3295
  enum 
2984
3303
  void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2985
3304
  flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2986
3305
 
 
3306
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2987
3307
  virtual void pack_info(Protocol *protocol);
2988
 
 
2989
 
  int add_row_data(unsigned char *data, size_t length)
 
3308
#endif
 
3309
 
 
3310
#ifdef MYSQL_CLIENT
 
3311
  /* not for direct call, each derived has its own ::print() */
 
3312
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info)= 0;
 
3313
#endif
 
3314
 
 
3315
#ifndef MYSQL_CLIENT
 
3316
  int add_row_data(uchar *data, size_t length)
2990
3317
  {
2991
3318
    return do_add_row_data(data,length); 
2992
3319
  }
 
3320
#endif
2993
3321
 
2994
3322
  /* Member functions to implement superclass interface */
2995
3323
  virtual int get_data_size();
2998
3326
  size_t get_width() const          { return m_width; }
2999
3327
  ulong get_table_id() const        { return m_table_id; }
3000
3328
 
 
3329
#ifndef MYSQL_CLIENT
3001
3330
  virtual bool write_data_header(IO_CACHE *file);
3002
3331
  virtual bool write_data_body(IO_CACHE *file);
3003
3332
  virtual const char *get_db() { return m_table->s->db.str; }
 
3333
#endif
3004
3334
  /*
3005
3335
    Check that malloc() succeeded in allocating memory for the rows
3006
3336
    buffer and the COLS vector. Checking that an Update_rows_log_event
3012
3342
    return m_rows_buf && m_cols.bitmap;
3013
3343
  }
3014
3344
 
3015
 
  uint32_t     m_row_count;         /* The number of rows added to the event */
 
3345
  uint     m_row_count;         /* The number of rows added to the event */
3016
3346
 
3017
3347
protected:
3018
3348
  /* 
3019
3349
     The constructors are protected since you're supposed to inherit
3020
3350
     this class, not create instances of this class.
3021
3351
  */
3022
 
  Rows_log_event(THD*, Table*, ulong table_id, 
 
3352
#ifndef MYSQL_CLIENT
 
3353
  Rows_log_event(THD*, TABLE*, ulong table_id, 
3023
3354
                 MY_BITMAP const *cols, bool is_transactional);
3024
 
  Rows_log_event(const char *row_data, uint32_t event_len, 
 
3355
#endif
 
3356
  Rows_log_event(const char *row_data, uint event_len, 
3025
3357
                 Log_event_type event_type,
3026
3358
                 const Format_description_log_event *description_event);
3027
3359
 
3028
 
  virtual int do_add_row_data(unsigned char *data, size_t length);
3029
 
 
3030
 
  Table *m_table;               /* The table the rows belong to */
 
3360
#ifdef MYSQL_CLIENT
 
3361
  void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
 
3362
#endif
 
3363
 
 
3364
#ifndef MYSQL_CLIENT
 
3365
  virtual int do_add_row_data(uchar *data, size_t length);
 
3366
#endif
 
3367
 
 
3368
#ifndef MYSQL_CLIENT
 
3369
  TABLE *m_table;               /* The table the rows belong to */
 
3370
#endif
3031
3371
  ulong       m_table_id;       /* Table ID */
3032
3372
  MY_BITMAP   m_cols;           /* Bitmap denoting columns available */
3033
3373
  ulong       m_width;          /* The width of the columns bitmap */
3043
3383
  ulong       m_master_reclength; /* Length of record on master side */
3044
3384
 
3045
3385
  /* Bit buffers in the same memory as the class */
3046
 
  uint32_t    m_bitbuf[128/(sizeof(uint32_t)*8)];
3047
 
  uint32_t    m_bitbuf_ai[128/(sizeof(uint32_t)*8)];
 
3386
  uint32    m_bitbuf[128/(sizeof(uint32)*8)];
 
3387
  uint32    m_bitbuf_ai[128/(sizeof(uint32)*8)];
3048
3388
 
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 */
 
3389
  uchar    *m_rows_buf;         /* The rows in packed format */
 
3390
  uchar    *m_rows_cur;         /* One-after the end of the data */
 
3391
  uchar    *m_rows_end;         /* One-after the end of the allocated space */
3052
3392
 
3053
3393
  flag_set m_flags;             /* Flags for row-level events */
3054
3394
 
3055
3395
  /* helper functions */
3056
3396
 
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 */
 
3397
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 
3398
  const uchar *m_curr_row;     /* Start of the row being processed */
 
3399
  const uchar *m_curr_row_end; /* One-after the end of the current row */
 
3400
  uchar    *m_key;      /* Buffer to keep key value during searches */
3060
3401
 
3061
3402
  int find_row(const Relay_log_info *const);
3062
3403
  int write_row(const Relay_log_info *const, const bool);
3074
3415
    ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
3075
3416
    return result;
3076
3417
  }
 
3418
#endif
3077
3419
 
3078
3420
private:
3079
3421
 
 
3422
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3080
3423
  virtual int do_apply_event(Relay_log_info const *rli);
3081
3424
  virtual int do_update_pos(Relay_log_info *rli);
3082
3425
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3131
3474
      
3132
3475
  */
3133
3476
  virtual int do_exec_row(const Relay_log_info *const rli) = 0;
 
3477
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
3134
3478
 
3135
3479
  friend class Old_rows_log_event;
3136
3480
};
3153
3497
    TYPE_CODE = WRITE_ROWS_EVENT
3154
3498
  };
3155
3499
 
3156
 
  Write_rows_log_event(THD*, Table*, ulong table_id, 
 
3500
#if !defined(MYSQL_CLIENT)
 
3501
  Write_rows_log_event(THD*, TABLE*, ulong table_id, 
3157
3502
                       bool is_transactional);
3158
 
  Write_rows_log_event(const char *buf, uint32_t event_len, 
 
3503
#endif
 
3504
#ifdef HAVE_REPLICATION
 
3505
  Write_rows_log_event(const char *buf, uint event_len, 
3159
3506
                       const Format_description_log_event *description_event);
3160
 
  static bool binlog_row_logging_function(THD *thd, Table *table,
 
3507
#endif
 
3508
#if !defined(MYSQL_CLIENT) 
 
3509
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3161
3510
                                          bool is_transactional,
3162
 
                                          const unsigned char *before_record
 
3511
                                          const uchar *before_record
3163
3512
                                          __attribute__((unused)),
3164
 
                                          const unsigned char *after_record)
 
3513
                                          const uchar *after_record)
3165
3514
  {
3166
3515
    return thd->binlog_write_row(table, is_transactional, after_record);
3167
3516
  }
 
3517
#endif
3168
3518
 
3169
3519
private:
3170
3520
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3171
3521
 
 
3522
#ifdef MYSQL_CLIENT
 
3523
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3524
#endif
 
3525
 
 
3526
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3172
3527
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3173
3528
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3174
3529
  virtual int do_exec_row(const Relay_log_info *const);
 
3530
#endif
3175
3531
};
3176
3532
 
3177
3533
 
3196
3552
    TYPE_CODE = UPDATE_ROWS_EVENT
3197
3553
  };
3198
3554
 
3199
 
  Update_rows_log_event(THD*, Table*, ulong table_id,
 
3555
#ifndef MYSQL_CLIENT
 
3556
  Update_rows_log_event(THD*, TABLE*, ulong table_id,
3200
3557
                        bool is_transactional);
3201
3558
 
3202
3559
  void init(MY_BITMAP const *cols);
 
3560
#endif
3203
3561
 
3204
3562
  virtual ~Update_rows_log_event();
3205
3563
 
3206
 
  Update_rows_log_event(const char *buf, uint32_t event_len, 
 
3564
#ifdef HAVE_REPLICATION
 
3565
  Update_rows_log_event(const char *buf, uint event_len, 
3207
3566
                        const Format_description_log_event *description_event);
 
3567
#endif
3208
3568
 
3209
 
  static bool binlog_row_logging_function(THD *thd, Table *table,
 
3569
#if !defined(MYSQL_CLIENT) 
 
3570
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3210
3571
                                          bool is_transactional,
3211
 
                                          const unsigned char *before_record,
3212
 
                                          const unsigned char *after_record)
 
3572
                                          const uchar *before_record,
 
3573
                                          const uchar *after_record)
3213
3574
  {
3214
3575
    return thd->binlog_update_row(table, is_transactional,
3215
3576
                                  before_record, after_record);
3216
3577
  }
 
3578
#endif
3217
3579
 
3218
3580
  virtual bool is_valid() const
3219
3581
  {
3223
3585
protected:
3224
3586
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3225
3587
 
 
3588
#ifdef MYSQL_CLIENT
 
3589
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3590
#endif
 
3591
 
 
3592
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3226
3593
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3227
3594
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3228
3595
  virtual int do_exec_row(const Relay_log_info *const);
 
3596
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
3229
3597
};
3230
3598
 
3231
3599
/**
3257
3625
    TYPE_CODE = DELETE_ROWS_EVENT
3258
3626
  };
3259
3627
 
3260
 
  Delete_rows_log_event(THD*, Table*, ulong, 
 
3628
#ifndef MYSQL_CLIENT
 
3629
  Delete_rows_log_event(THD*, TABLE*, ulong, 
3261
3630
                        bool is_transactional);
3262
 
  Delete_rows_log_event(const char *buf, uint32_t event_len, 
 
3631
#endif
 
3632
#ifdef HAVE_REPLICATION
 
3633
  Delete_rows_log_event(const char *buf, uint event_len, 
3263
3634
                        const Format_description_log_event *description_event);
3264
 
  static bool binlog_row_logging_function(THD *thd, Table *table,
 
3635
#endif
 
3636
#if !defined(MYSQL_CLIENT) 
 
3637
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3265
3638
                                          bool is_transactional,
3266
 
                                          const unsigned char *before_record,
3267
 
                                          const unsigned char *after_record
 
3639
                                          const uchar *before_record,
 
3640
                                          const uchar *after_record
3268
3641
                                          __attribute__((unused)))
3269
3642
  {
3270
3643
    return thd->binlog_delete_row(table, is_transactional, before_record);
3271
3644
  }
 
3645
#endif
3272
3646
  
3273
3647
protected:
3274
3648
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3275
3649
 
 
3650
#ifdef MYSQL_CLIENT
 
3651
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3652
#endif
 
3653
 
 
3654
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3276
3655
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3277
3656
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3278
3657
  virtual int do_exec_row(const Relay_log_info *const);
 
3658
#endif
3279
3659
};
3280
3660
 
3281
3661
 
3317
3697
*/
3318
3698
class Incident_log_event : public Log_event {
3319
3699
public:
 
3700
#ifndef MYSQL_CLIENT
3320
3701
  Incident_log_event(THD *thd_arg, Incident incident)
3321
3702
    : Log_event(thd_arg, 0, false), m_incident(incident)
3322
3703
  {
3326
3707
  }
3327
3708
 
3328
3709
  Incident_log_event(THD *thd_arg, Incident incident, LEX_STRING const msg)
3329
 
    : Log_event(thd_arg, 0, false), m_incident(incident)
 
3710
    : Log_event(thd_arg, 0, FALSE), m_incident(incident)
3330
3711
  {
3331
3712
    m_message= msg;
3332
3713
    return;
3333
3714
  }
 
3715
#endif
3334
3716
 
 
3717
#ifndef MYSQL_CLIENT
3335
3718
  void pack_info(Protocol*);
 
3719
#endif
3336
3720
 
3337
 
  Incident_log_event(const char *buf, uint32_t event_len,
 
3721
  Incident_log_event(const char *buf, uint event_len,
3338
3722
                     const Format_description_log_event *descr_event);
3339
3723
 
3340
3724
  virtual ~Incident_log_event();
3341
3725
 
 
3726
#ifdef MYSQL_CLIENT
 
3727
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3728
#endif
 
3729
 
 
3730
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3342
3731
  virtual int do_apply_event(Relay_log_info const *rli);
 
3732
#endif
3343
3733
 
3344
3734
  virtual bool write_data_header(IO_CACHE *file);
3345
3735
  virtual bool write_data_body(IO_CACHE *file);
3358
3748
  LEX_STRING m_message;
3359
3749
};
3360
3750
 
3361
 
int append_query_string(const CHARSET_INFO * const csinfo,
3362
 
                        String const *from, String *to);
3363
 
 
3364
3751
static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
3365
3752
                                                       FILE *file)
3366
3753
{
3369
3756
    reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3370
3757
}
3371
3758
 
 
3759
#ifndef MYSQL_CLIENT
3372
3760
/*****************************************************************************
3373
3761
 
3374
3762
  Heartbeat Log Event class
3387
3775
class Heartbeat_log_event: public Log_event
3388
3776
{
3389
3777
public:
3390
 
  Heartbeat_log_event(const char* buf, uint32_t event_len,
 
3778
  Heartbeat_log_event(const char* buf, uint event_len,
3391
3779
                      const Format_description_log_event* description_event);
3392
3780
  Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; }
3393
3781
  bool is_valid() const
3396
3784
              log_pos >= BIN_LOG_HEADER_SIZE);
3397
3785
    }
3398
3786
  const char * get_log_ident() { return log_ident; }
3399
 
  uint32_t get_ident_len() { return ident_len; }
 
3787
  uint get_ident_len() { return ident_len; }
3400
3788
  
3401
3789
private:
3402
3790
  const char* log_ident;
3403
 
  uint32_t ident_len;
 
3791
  uint ident_len;
3404
3792
};
 
3793
#endif
3405
3794
 
3406
3795
/**
3407
3796
  @} (end of group Replication)