~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log_event.h

Renamed strings to mystrings, for include/lib naming consistency.

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
29
25
*/
30
26
 
31
27
 
32
 
#ifndef DRIZZLED_LOG_EVENT_H
33
 
#define DRIZZLED_LOG_EVENT_H
34
 
 
35
 
 
36
 
#include <string>
37
 
#include <mysys/my_bitmap.h>
 
28
#ifndef _log_event_h
 
29
#define _log_event_h
 
30
 
 
31
#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT)
 
32
#pragma interface                       /* gcc class implementation */
 
33
#endif
 
34
 
 
35
#include <my_bitmap.h>
38
36
#include "rpl_constants.h"
 
37
#ifndef MYSQL_CLIENT
39
38
#include "rpl_record.h"
40
39
#include "rpl_reporting.h"
41
 
 
42
 
#include <drizzled/sql_string.h>       /* append_query_string() needs String declaration */
 
40
#else
 
41
#include "my_decimal.h"
 
42
#endif
43
43
 
44
44
/**
45
45
   Either assert or return an error.
159
159
  char opt_flags;
160
160
  char empty_flags;
161
161
 
162
 
  /* store in new format even if old is possible */
 
162
  // store in new format even if old is possible
163
163
  void force_new_format() { cached_new_format = 1;}
164
164
  int data_size()
165
165
  {
209
209
   event's ID, LOG_EVENT_HEADER_LEN will be something like 26, but
210
210
   LOG_EVENT_MINIMAL_HEADER_LEN will remain 19.
211
211
*/
212
 
#define LOG_EVENT_MINIMAL_HEADER_LEN (uint8_t)19
 
212
#define LOG_EVENT_MINIMAL_HEADER_LEN 19
213
213
 
214
214
/* event-specific post-header sizes */
215
215
// where 3.23, 4.x and 5.0 agree
398
398
/**
399
399
  @def LOG_EVENT_THREAD_SPECIFIC_F
400
400
 
401
 
  If the query depends on the thread (for example: TEMPORARY Table).
 
401
  If the query depends on the thread (for example: TEMPORARY TABLE).
402
402
  Currently this is used by mysqlbinlog to know it must print
403
403
  SET @@PSEUDO_THREAD_ID=xx; before the query (it would not hurt to print it
404
404
  for every query but this would be slow).
429
429
/**
430
430
  @def OPTIONS_WRITTEN_TO_BIN_LOG
431
431
 
432
 
  OPTIONS_WRITTEN_TO_BIN_LOG are the bits of session->options which must
 
432
  OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must
433
433
  be written to the binlog. OPTIONS_WRITTEN_TO_BIN_LOG could be
434
434
  written into the Format_description_log_event, so that if later we
435
435
  don't want to replicate a variable we did replicate, or the
436
436
  contrary, it's doable. But it should not be too hard to decide once
437
437
  for all of what we replicate and what we don't, among the fixed 32
438
 
  bits of session->options.
 
438
  bits of thd->options.
439
439
 
440
440
  I (Guilhem) have read through every option's usage, and it looks
441
441
  like OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only
453
453
 
454
454
/* Shouldn't be defined before */
455
455
#define EXPECTED_OPTIONS \
456
 
  ((1U << 14) | (1U << 26) | (1U << 27) | (1U << 19))
 
456
  ((1ULL << 14) | (1ULL << 26) | (1ULL << 27) | (1ULL << 19))
457
457
 
458
458
#if OPTIONS_WRITTEN_TO_BIN_LOG != EXPECTED_OPTIONS
459
459
#error OPTIONS_WRITTEN_TO_BIN_LOG must NOT change their values!
545
545
};
546
546
 
547
547
 
 
548
#ifndef MYSQL_CLIENT
548
549
class String;
549
 
class DRIZZLE_BIN_LOG;
550
 
class Session;
 
550
class MYSQL_BIN_LOG;
 
551
class THD;
 
552
#endif
551
553
 
552
554
class Format_description_log_event;
553
555
class Relay_log_info;
554
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_t 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_t 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
 
555
635
/**
556
636
  the struct aggregates two paramenters that identify an event
557
637
  uniquely in scope of communication of a particular master and slave couple.
744
824
    sees the offset of the BEGIN, which is logical as rollback may
745
825
    occur), except the COMMIT query which has its real offset.
746
826
  */
747
 
  off_t log_pos;
 
827
  my_off_t log_pos;
748
828
  /*
749
829
     A temp buffer for read_log_event; it is later analysed according to the
750
830
     event's type, and its content is distributed in the event-specific fields.
785
865
  */
786
866
  ulong slave_exec_mode;
787
867
 
788
 
  Session* session;
 
868
#ifndef MYSQL_CLIENT
 
869
  THD* thd;
789
870
 
790
871
  Log_event();
791
 
  Log_event(Session* session_arg, uint16_t flags_arg, bool cache_stmt);
 
872
  Log_event(THD* thd_arg, uint16_t flags_arg, bool cache_stmt);
792
873
  /*
793
874
    read_log_event() functions read an event from a binlog or relay
794
875
    log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the
812
893
    EVENTS.
813
894
  */
814
895
  static void init_show_field_list(List<Item>* field_list);
 
896
#ifdef HAVE_REPLICATION
815
897
  int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
816
898
 
817
899
  /*
821
903
 
822
904
  virtual void pack_info(Protocol *protocol);
823
905
 
 
906
#endif /* HAVE_REPLICATION */
824
907
  virtual const char* get_db()
825
908
  {
826
 
    return session ? session->db : 0;
 
909
    return thd ? thd->db : 0;
827
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
828
925
 
829
926
  static void *operator new(size_t size)
830
927
  {
832
929
  }
833
930
 
834
931
  static void operator delete(void *ptr,
835
 
                              size_t)
 
932
                              size_t size __attribute__((unused)))
836
933
  {
837
 
    free((unsigned char*) ptr);
 
934
    my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
838
935
  }
839
936
 
840
937
  /* Placement version of the above operators */
841
938
  static void *operator new(size_t, void* ptr) { return ptr; }
842
939
  static void operator delete(void*, void*) { }
843
940
 
 
941
#ifndef MYSQL_CLIENT
844
942
  bool write_header(IO_CACHE* file, ulong data_length);
845
943
  virtual bool write(IO_CACHE* file)
846
944
  {
848
946
            write_data_header(file) ||
849
947
            write_data_body(file));
850
948
  }
851
 
  virtual bool write_data_header(IO_CACHE*)
 
949
  virtual bool write_data_header(IO_CACHE* file __attribute__((unused)))
852
950
  { return 0; }
853
 
  virtual bool write_data_body(IO_CACHE*)
 
951
  virtual bool write_data_body(IO_CACHE* file __attribute__((unused)))
854
952
  { return 0; }
855
953
  inline time_t get_time()
856
954
  {
857
 
    Session *tmp_session;
 
955
    THD *tmp_thd;
858
956
    if (when)
859
957
      return when;
860
 
    if (session)
861
 
      return session->start_time;
862
 
    if ((tmp_session= current_session))
863
 
      return tmp_session->start_time;
 
958
    if (thd)
 
959
      return thd->start_time;
 
960
    if ((tmp_thd= current_thd))
 
961
      return tmp_thd->start_time;
864
962
    return my_time(0);
865
963
  }
 
964
#endif
866
965
  virtual Log_event_type get_type_code() = 0;
867
966
  virtual bool is_valid() const = 0;
868
967
  virtual bool is_artificial_event() { return 0; }
875
974
  {
876
975
    if (temp_buf)
877
976
    {
878
 
      free(temp_buf);
 
977
      my_free(temp_buf, MYF(0));
879
978
      temp_buf = 0;
880
979
    }
881
980
  }
884
983
    is calculated during write()
885
984
  */
886
985
  virtual int get_data_size() { return 0;}
887
 
  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,
888
987
                                   const char **error,
889
988
                                   const Format_description_log_event
890
989
                                   *description_event);
899
998
 
900
999
  /* Return start of query time or current time */
901
1000
 
 
1001
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
902
1002
public:
903
1003
 
904
1004
  /**
975
1075
    @retval 0     Event applied successfully
976
1076
    @retval errno Error code if event application failed
977
1077
  */
978
 
  virtual int do_apply_event(Relay_log_info const *)
 
1078
  virtual int do_apply_event(Relay_log_info const *rli __attribute__((unused)))
979
1079
  {
980
1080
    return 0;                /* Default implementation does nothing */
981
1081
  }
1037
1137
     non-zero. The caller shall decrease the counter by one.
1038
1138
   */
1039
1139
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
1140
#endif
1040
1141
};
1041
1142
 
1042
1143
 
1179
1280
    <td>flags2</td>
1180
1281
    <td>Q_FLAGS2_CODE == 0</td>
1181
1282
    <td>4 byte bitfield</td>
1182
 
    <td>The flags in @c session->options, binary AND-ed with @c
1183
 
    OPTIONS_WRITTEN_TO_BIN_LOG.  The @c session->options bitfield contains
 
1283
    <td>The flags in @c thd->options, binary AND-ed with @c
 
1284
    OPTIONS_WRITTEN_TO_BIN_LOG.  The @c thd->options bitfield contains
1184
1285
    options for "SELECT".  @c OPTIONS_WRITTEN identifies those options
1185
1286
    that need to be written to the binlog (not all do).  Specifically,
1186
1287
    @c OPTIONS_WRITTEN_TO_BIN_LOG equals (@c OPTION_AUTO_IS_NULL | @c
1337
1438
    <td>2 byte integer</td>
1338
1439
 
1339
1440
    <td>The value of the collation_database system variable (in the
1340
 
    source code stored in @c session->variables.collation_database), which
 
1441
    source code stored in @c thd->variables.collation_database), which
1341
1442
    holds the code for a (character set, collation) pair as described
1342
1443
    above (see Q_CHARSET_CODE).
1343
1444
 
1404
1505
    concerned) from here.
1405
1506
  */
1406
1507
 
1407
 
  uint32_t catalog_len;                 // <= 255 char; 0 means uninited
 
1508
  uint catalog_len;                     // <= 255 char; 0 means uninited
1408
1509
 
1409
1510
  /*
1410
1511
    We want to be able to store a variable number of N-bit status vars:
1430
1531
 
1431
1532
  /*
1432
1533
    'flags2' is a second set of flags (on top of those in Log_event), for
1433
 
    session variables. These are session->options which is & against a mask
 
1534
    session variables. These are thd->options which is & against a mask
1434
1535
    (OPTIONS_WRITTEN_TO_BIN_LOG).
1435
1536
    flags2_inited helps make a difference between flags2==0 (3.23 or 4.x
1436
1537
    master, we don't know flags2, so use the slave server's global options) and
1446
1547
  ulong sql_mode;
1447
1548
  ulong auto_increment_increment, auto_increment_offset;
1448
1549
  char charset[6];
1449
 
  uint32_t time_zone_len; /* 0 means uninited */
 
1550
  uint time_zone_len; /* 0 means uninited */
1450
1551
  const char *time_zone_str;
1451
 
  uint32_t lc_time_names_number; /* 0 means en_US */
1452
 
  uint32_t charset_database_number;
1453
 
 
1454
 
 
1455
 
  Query_log_event(Session* session_arg, const char* query_arg, ulong query_length,
 
1552
  uint lc_time_names_number; /* 0 means en_US */
 
1553
  uint charset_database_number;
 
1554
 
 
1555
#ifndef MYSQL_CLIENT
 
1556
 
 
1557
  Query_log_event(THD* thd_arg, const char* query_arg, ulong query_length,
1456
1558
                  bool using_trans, bool suppress_use,
1457
 
                  Session::killed_state killed_err_arg= Session::KILLED_NO_VALUE);
 
1559
                  THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
1458
1560
  const char* get_db() { return db; }
 
1561
#ifdef HAVE_REPLICATION
1459
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
1460
1568
 
1461
1569
  Query_log_event();
1462
 
  Query_log_event(const char* buf, uint32_t event_len,
 
1570
  Query_log_event(const char* buf, uint event_len,
1463
1571
                  const Format_description_log_event *description_event,
1464
1572
                  Log_event_type event_type);
1465
1573
  ~Query_log_event()
1466
1574
  {
1467
1575
    if (data_buf)
1468
 
      free((unsigned char*) data_buf);
 
1576
      my_free((uchar*) data_buf, MYF(0));
1469
1577
  }
1470
1578
  Log_event_type get_type_code() { return QUERY_EVENT; }
 
1579
#ifndef MYSQL_CLIENT
1471
1580
  bool write(IO_CACHE* file);
1472
 
  virtual bool write_post_header_for_derived(IO_CACHE*)
 
1581
  virtual bool write_post_header_for_derived(IO_CACHE* file __attribute__((unused)))
1473
1582
  { return false; }
 
1583
#endif
1474
1584
  bool is_valid() const { return query != 0; }
1475
1585
 
1476
1586
  /*
1481
1591
  /* Writes derived event-specific part of post header. */
1482
1592
 
1483
1593
public:        /* !!! Public in this patch to allow old usage */
 
1594
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1484
1595
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
1485
1596
  virtual int do_apply_event(Relay_log_info const *rli);
1486
1597
  virtual int do_update_pos(Relay_log_info *rli);
1488
1599
  int do_apply_event(Relay_log_info const *rli,
1489
1600
                       const char *query_arg,
1490
1601
                       uint32_t q_len_arg);
 
1602
#endif /* HAVE_REPLICATION */
1491
1603
};
1492
1604
 
1493
1605
 
 
1606
#ifdef HAVE_REPLICATION
 
1607
 
1494
1608
/**
1495
1609
  @class Slave_log_event
1496
1610
 
1539
1653
  </tr>
1540
1654
  </table>
1541
1655
*/
1542
 
 
1543
1656
class Slave_log_event: public Log_event
1544
1657
{
1545
1658
protected:
1546
1659
  char* mem_pool;
1547
 
  void init_from_mem_pool();
 
1660
  void init_from_mem_pool(int data_size);
1548
1661
public:
1549
 
  off_t master_pos;
1550
 
  std::string master_host;
1551
 
  std::string master_log;
 
1662
  my_off_t master_pos;
 
1663
  char* master_host;
 
1664
  char* master_log;
 
1665
  int master_host_len;
 
1666
  int master_log_len;
1552
1667
  uint16_t master_port;
1553
1668
 
1554
 
  Slave_log_event(Session* session_arg, Relay_log_info* rli);
 
1669
#ifndef MYSQL_CLIENT
 
1670
  Slave_log_event(THD* thd_arg, Relay_log_info* rli);
1555
1671
  void pack_info(Protocol* protocol);
 
1672
#else
 
1673
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
1674
#endif
1556
1675
 
1557
 
  Slave_log_event(const char* buf, uint32_t event_len);
 
1676
  Slave_log_event(const char* buf, uint event_len);
1558
1677
  ~Slave_log_event();
1559
1678
  int get_data_size();
1560
 
  bool is_valid() const { return master_host.length() != 0; }
 
1679
  bool is_valid() const { return master_host != 0; }
1561
1680
  Log_event_type get_type_code() { return SLAVE_EVENT; }
 
1681
#ifndef MYSQL_CLIENT
1562
1682
  bool write(IO_CACHE* file);
 
1683
#endif
1563
1684
 
1564
1685
private:
 
1686
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1565
1687
  virtual int do_apply_event(Relay_log_info const* rli);
 
1688
#endif
1566
1689
};
1567
1690
 
 
1691
#endif /* HAVE_REPLICATION */
 
1692
 
1568
1693
 
1569
1694
/**
1570
1695
  @class Load_log_event
1576
1701
   (1)    USE db;
1577
1702
   (2)    LOAD DATA [LOCAL] INFILE 'file_name'
1578
1703
   (3)    [REPLACE | IGNORE]
1579
 
   (4)    INTO Table 'table_name'
 
1704
   (4)    INTO TABLE 'table_name'
1580
1705
   (5)    [FIELDS
1581
1706
   (6)      [TERMINATED BY 'field_term']
1582
1707
   (7)      [[OPTIONALLY] ENCLOSED BY 'enclosed']
1768
1893
class Load_log_event: public Log_event
1769
1894
{
1770
1895
private:
1771
 
  uint32_t get_query_buffer_length();
 
1896
  uint get_query_buffer_length();
1772
1897
  void print_query(bool need_db, char *buf, char **end,
1773
1898
                   char **fn_start, char **fn_end);
1774
1899
protected:
1789
1914
  uint32_t fname_len;
1790
1915
  uint32_t num_fields;
1791
1916
  const char* fields;
1792
 
  const unsigned char* field_lens;
 
1917
  const uchar* field_lens;
1793
1918
  uint32_t field_block_len;
1794
1919
 
1795
1920
  const char* table_name;
1800
1925
  bool local_fname;
1801
1926
 
1802
1927
  /* fname doesn't point to memory inside Log_event::temp_buf  */
1803
 
  void set_fname_outside_temp_buf(const char *afname, uint32_t alen)
 
1928
  void set_fname_outside_temp_buf(const char *afname, uint alen)
1804
1929
  {
1805
1930
    fname= afname;
1806
1931
    fname_len= alen;
1812
1937
    return local_fname;
1813
1938
  }
1814
1939
 
 
1940
#ifndef MYSQL_CLIENT
1815
1941
  String field_lens_buf;
1816
1942
  String fields_buf;
1817
1943
 
1818
 
  Load_log_event(Session* session, sql_exchange* ex, const char* db_arg,
 
1944
  Load_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
1819
1945
                 const char* table_name_arg,
1820
1946
                 List<Item>& fields_arg, enum enum_duplicates handle_dup, bool ignore,
1821
1947
                 bool using_trans);
1822
1948
  void set_fields(const char* db, List<Item> &fields_arg,
1823
1949
                  Name_resolution_context *context);
1824
1950
  const char* get_db() { return db; }
 
1951
#ifdef HAVE_REPLICATION
1825
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
1826
1958
 
1827
1959
  /*
1828
1960
    Note that for all the events related to LOAD DATA (Load_log_event,
1830
1962
    logging of LOAD DATA is going to be changed in 4.1 or 5.0, this is only used
1831
1963
    for the common_header_len (post_header_len will not be changed).
1832
1964
  */
1833
 
  Load_log_event(const char* buf, uint32_t event_len,
 
1965
  Load_log_event(const char* buf, uint event_len,
1834
1966
                 const Format_description_log_event* description_event);
1835
1967
  ~Load_log_event()
1836
1968
  {}
1838
1970
  {
1839
1971
    return sql_ex.new_format() ? NEW_LOAD_EVENT: LOAD_EVENT;
1840
1972
  }
 
1973
#ifndef MYSQL_CLIENT
1841
1974
  bool write_data_header(IO_CACHE* file);
1842
1975
  bool write_data_body(IO_CACHE* file);
 
1976
#endif
1843
1977
  bool is_valid() const { return table_name != 0; }
1844
1978
  int get_data_size()
1845
1979
  {
1849
1983
  }
1850
1984
 
1851
1985
public:        /* !!! Public in this patch to allow old usage */
 
1986
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1852
1987
  virtual int do_apply_event(Relay_log_info const* rli)
1853
1988
  {
1854
 
    return do_apply_event(session->slave_net,rli,0);
 
1989
    return do_apply_event(thd->slave_net,rli,0);
1855
1990
  }
1856
1991
 
1857
1992
  int do_apply_event(NET *net, Relay_log_info const *rli,
1858
1993
                     bool use_rli_only_for_errors);
 
1994
#endif
1859
1995
};
1860
1996
 
1861
1997
extern char server_version[SERVER_VERSION_LENGTH];
1915
2051
  */
1916
2052
  bool dont_set_created;
1917
2053
 
 
2054
#ifndef MYSQL_CLIENT
1918
2055
  Start_log_event_v3();
 
2056
#ifdef HAVE_REPLICATION
1919
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
1920
2063
 
1921
2064
  Start_log_event_v3(const char* buf,
1922
2065
                     const Format_description_log_event* description_event);
1923
2066
  ~Start_log_event_v3() {}
1924
2067
  Log_event_type get_type_code() { return START_EVENT_V3;}
 
2068
#ifndef MYSQL_CLIENT
1925
2069
  bool write(IO_CACHE* file);
 
2070
#endif
1926
2071
  bool is_valid() const { return 1; }
1927
2072
  int get_data_size()
1928
2073
  {
1931
2076
  virtual bool is_artificial_event() { return artificial_event; }
1932
2077
 
1933
2078
protected:
 
2079
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
1934
2080
  virtual int do_apply_event(Relay_log_info const *rli);
1935
2081
  virtual enum_skip_reason do_shall_skip(Relay_log_info*)
1936
2082
  {
1943
2089
    else
1944
2090
      return Log_event::EVENT_SKIP_NOT;
1945
2091
  }
 
2092
#endif
1946
2093
};
1947
2094
 
1948
2095
 
1969
2116
  uint8_t number_of_event_types;
1970
2117
  /* The list of post-headers' lengthes */
1971
2118
  uint8_t *post_header_len;
1972
 
  unsigned char server_version_split[3];
 
2119
  uchar server_version_split[3];
1973
2120
  const uint8_t *event_type_permutation;
1974
2121
 
1975
2122
  Format_description_log_event(uint8_t binlog_ver, const char* server_ver=0);
1976
 
  Format_description_log_event(const char* buf, uint32_t event_len,
 
2123
  Format_description_log_event(const char* buf, uint event_len,
1977
2124
                               const Format_description_log_event
1978
2125
                               *description_event);
1979
2126
  ~Format_description_log_event()
1980
2127
  {
1981
 
    free((unsigned char*)post_header_len);
 
2128
    my_free((uchar*)post_header_len, MYF(MY_ALLOW_ZERO_PTR));
1982
2129
  }
1983
2130
  Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
 
2131
#ifndef MYSQL_CLIENT
1984
2132
  bool write(IO_CACHE* file);
 
2133
#endif
1985
2134
  bool is_valid() const
1986
2135
  {
1987
2136
    return ((common_header_len >= ((binlog_version==1) ? OLD_HEADER_LEN :
2001
2150
  void calc_server_version_split();
2002
2151
 
2003
2152
protected:
 
2153
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2004
2154
  virtual int do_apply_event(Relay_log_info const *rli);
2005
2155
  virtual int do_update_pos(Relay_log_info *rli);
2006
2156
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2157
#endif
2007
2158
};
2008
2159
 
2009
2160
 
2048
2199
{
2049
2200
public:
2050
2201
  uint64_t val;
2051
 
  unsigned char type;
 
2202
  uchar type;
2052
2203
 
2053
 
  Intvar_log_event(Session* session_arg,unsigned char type_arg, uint64_t val_arg)
2054
 
    :Log_event(session_arg,0,0),val(val_arg),type(type_arg)
 
2204
#ifndef MYSQL_CLIENT
 
2205
  Intvar_log_event(THD* thd_arg,uchar type_arg, uint64_t val_arg)
 
2206
    :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
2055
2207
  {}
 
2208
#ifdef HAVE_REPLICATION
2056
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
2057
2214
 
2058
2215
  Intvar_log_event(const char* buf,
2059
2216
                   const Format_description_log_event *description_event);
2061
2218
  Log_event_type get_type_code() { return INTVAR_EVENT;}
2062
2219
  const char* get_var_type_name();
2063
2220
  int get_data_size() { return  9; /* sizeof(type) + sizeof(val) */;}
 
2221
#ifndef MYSQL_CLIENT
2064
2222
  bool write(IO_CACHE* file);
 
2223
#endif
2065
2224
  bool is_valid() const { return 1; }
2066
2225
 
2067
2226
private:
 
2227
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2068
2228
  virtual int do_apply_event(Relay_log_info const *rli);
2069
2229
  virtual int do_update_pos(Relay_log_info *rli);
2070
2230
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2231
#endif
2071
2232
};
2072
2233
 
2073
2234
 
2115
2276
  uint64_t seed1;
2116
2277
  uint64_t seed2;
2117
2278
 
2118
 
  Rand_log_event(Session* session_arg, uint64_t seed1_arg, uint64_t seed2_arg)
2119
 
    :Log_event(session_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
 
2279
#ifndef MYSQL_CLIENT
 
2280
  Rand_log_event(THD* thd_arg, uint64_t seed1_arg, uint64_t seed2_arg)
 
2281
    :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
2120
2282
  {}
 
2283
#ifdef HAVE_REPLICATION
2121
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
2122
2289
 
2123
2290
  Rand_log_event(const char* buf,
2124
2291
                 const Format_description_log_event *description_event);
2125
2292
  ~Rand_log_event() {}
2126
2293
  Log_event_type get_type_code() { return RAND_EVENT;}
2127
2294
  int get_data_size() { return 16; /* sizeof(uint64_t) * 2*/ }
 
2295
#ifndef MYSQL_CLIENT
2128
2296
  bool write(IO_CACHE* file);
 
2297
#endif
2129
2298
  bool is_valid() const { return 1; }
2130
2299
 
2131
2300
private:
 
2301
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2132
2302
  virtual int do_apply_event(Relay_log_info const *rli);
2133
2303
  virtual int do_update_pos(Relay_log_info *rli);
2134
2304
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2305
#endif
2135
2306
};
2136
2307
 
2137
2308
/**
2142
2313
 
2143
2314
  @section Xid_log_event_binary_format Binary Format  
2144
2315
*/
 
2316
#ifdef MYSQL_CLIENT
 
2317
typedef uint64_t my_xid; // this line is the same as in handler.h
 
2318
#endif
 
2319
 
2145
2320
class Xid_log_event: public Log_event
2146
2321
{
2147
2322
 public:
2148
2323
   my_xid xid;
2149
2324
 
2150
 
  Xid_log_event(Session* session_arg, my_xid x): Log_event(session_arg,0,0), xid(x) {}
 
2325
#ifndef MYSQL_CLIENT
 
2326
  Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
 
2327
#ifdef HAVE_REPLICATION
2151
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
2152
2333
 
2153
2334
  Xid_log_event(const char* buf,
2154
2335
                const Format_description_log_event *description_event);
2155
2336
  ~Xid_log_event() {}
2156
2337
  Log_event_type get_type_code() { return XID_EVENT;}
2157
2338
  int get_data_size() { return sizeof(xid); }
 
2339
#ifndef MYSQL_CLIENT
2158
2340
  bool write(IO_CACHE* file);
 
2341
#endif
2159
2342
  bool is_valid() const { return 1; }
2160
2343
 
2161
2344
private:
 
2345
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2162
2346
  virtual int do_apply_event(Relay_log_info const *rli);
2163
2347
  enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2348
#endif
2164
2349
};
2165
2350
 
2166
2351
/**
2176
2361
{
2177
2362
public:
2178
2363
  char *name;
2179
 
  uint32_t name_len;
 
2364
  uint name_len;
2180
2365
  char *val;
2181
2366
  ulong val_len;
2182
2367
  Item_result type;
2183
 
  uint32_t charset_number;
 
2368
  uint charset_number;
2184
2369
  bool is_null;
2185
 
  User_var_log_event(Session*,
2186
 
                     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,
2187
2373
                     char *val_arg, ulong val_len_arg, Item_result type_arg,
2188
 
                     uint32_t charset_number_arg)
 
2374
                     uint charset_number_arg)
2189
2375
    :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
2190
2376
    val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
2191
2377
    { is_null= !val; }
2192
2378
  void pack_info(Protocol* protocol);
 
2379
#else
 
2380
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2381
#endif
2193
2382
 
2194
2383
  User_var_log_event(const char* buf,
2195
2384
                     const Format_description_log_event *description_event);
2196
2385
  ~User_var_log_event() {}
2197
2386
  Log_event_type get_type_code() { return USER_VAR_EVENT;}
 
2387
#ifndef MYSQL_CLIENT
2198
2388
  bool write(IO_CACHE* file);
 
2389
#endif
2199
2390
  bool is_valid() const { return 1; }
2200
2391
 
2201
2392
private:
 
2393
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2202
2394
  virtual int do_apply_event(Relay_log_info const *rli);
2203
2395
  virtual int do_update_pos(Relay_log_info *rli);
2204
2396
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2397
#endif
2205
2398
};
2206
2399
 
2207
2400
 
2216
2409
class Stop_log_event: public Log_event
2217
2410
{
2218
2411
public:
 
2412
#ifndef MYSQL_CLIENT
2219
2413
  Stop_log_event() :Log_event()
2220
2414
  {}
 
2415
#else
 
2416
  void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 
2417
#endif
2221
2418
 
2222
2419
  Stop_log_event(const char* buf,
2223
2420
                 const Format_description_log_event *description_event):
2228
2425
  bool is_valid() const { return 1; }
2229
2426
 
2230
2427
private:
 
2428
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2231
2429
  virtual int do_update_pos(Relay_log_info *rli);
2232
 
  virtual enum_skip_reason do_shall_skip(Relay_log_info *)
 
2430
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli __attribute__((unused)))
2233
2431
  {
2234
2432
    /*
2235
2433
      Events from ourself should be skipped, but they should not
2240
2438
    else
2241
2439
      return Log_event::EVENT_SKIP_NOT;
2242
2440
  }
 
2441
#endif
2243
2442
};
2244
2443
 
2245
2444
/**
2299
2498
  };
2300
2499
  const char* new_log_ident;
2301
2500
  uint64_t pos;
2302
 
  uint32_t ident_len;
2303
 
  uint32_t flags;
 
2501
  uint ident_len;
 
2502
  uint flags;
 
2503
#ifndef MYSQL_CLIENT
2304
2504
  Rotate_log_event(const char* new_log_ident_arg,
2305
 
                   uint32_t ident_len_arg,
2306
 
                   uint64_t pos_arg, uint32_t flags);
 
2505
                   uint ident_len_arg,
 
2506
                   uint64_t pos_arg, uint flags);
 
2507
#ifdef HAVE_REPLICATION
2307
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
2308
2513
 
2309
 
  Rotate_log_event(const char* buf, uint32_t event_len,
 
2514
  Rotate_log_event(const char* buf, uint event_len,
2310
2515
                   const Format_description_log_event* description_event);
2311
2516
  ~Rotate_log_event()
2312
2517
  {
2313
2518
    if (flags & DUP_NAME)
2314
 
      free((unsigned char*) new_log_ident);
 
2519
      my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR));
2315
2520
  }
2316
2521
  Log_event_type get_type_code() { return ROTATE_EVENT;}
2317
2522
  int get_data_size() { return  ident_len + ROTATE_HEADER_LEN;}
2318
2523
  bool is_valid() const { return new_log_ident != 0; }
 
2524
#ifndef MYSQL_CLIENT
2319
2525
  bool write(IO_CACHE* file);
 
2526
#endif
2320
2527
 
2321
2528
private:
 
2529
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2322
2530
  virtual int do_update_pos(Relay_log_info *rli);
2323
2531
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2532
#endif
2324
2533
};
2325
2534
 
2326
2535
 
2342
2551
  */
2343
2552
  bool fake_base;
2344
2553
public:
2345
 
  unsigned char* block;
 
2554
  uchar* block;
2346
2555
  const char *event_buf;
2347
 
  uint32_t block_len;
2348
 
  uint32_t file_id;
 
2556
  uint block_len;
 
2557
  uint file_id;
2349
2558
  bool inited_from_old;
2350
2559
 
2351
 
  Create_file_log_event(Session* session, sql_exchange* ex, const char* db_arg,
 
2560
#ifndef MYSQL_CLIENT
 
2561
  Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
2352
2562
                        const char* table_name_arg,
2353
2563
                        List<Item>& fields_arg,
2354
2564
                        enum enum_duplicates handle_dup, bool ignore,
2355
 
                        unsigned char* block_arg, uint32_t block_len_arg,
 
2565
                        uchar* block_arg, uint block_len_arg,
2356
2566
                        bool using_trans);
 
2567
#ifdef HAVE_REPLICATION
2357
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
2358
2575
 
2359
 
  Create_file_log_event(const char* buf, uint32_t event_len,
 
2576
  Create_file_log_event(const char* buf, uint event_len,
2360
2577
                        const Format_description_log_event* description_event);
2361
2578
  ~Create_file_log_event()
2362
2579
  {
2363
 
    free((char*) event_buf);
 
2580
    my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR));
2364
2581
  }
2365
2582
 
2366
2583
  Log_event_type get_type_code()
2374
2591
            4 + 1 + block_len);
2375
2592
  }
2376
2593
  bool is_valid() const { return inited_from_old || block != 0; }
 
2594
#ifndef MYSQL_CLIENT
2377
2595
  bool write_data_header(IO_CACHE* file);
2378
2596
  bool write_data_body(IO_CACHE* file);
2379
2597
  /*
2381
2599
    write it as Load event - used on the slave
2382
2600
  */
2383
2601
  bool write_base(IO_CACHE* file);
 
2602
#endif
2384
2603
 
2385
2604
private:
 
2605
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2386
2606
  virtual int do_apply_event(Relay_log_info const *rli);
 
2607
#endif
2387
2608
};
2388
2609
 
2389
2610
 
2396
2617
class Append_block_log_event: public Log_event
2397
2618
{
2398
2619
public:
2399
 
  unsigned char* block;
2400
 
  uint32_t block_len;
2401
 
  uint32_t file_id;
 
2620
  uchar* block;
 
2621
  uint block_len;
 
2622
  uint file_id;
2402
2623
  /*
2403
2624
    'db' is filled when the event is created in mysql_load() (the
2404
2625
    event needs to have a 'db' member to be well filtered by
2412
2633
  */
2413
2634
  const char* db;
2414
2635
 
2415
 
  Append_block_log_event(Session* session, const char* db_arg, unsigned char* block_arg,
2416
 
                         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
2417
2640
  void pack_info(Protocol* protocol);
2418
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
2419
2646
 
2420
 
  Append_block_log_event(const char* buf, uint32_t event_len,
 
2647
  Append_block_log_event(const char* buf, uint event_len,
2421
2648
                         const Format_description_log_event
2422
2649
                         *description_event);
2423
2650
  ~Append_block_log_event() {}
2424
2651
  Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
2425
2652
  int get_data_size() { return  block_len + APPEND_BLOCK_HEADER_LEN ;}
2426
2653
  bool is_valid() const { return block != 0; }
 
2654
#ifndef MYSQL_CLIENT
2427
2655
  bool write(IO_CACHE* file);
2428
2656
  const char* get_db() { return db; }
 
2657
#endif
2429
2658
 
2430
2659
private:
 
2660
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2431
2661
  virtual int do_apply_event(Relay_log_info const *rli);
 
2662
#endif
2432
2663
};
2433
2664
 
2434
2665
 
2441
2672
class Delete_file_log_event: public Log_event
2442
2673
{
2443
2674
public:
2444
 
  uint32_t file_id;
 
2675
  uint file_id;
2445
2676
  const char* db; /* see comment in Append_block_log_event */
2446
2677
 
2447
 
  Delete_file_log_event(Session* session, const char* db_arg, bool using_trans);
 
2678
#ifndef MYSQL_CLIENT
 
2679
  Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
 
2680
#ifdef HAVE_REPLICATION
2448
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
2449
2688
 
2450
 
  Delete_file_log_event(const char* buf, uint32_t event_len,
 
2689
  Delete_file_log_event(const char* buf, uint event_len,
2451
2690
                        const Format_description_log_event* description_event);
2452
2691
  ~Delete_file_log_event() {}
2453
2692
  Log_event_type get_type_code() { return DELETE_FILE_EVENT;}
2454
2693
  int get_data_size() { return DELETE_FILE_HEADER_LEN ;}
2455
2694
  bool is_valid() const { return file_id != 0; }
 
2695
#ifndef MYSQL_CLIENT
2456
2696
  bool write(IO_CACHE* file);
2457
2697
  const char* get_db() { return db; }
 
2698
#endif
2458
2699
 
2459
2700
private:
 
2701
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2460
2702
  virtual int do_apply_event(Relay_log_info const *rli);
 
2703
#endif
2461
2704
};
2462
2705
 
2463
2706
 
2470
2713
class Execute_load_log_event: public Log_event
2471
2714
{
2472
2715
public:
2473
 
  uint32_t file_id;
 
2716
  uint file_id;
2474
2717
  const char* db; /* see comment in Append_block_log_event */
2475
2718
 
2476
 
  Execute_load_log_event(Session* session, const char* db_arg, bool using_trans);
 
2719
#ifndef MYSQL_CLIENT
 
2720
  Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
 
2721
#ifdef HAVE_REPLICATION
2477
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
2478
2727
 
2479
 
  Execute_load_log_event(const char* buf, uint32_t event_len,
 
2728
  Execute_load_log_event(const char* buf, uint event_len,
2480
2729
                         const Format_description_log_event
2481
2730
                         *description_event);
2482
2731
  ~Execute_load_log_event() {}
2483
2732
  Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
2484
2733
  int get_data_size() { return  EXEC_LOAD_HEADER_LEN ;}
2485
2734
  bool is_valid() const { return file_id != 0; }
 
2735
#ifndef MYSQL_CLIENT
2486
2736
  bool write(IO_CACHE* file);
2487
2737
  const char* get_db() { return db; }
 
2738
#endif
2488
2739
 
2489
2740
private:
 
2741
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2490
2742
  virtual int do_apply_event(Relay_log_info const *rli);
 
2743
#endif
2491
2744
};
2492
2745
 
2493
2746
 
2503
2756
class Begin_load_query_log_event: public Append_block_log_event
2504
2757
{
2505
2758
public:
2506
 
  Begin_load_query_log_event(Session* session_arg, const char *db_arg,
2507
 
                             unsigned char* block_arg, uint32_t block_len_arg,
 
2759
#ifndef MYSQL_CLIENT
 
2760
  Begin_load_query_log_event(THD* thd_arg, const char *db_arg,
 
2761
                             uchar* block_arg, uint block_len_arg,
2508
2762
                             bool using_trans);
2509
 
  Begin_load_query_log_event(Session* session);
 
2763
#ifdef HAVE_REPLICATION
 
2764
  Begin_load_query_log_event(THD* thd);
2510
2765
  int get_create_or_append() const;
2511
 
  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,
2512
2769
                             const Format_description_log_event
2513
2770
                             *description_event);
2514
2771
  ~Begin_load_query_log_event() {}
2515
2772
  Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
2516
2773
private:
 
2774
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2517
2775
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
2776
#endif
2518
2777
};
2519
2778
 
2520
2779
 
2536
2795
class Execute_load_query_log_event: public Query_log_event
2537
2796
{
2538
2797
public:
2539
 
  uint32_t file_id;       // file_id of temporary file
2540
 
  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
2541
2800
                      // be substituted
2542
 
  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
2543
2802
  /*
2544
2803
    We have to store type of duplicate handling explicitly, because
2545
2804
    for LOAD DATA it also depends on LOCAL option. And this part
2548
2807
  */
2549
2808
  enum_load_dup_handling dup_handling;
2550
2809
 
2551
 
  Execute_load_query_log_event(Session* session, const char* query_arg,
2552
 
                               ulong query_length, uint32_t fn_pos_start_arg,
2553
 
                               uint32_t fn_pos_end_arg,
 
2810
#ifndef MYSQL_CLIENT
 
2811
  Execute_load_query_log_event(THD* thd, const char* query_arg,
 
2812
                               ulong query_length, uint fn_pos_start_arg,
 
2813
                               uint fn_pos_end_arg,
2554
2814
                               enum_load_dup_handling dup_handling_arg,
2555
2815
                               bool using_trans, bool suppress_use,
2556
 
                               Session::killed_state
2557
 
                               killed_err_arg= Session::KILLED_NO_VALUE);
 
2816
                               THD::killed_state
 
2817
                               killed_err_arg= THD::KILLED_NO_VALUE);
 
2818
#ifdef HAVE_REPLICATION
2558
2819
  void pack_info(Protocol* protocol);
2559
 
  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,
2560
2828
                               const Format_description_log_event
2561
2829
                               *description_event);
2562
2830
  ~Execute_load_query_log_event() {}
2565
2833
  bool is_valid() const { return Query_log_event::is_valid() && file_id != 0; }
2566
2834
 
2567
2835
  ulong get_post_header_size_for_derived();
 
2836
#ifndef MYSQL_CLIENT
2568
2837
  bool write_post_header_for_derived(IO_CACHE* file);
 
2838
#endif
2569
2839
 
2570
2840
private:
 
2841
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2571
2842
  virtual int do_apply_event(Relay_log_info const *rli);
2572
 
};
2573
 
 
2574
 
 
2575
 
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);
2576
2872
 
2577
2873
/**
2578
2874
  @class Table_map_log_event
2865
3161
  void clear_flags(flag_set flag) { m_flags &= ~flag; }
2866
3162
  flag_set get_flags(flag_set flag) const { return m_flags & flag; }
2867
3163
 
2868
 
  Table_map_log_event(Session *session, Table *tbl, ulong tid, 
 
3164
#ifndef MYSQL_CLIENT
 
3165
  Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, 
2869
3166
                      bool is_transactional, uint16_t flags);
2870
 
  Table_map_log_event(const char *buf, uint32_t event_len, 
 
3167
#endif
 
3168
#ifdef HAVE_REPLICATION
 
3169
  Table_map_log_event(const char *buf, uint event_len, 
2871
3170
                      const Format_description_log_event *description_event);
 
3171
#endif
2872
3172
 
2873
3173
  ~Table_map_log_event();
2874
3174
 
2876
3176
  virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
2877
3177
 
2878
3178
  virtual int get_data_size() { return m_data_size; } 
 
3179
#ifndef MYSQL_CLIENT
2879
3180
  virtual int save_field_metadata();
2880
3181
  virtual bool write_data_header(IO_CACHE *file);
2881
3182
  virtual bool write_data_body(IO_CACHE *file);
2882
3183
  virtual const char *get_db() { return m_dbnam; }
 
3184
#endif
 
3185
 
 
3186
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2883
3187
  virtual void pack_info(Protocol *protocol);
 
3188
#endif
 
3189
 
 
3190
#ifdef MYSQL_CLIENT
 
3191
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3192
#endif
 
3193
 
2884
3194
 
2885
3195
private:
 
3196
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2886
3197
  virtual int do_apply_event(Relay_log_info const *rli);
2887
3198
  virtual int do_update_pos(Relay_log_info *rli);
2888
3199
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
 
3200
#endif
2889
3201
 
2890
 
  Table         *m_table;
 
3202
#ifndef MYSQL_CLIENT
 
3203
  TABLE         *m_table;
 
3204
#endif
2891
3205
  char const    *m_dbnam;
2892
3206
  size_t         m_dblen;
2893
3207
  char const    *m_tblnam;
2894
3208
  size_t         m_tbllen;
2895
3209
  ulong          m_colcnt;
2896
 
  unsigned char         *m_coltype;
 
3210
  uchar         *m_coltype;
2897
3211
 
2898
 
  unsigned char         *m_memory;
 
3212
  uchar         *m_memory;
2899
3213
  ulong          m_table_id;
2900
3214
  flag_set       m_flags;
2901
3215
 
2902
3216
  size_t         m_data_size;
2903
3217
 
2904
 
  unsigned char          *m_field_metadata;        // buffer for field metadata
 
3218
  uchar          *m_field_metadata;        // buffer for field metadata
2905
3219
  /*
2906
3220
    The size of field metadata buffer set by calling save_field_metadata()
2907
3221
  */
2908
3222
  ulong          m_field_metadata_size;   
2909
 
  unsigned char         *m_null_bits;
2910
 
  unsigned char         *m_meta_memory;
 
3223
  uchar         *m_null_bits;
 
3224
  uchar         *m_meta_memory;
2911
3225
};
2912
3226
 
2913
3227
 
2954
3268
    /* Last event of a statement */
2955
3269
    STMT_END_F = (1U << 0),
2956
3270
 
2957
 
    /* Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in session->options */
 
3271
    /* Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in thd->options */
2958
3272
    NO_FOREIGN_KEY_CHECKS_F = (1U << 1),
2959
3273
 
2960
 
    /* Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in session->options */
 
3274
    /* Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in thd->options */
2961
3275
    RELAXED_UNIQUE_CHECKS_F = (1U << 2),
2962
3276
 
2963
3277
    /** 
2981
3295
  void clear_flags(flag_set flags_arg) { m_flags &= ~flags_arg; }
2982
3296
  flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
2983
3297
 
 
3298
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
2984
3299
  virtual void pack_info(Protocol *protocol);
2985
 
 
2986
 
  int add_row_data(unsigned char *data, size_t length)
 
3300
#endif
 
3301
 
 
3302
#ifdef MYSQL_CLIENT
 
3303
  /* not for direct call, each derived has its own ::print() */
 
3304
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info)= 0;
 
3305
#endif
 
3306
 
 
3307
#ifndef MYSQL_CLIENT
 
3308
  int add_row_data(uchar *data, size_t length)
2987
3309
  {
2988
3310
    return do_add_row_data(data,length); 
2989
3311
  }
 
3312
#endif
2990
3313
 
2991
3314
  /* Member functions to implement superclass interface */
2992
3315
  virtual int get_data_size();
2995
3318
  size_t get_width() const          { return m_width; }
2996
3319
  ulong get_table_id() const        { return m_table_id; }
2997
3320
 
 
3321
#ifndef MYSQL_CLIENT
2998
3322
  virtual bool write_data_header(IO_CACHE *file);
2999
3323
  virtual bool write_data_body(IO_CACHE *file);
3000
3324
  virtual const char *get_db() { return m_table->s->db.str; }
 
3325
#endif
3001
3326
  /*
3002
3327
    Check that malloc() succeeded in allocating memory for the rows
3003
3328
    buffer and the COLS vector. Checking that an Update_rows_log_event
3009
3334
    return m_rows_buf && m_cols.bitmap;
3010
3335
  }
3011
3336
 
3012
 
  uint32_t     m_row_count;         /* The number of rows added to the event */
 
3337
  uint     m_row_count;         /* The number of rows added to the event */
3013
3338
 
3014
3339
protected:
3015
3340
  /* 
3016
3341
     The constructors are protected since you're supposed to inherit
3017
3342
     this class, not create instances of this class.
3018
3343
  */
3019
 
  Rows_log_event(Session*, Table*, ulong table_id, 
 
3344
#ifndef MYSQL_CLIENT
 
3345
  Rows_log_event(THD*, TABLE*, ulong table_id, 
3020
3346
                 MY_BITMAP const *cols, bool is_transactional);
3021
 
  Rows_log_event(const char *row_data, uint32_t event_len, 
 
3347
#endif
 
3348
  Rows_log_event(const char *row_data, uint event_len, 
3022
3349
                 Log_event_type event_type,
3023
3350
                 const Format_description_log_event *description_event);
3024
3351
 
3025
 
  virtual int do_add_row_data(unsigned char *data, size_t length);
3026
 
 
3027
 
  Table *m_table;               /* The table the rows belong to */
 
3352
#ifdef MYSQL_CLIENT
 
3353
  void print_helper(FILE *, PRINT_EVENT_INFO *, char const *const name);
 
3354
#endif
 
3355
 
 
3356
#ifndef MYSQL_CLIENT
 
3357
  virtual int do_add_row_data(uchar *data, size_t length);
 
3358
#endif
 
3359
 
 
3360
#ifndef MYSQL_CLIENT
 
3361
  TABLE *m_table;               /* The table the rows belong to */
 
3362
#endif
3028
3363
  ulong       m_table_id;       /* Table ID */
3029
3364
  MY_BITMAP   m_cols;           /* Bitmap denoting columns available */
3030
3365
  ulong       m_width;          /* The width of the columns bitmap */
3043
3378
  uint32_t    m_bitbuf[128/(sizeof(uint32_t)*8)];
3044
3379
  uint32_t    m_bitbuf_ai[128/(sizeof(uint32_t)*8)];
3045
3380
 
3046
 
  unsigned char    *m_rows_buf;         /* The rows in packed format */
3047
 
  unsigned char    *m_rows_cur;         /* One-after the end of the data */
3048
 
  unsigned char    *m_rows_end;         /* One-after the end of the allocated space */
 
3381
  uchar    *m_rows_buf;         /* The rows in packed format */
 
3382
  uchar    *m_rows_cur;         /* One-after the end of the data */
 
3383
  uchar    *m_rows_end;         /* One-after the end of the allocated space */
3049
3384
 
3050
3385
  flag_set m_flags;             /* Flags for row-level events */
3051
3386
 
3052
3387
  /* helper functions */
3053
3388
 
3054
 
  const unsigned char *m_curr_row;     /* Start of the row being processed */
3055
 
  const unsigned char *m_curr_row_end; /* One-after the end of the current row */
3056
 
  unsigned char    *m_key;      /* Buffer to keep key value during searches */
 
3389
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
 
3390
  const uchar *m_curr_row;     /* Start of the row being processed */
 
3391
  const uchar *m_curr_row_end; /* One-after the end of the current row */
 
3392
  uchar    *m_key;      /* Buffer to keep key value during searches */
3057
3393
 
3058
3394
  int find_row(const Relay_log_info *const);
3059
3395
  int write_row(const Relay_log_info *const, const bool);
3060
3396
 
3061
3397
  // Unpack the current row into m_table->record[0]
3062
3398
  int unpack_current_row(const Relay_log_info *const rli,
3063
 
                         MY_BITMAP const *cols);
 
3399
                         MY_BITMAP const *cols)
 
3400
  { 
 
3401
    assert(m_table);
 
3402
    ASSERT_OR_RETURN_ERROR(m_curr_row < m_rows_end, HA_ERR_CORRUPT_EVENT);
 
3403
    int const result= ::unpack_row(rli, m_table, m_width, m_curr_row, cols,
 
3404
                                   &m_curr_row_end, &m_master_reclength);
 
3405
    if (m_curr_row_end > m_rows_end)
 
3406
      my_error(ER_SLAVE_CORRUPT_EVENT, MYF(0));
 
3407
    ASSERT_OR_RETURN_ERROR(m_curr_row_end <= m_rows_end, HA_ERR_CORRUPT_EVENT);
 
3408
    return result;
 
3409
  }
 
3410
#endif
3064
3411
 
3065
3412
private:
3066
3413
 
 
3414
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3067
3415
  virtual int do_apply_event(Relay_log_info const *rli);
3068
3416
  virtual int do_update_pos(Relay_log_info *rli);
3069
3417
  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
3118
3466
      
3119
3467
  */
3120
3468
  virtual int do_exec_row(const Relay_log_info *const rli) = 0;
 
3469
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
3121
3470
 
3122
3471
  friend class Old_rows_log_event;
3123
3472
};
3136
3485
public:
3137
3486
  enum 
3138
3487
  {
3139
 
    /* Support interface to Session::binlog_prepare_pending_rows_event */
 
3488
    /* Support interface to THD::binlog_prepare_pending_rows_event */
3140
3489
    TYPE_CODE = WRITE_ROWS_EVENT
3141
3490
  };
3142
3491
 
3143
 
  Write_rows_log_event(Session*, Table*, ulong table_id, 
 
3492
#if !defined(MYSQL_CLIENT)
 
3493
  Write_rows_log_event(THD*, TABLE*, ulong table_id, 
3144
3494
                       bool is_transactional);
3145
 
  Write_rows_log_event(const char *buf, uint32_t event_len, 
 
3495
#endif
 
3496
#ifdef HAVE_REPLICATION
 
3497
  Write_rows_log_event(const char *buf, uint event_len, 
3146
3498
                       const Format_description_log_event *description_event);
3147
 
  static bool binlog_row_logging_function(Session *session, Table *table,
 
3499
#endif
 
3500
#if !defined(MYSQL_CLIENT) 
 
3501
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3148
3502
                                          bool is_transactional,
3149
 
                                          const unsigned char *,
3150
 
                                          const unsigned char *after_record)
 
3503
                                          const uchar *before_record
 
3504
                                          __attribute__((unused)),
 
3505
                                          const uchar *after_record)
3151
3506
  {
3152
 
    return session->binlog_write_row(table, is_transactional, after_record);
 
3507
    return thd->binlog_write_row(table, is_transactional, after_record);
3153
3508
  }
 
3509
#endif
3154
3510
 
3155
3511
private:
3156
3512
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3157
3513
 
 
3514
#ifdef MYSQL_CLIENT
 
3515
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3516
#endif
 
3517
 
 
3518
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3158
3519
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3159
3520
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3160
3521
  virtual int do_exec_row(const Relay_log_info *const);
 
3522
#endif
3161
3523
};
3162
3524
 
3163
3525
 
3178
3540
public:
3179
3541
  enum 
3180
3542
  {
3181
 
    /* Support interface to Session::binlog_prepare_pending_rows_event */
 
3543
    /* Support interface to THD::binlog_prepare_pending_rows_event */
3182
3544
    TYPE_CODE = UPDATE_ROWS_EVENT
3183
3545
  };
3184
3546
 
3185
 
  Update_rows_log_event(Session*, Table*, ulong table_id,
 
3547
#ifndef MYSQL_CLIENT
 
3548
  Update_rows_log_event(THD*, TABLE*, ulong table_id,
3186
3549
                        bool is_transactional);
3187
3550
 
3188
3551
  void init(MY_BITMAP const *cols);
 
3552
#endif
3189
3553
 
3190
3554
  virtual ~Update_rows_log_event();
3191
3555
 
3192
 
  Update_rows_log_event(const char *buf, uint32_t event_len, 
 
3556
#ifdef HAVE_REPLICATION
 
3557
  Update_rows_log_event(const char *buf, uint event_len, 
3193
3558
                        const Format_description_log_event *description_event);
 
3559
#endif
3194
3560
 
3195
 
  static bool binlog_row_logging_function(Session *session, Table *table,
 
3561
#if !defined(MYSQL_CLIENT) 
 
3562
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3196
3563
                                          bool is_transactional,
3197
 
                                          const unsigned char *before_record,
3198
 
                                          const unsigned char *after_record)
 
3564
                                          const uchar *before_record,
 
3565
                                          const uchar *after_record)
3199
3566
  {
3200
 
    return session->binlog_update_row(table, is_transactional,
 
3567
    return thd->binlog_update_row(table, is_transactional,
3201
3568
                                  before_record, after_record);
3202
3569
  }
 
3570
#endif
3203
3571
 
3204
3572
  virtual bool is_valid() const
3205
3573
  {
3209
3577
protected:
3210
3578
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3211
3579
 
 
3580
#ifdef MYSQL_CLIENT
 
3581
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3582
#endif
 
3583
 
 
3584
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3212
3585
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3213
3586
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3214
3587
  virtual int do_exec_row(const Relay_log_info *const);
 
3588
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
3215
3589
};
3216
3590
 
3217
3591
/**
3239
3613
public:
3240
3614
  enum 
3241
3615
  {
3242
 
    /* Support interface to Session::binlog_prepare_pending_rows_event */
 
3616
    /* Support interface to THD::binlog_prepare_pending_rows_event */
3243
3617
    TYPE_CODE = DELETE_ROWS_EVENT
3244
3618
  };
3245
3619
 
3246
 
  Delete_rows_log_event(Session*, Table*, ulong, 
 
3620
#ifndef MYSQL_CLIENT
 
3621
  Delete_rows_log_event(THD*, TABLE*, ulong, 
3247
3622
                        bool is_transactional);
3248
 
  Delete_rows_log_event(const char *buf, uint32_t event_len, 
 
3623
#endif
 
3624
#ifdef HAVE_REPLICATION
 
3625
  Delete_rows_log_event(const char *buf, uint event_len, 
3249
3626
                        const Format_description_log_event *description_event);
3250
 
  static bool binlog_row_logging_function(Session *session, Table *table,
 
3627
#endif
 
3628
#if !defined(MYSQL_CLIENT) 
 
3629
  static bool binlog_row_logging_function(THD *thd, TABLE *table,
3251
3630
                                          bool is_transactional,
3252
 
                                          const unsigned char *before_record,
3253
 
                                          const unsigned char *)
 
3631
                                          const uchar *before_record,
 
3632
                                          const uchar *after_record
 
3633
                                          __attribute__((unused)))
3254
3634
  {
3255
 
    return session->binlog_delete_row(table, is_transactional, before_record);
 
3635
    return thd->binlog_delete_row(table, is_transactional, before_record);
3256
3636
  }
 
3637
#endif
3257
3638
  
3258
3639
protected:
3259
3640
  virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; }
3260
3641
 
 
3642
#ifdef MYSQL_CLIENT
 
3643
  void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3644
#endif
 
3645
 
 
3646
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3261
3647
  virtual int do_before_row_operations(const Slave_reporting_capability *const);
3262
3648
  virtual int do_after_row_operations(const Slave_reporting_capability *const,int);
3263
3649
  virtual int do_exec_row(const Relay_log_info *const);
 
3650
#endif
3264
3651
};
3265
3652
 
3266
3653
 
3302
3689
*/
3303
3690
class Incident_log_event : public Log_event {
3304
3691
public:
3305
 
  Incident_log_event(Session *session_arg, Incident incident)
3306
 
    : Log_event(session_arg, 0, false), m_incident(incident)
 
3692
#ifndef MYSQL_CLIENT
 
3693
  Incident_log_event(THD *thd_arg, Incident incident)
 
3694
    : Log_event(thd_arg, 0, false), m_incident(incident)
3307
3695
  {
3308
3696
    m_message.str= NULL;                    /* Just as a precaution */
3309
3697
    m_message.length= 0;
3310
3698
    return;
3311
3699
  }
3312
3700
 
3313
 
  Incident_log_event(Session *session_arg, Incident incident, LEX_STRING const msg)
3314
 
    : Log_event(session_arg, 0, false), m_incident(incident)
 
3701
  Incident_log_event(THD *thd_arg, Incident incident, LEX_STRING const msg)
 
3702
    : Log_event(thd_arg, 0, false), m_incident(incident)
3315
3703
  {
3316
3704
    m_message= msg;
3317
3705
    return;
3318
3706
  }
 
3707
#endif
3319
3708
 
 
3709
#ifndef MYSQL_CLIENT
3320
3710
  void pack_info(Protocol*);
 
3711
#endif
3321
3712
 
3322
 
  Incident_log_event(const char *buf, uint32_t event_len,
 
3713
  Incident_log_event(const char *buf, uint event_len,
3323
3714
                     const Format_description_log_event *descr_event);
3324
3715
 
3325
3716
  virtual ~Incident_log_event();
3326
3717
 
 
3718
#ifdef MYSQL_CLIENT
 
3719
  virtual void print(FILE *file, PRINT_EVENT_INFO *print_event_info);
 
3720
#endif
 
3721
 
 
3722
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
3327
3723
  virtual int do_apply_event(Relay_log_info const *rli);
 
3724
#endif
3328
3725
 
3329
3726
  virtual bool write_data_header(IO_CACHE *file);
3330
3727
  virtual bool write_data_body(IO_CACHE *file);
3343
3740
  LEX_STRING m_message;
3344
3741
};
3345
3742
 
3346
 
int append_query_string(const CHARSET_INFO * const csinfo,
3347
 
                        String const *from, String *to);
3348
 
 
3349
3743
static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
3350
3744
                                                       FILE *file)
3351
3745
{
3354
3748
    reinit_io_cache(cache, WRITE_CACHE, 0, false, true);
3355
3749
}
3356
3750
 
 
3751
#ifndef MYSQL_CLIENT
3357
3752
/*****************************************************************************
3358
3753
 
3359
3754
  Heartbeat Log Event class
3372
3767
class Heartbeat_log_event: public Log_event
3373
3768
{
3374
3769
public:
3375
 
  Heartbeat_log_event(const char* buf, uint32_t event_len,
 
3770
  Heartbeat_log_event(const char* buf, uint event_len,
3376
3771
                      const Format_description_log_event* description_event);
3377
3772
  Log_event_type get_type_code() { return HEARTBEAT_LOG_EVENT; }
3378
3773
  bool is_valid() const
3381
3776
              log_pos >= BIN_LOG_HEADER_SIZE);
3382
3777
    }
3383
3778
  const char * get_log_ident() { return log_ident; }
3384
 
  uint32_t get_ident_len() { return ident_len; }
 
3779
  uint get_ident_len() { return ident_len; }
3385
3780
  
3386
3781
private:
3387
3782
  const char* log_ident;
3388
 
  uint32_t ident_len;
 
3783
  uint ident_len;
3389
3784
};
 
3785
#endif
3390
3786
 
3391
3787
/**
3392
3788
  @} (end of group Replication)
3393
3789
*/
3394
3790
 
3395
 
#endif /* DRIZZLED_LOG_EVENT_H */
 
3791
#endif /* _log_event_h */