~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log_event.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 01:56:16 UTC
  • mto: This revision was merged to the branch mainline in revision 479.
  • Revision ID: brian@gir-20081006015616-n121e8o8nuwag0ov
Removed dead HAVE_REPL needs for embedded server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
 
#ifndef DRIZZLE_CLIENT
18
 
 
19
17
#include <drizzled/server_includes.h>
20
18
#include "rpl_rli.h"
21
19
#include "rpl_mi.h"
27
25
 
28
26
#include <algorithm>
29
27
 
30
 
#endif /* !DRIZZLE_CLIENT */
31
 
 
32
28
#include <mysys/base64.h>
33
29
#include <mysys/my_bitmap.h>
34
30
 
49
45
#define FMT_G_BUFSIZE(PREC) (3 + (PREC) + 5 + 1)
50
46
 
51
47
 
52
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
53
48
static const char *HA_ERR(int i)
54
49
{
55
50
  switch (i) {
150
145
              handler_error == NULL? _("<unknown>") : handler_error,
151
146
              log_name, pos);
152
147
}
153
 
#endif
 
148
 
154
149
 
155
150
/*
156
151
  Cache that will automatically be written to a dedicated file on
236
231
  pretty_print_str()
237
232
*/
238
233
 
239
 
#ifdef DRIZZLE_CLIENT
240
 
static void pretty_print_str(IO_CACHE* cache, const char* str, int len)
241
 
{
242
 
  const char* end = str + len;
243
 
  my_b_printf(cache, "\'");
244
 
  while (str < end)
245
 
  {
246
 
    char c;
247
 
    switch ((c=*str++)) {
248
 
    case '\n': my_b_printf(cache, "\\n"); break;
249
 
    case '\r': my_b_printf(cache, "\\r"); break;
250
 
    case '\\': my_b_printf(cache, "\\\\"); break;
251
 
    case '\b': my_b_printf(cache, "\\b"); break;
252
 
    case '\t': my_b_printf(cache, "\\t"); break;
253
 
    case '\'': my_b_printf(cache, "\\'"); break;
254
 
    case 0   : my_b_printf(cache, "\\0"); break;
255
 
    default:
256
 
      my_b_printf(cache, "%c", c);
257
 
      break;
258
 
    }
259
 
  }
260
 
  my_b_printf(cache, "\'");
261
 
}
262
 
#endif /* DRIZZLE_CLIENT */
263
 
 
264
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
265
 
 
266
234
static void clear_all_errors(THD *thd, Relay_log_info *rli)
267
235
{
268
236
  thd->is_slave_error = 0;
280
248
  return ((err_code == ER_SLAVE_IGNORED_TABLE) ||
281
249
          (use_slave_mask && bitmap_is_set(&slave_error_mask, err_code)));
282
250
}
283
 
#endif
284
251
 
285
252
 
286
253
/*
287
254
  pretty_print_str()
288
255
*/
289
256
 
290
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
291
257
static char *pretty_print_str(char *packet, const char *str, int len)
292
258
{
293
259
  const char *end= str + len;
312
278
  *pos++= '\'';
313
279
  return pos;
314
280
}
315
 
#endif /* !DRIZZLE_CLIENT */
316
 
 
317
 
 
318
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
281
 
319
282
 
320
283
/**
321
284
  Creates a temporary name for load data infile:.
345
308
  my_stpcpy(res, ext);                             // Add extension last
346
309
  return res;                                   // Pointer to extension
347
310
}
348
 
#endif
349
 
 
350
 
 
351
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
311
 
352
312
 
353
313
/**
354
314
  Delete all temporary files used for SQL_LOAD.
389
349
 
390
350
  my_dirend(dirp);
391
351
}
392
 
#endif
393
352
 
394
353
 
395
354
/*
438
397
  return to;                               // pointer to end 0 of 'to'
439
398
}
440
399
 
441
 
#ifndef DRIZZLE_CLIENT
442
400
 
443
401
/**
444
402
  Append a version of the 'from' string suitable for use in a query to
468
426
  to->length(orig_len + ptr - beg);
469
427
  return 0;
470
428
}
471
 
#endif
472
 
 
473
 
 
474
 
/**
475
 
  Prints a "session_var=value" string. Used by mysqlbinlog to print some SET
476
 
  commands just before it prints a query.
477
 
*/
478
 
 
479
 
#ifdef DRIZZLE_CLIENT
480
 
 
481
 
static void print_set_option(IO_CACHE* file, uint32_t bits_changed,
482
 
                             uint32_t option, uint32_t flags, const char* name,
483
 
                             bool* need_comma)
484
 
{
485
 
  if (bits_changed & option)
486
 
  {
487
 
    if (*need_comma)
488
 
      my_b_printf(file,", ");
489
 
    my_b_printf(file,"%s=%d", name, test(flags & option));
490
 
    *need_comma= 1;
491
 
  }
492
 
}
493
 
#endif
 
429
 
494
430
 
495
431
/**************************************************************************
496
432
        Log_event methods (= the parent class of all events)
544
480
  Log_event::Log_event()
545
481
*/
546
482
 
547
 
#ifndef DRIZZLE_CLIENT
548
483
Log_event::Log_event(THD* thd_arg, uint16_t flags_arg, bool using_trans)
549
484
  :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), thd(thd_arg)
550
485
{
573
508
  when=         0;
574
509
  log_pos=      0;
575
510
}
576
 
#endif /* !DRIZZLE_CLIENT */
577
511
 
578
512
 
579
513
/*
584
518
                     const Format_description_log_event* description_event)
585
519
  :temp_buf(0), cache_stmt(0)
586
520
{
587
 
#ifndef DRIZZLE_CLIENT
588
 
  thd = 0;
589
 
#endif
590
 
  when = uint4korr(buf);
591
 
  server_id = uint4korr(buf + SERVER_ID_OFFSET);
 
521
  thd= 0;
 
522
  when= uint4korr(buf);
 
523
  server_id= uint4korr(buf + SERVER_ID_OFFSET);
592
524
  data_written= uint4korr(buf + EVENT_LEN_OFFSET);
593
525
  if (description_event->binlog_version==1)
594
526
  {
647
579
  /* otherwise, go on with reading the header from buf (nothing now) */
648
580
}
649
581
 
650
 
#ifndef DRIZZLE_CLIENT
651
 
#ifdef HAVE_REPLICATION
652
582
 
653
583
int Log_event::do_update_pos(Relay_log_info *rli)
654
584
{
727
657
  pack_info(protocol);
728
658
  return protocol->write();
729
659
}
730
 
#endif /* HAVE_REPLICATION */
731
660
 
732
661
 
733
662
/**
899
828
    pthread_mutex_unlock(log_lock);
900
829
  return(result);
901
830
}
902
 
#endif /* !DRIZZLE_CLIENT */
903
831
 
904
 
#ifndef DRIZZLE_CLIENT
905
832
#define UNLOCK_MUTEX if (log_lock) pthread_mutex_unlock(log_lock);
906
833
#define LOCK_MUTEX if (log_lock) pthread_mutex_lock(log_lock);
907
 
#else
908
 
#define UNLOCK_MUTEX
909
 
#define LOCK_MUTEX
910
 
#endif
911
834
 
912
 
#ifndef DRIZZLE_CLIENT
913
835
/**
914
836
  @note
915
837
    Allocates memory;  The caller is responsible for clean-up.
918
840
                                     pthread_mutex_t* log_lock,
919
841
                                     const Format_description_log_event
920
842
                                     *description_event)
921
 
#else
922
 
Log_event* Log_event::read_log_event(IO_CACHE* file,
923
 
                                     const Format_description_log_event
924
 
                                     *description_event)
925
 
#endif
926
843
{
927
844
  assert(description_event != 0);
928
845
  char head[LOG_EVENT_MINIMAL_HEADER_LEN];
1102
1019
    case FORMAT_DESCRIPTION_EVENT:
1103
1020
      ev = new Format_description_log_event(buf, event_len, description_event);
1104
1021
      break;
1105
 
#if defined(HAVE_REPLICATION) 
1106
1022
    case WRITE_ROWS_EVENT:
1107
1023
      ev = new Write_rows_log_event(buf, event_len, description_event);
1108
1024
      break;
1115
1031
    case TABLE_MAP_EVENT:
1116
1032
      ev = new Table_map_log_event(buf, event_len, description_event);
1117
1033
      break;
1118
 
#endif
1119
1034
    case BEGIN_LOAD_QUERY_EVENT:
1120
1035
      ev = new Begin_load_query_log_event(buf, event_len, description_event);
1121
1036
      break;
1143
1058
  if (!ev || !ev->is_valid())
1144
1059
  {
1145
1060
    delete ev;
1146
 
#ifdef DRIZZLE_CLIENT
1147
 
    if (!force_opt) /* then mysqlbinlog dies */
1148
 
    {
1149
 
      *error= "Found invalid event in binary log";
1150
 
      return(0);
1151
 
    }
1152
 
    ev= new Unknown_log_event(buf, description_event);
1153
 
#else
1154
1061
    *error= "Found invalid event in binary log";
1155
1062
    return(0);
1156
 
#endif
1157
1063
  }
1158
1064
  return(ev);  
1159
1065
}
1160
1066
 
1161
 
#ifdef DRIZZLE_CLIENT
1162
 
 
1163
 
/*
1164
 
  Log_event::print_header()
1165
 
*/
1166
 
 
1167
 
void Log_event::print_header(IO_CACHE* file,
1168
 
                             PRINT_EVENT_INFO* print_event_info,
1169
 
                             bool is_more __attribute__((unused)))
1170
 
{
1171
 
  char llbuff[22];
1172
 
  my_off_t hexdump_from= print_event_info->hexdump_from;
1173
 
 
1174
 
  my_b_printf(file, "#");
1175
 
  print_timestamp(file);
1176
 
  my_b_printf(file, " server id %d  end_log_pos %s ", server_id,
1177
 
              llstr(log_pos,llbuff));
1178
 
 
1179
 
  /* mysqlbinlog --hexdump */
1180
 
  if (print_event_info->hexdump_from)
1181
 
  {
1182
 
    my_b_printf(file, "\n");
1183
 
    uchar *ptr= (uchar*)temp_buf;
1184
 
    my_off_t size=
1185
 
      uint4korr(ptr + EVENT_LEN_OFFSET) - LOG_EVENT_MINIMAL_HEADER_LEN;
1186
 
    my_off_t i;
1187
 
 
1188
 
    /* Header len * 4 >= header len * (2 chars + space + extra space) */
1189
 
    char *h, hex_string[LOG_EVENT_MINIMAL_HEADER_LEN*4]= {0};
1190
 
    char *c, char_string[16+1]= {0};
1191
 
 
1192
 
    /* Pretty-print event common header if header is exactly 19 bytes */
1193
 
    if (print_event_info->common_header_len == LOG_EVENT_MINIMAL_HEADER_LEN)
1194
 
    {
1195
 
      char emit_buf[256];               // Enough for storing one line
1196
 
      my_b_printf(file, "# Position  Timestamp   Type   Master ID        "
1197
 
                  "Size      Master Pos    Flags \n");
1198
 
      int const bytes_written=
1199
 
        snprintf(emit_buf, sizeof(emit_buf),
1200
 
                 "# %8.8lx %02x %02x %02x %02x   %02x   "
1201
 
                 "%02x %02x %02x %02x   %02x %02x %02x %02x   "
1202
 
                 "%02x %02x %02x %02x   %02x %02x\n",
1203
 
                 (unsigned long) hexdump_from,
1204
 
                 ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6],
1205
 
                 ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13],
1206
 
                 ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]);
1207
 
      assert(bytes_written >= 0);
1208
 
      assert(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1209
 
      my_b_write(file, (uchar*) emit_buf, bytes_written);
1210
 
      ptr += LOG_EVENT_MINIMAL_HEADER_LEN;
1211
 
      hexdump_from += LOG_EVENT_MINIMAL_HEADER_LEN;
1212
 
    }
1213
 
 
1214
 
    /* Rest of event (without common header) */
1215
 
    for (i= 0, c= char_string, h=hex_string;
1216
 
         i < size;
1217
 
         i++, ptr++)
1218
 
    {
1219
 
      snprintf(h, 4, "%02x ", *ptr);
1220
 
      h += 3;
1221
 
 
1222
 
      *c++= my_isalnum(&my_charset_bin, *ptr) ? *ptr : '.';
1223
 
 
1224
 
      if (i % 16 == 15)
1225
 
      {
1226
 
        /*
1227
 
          my_b_printf() does not support full printf() formats, so we
1228
 
          have to do it this way.
1229
 
 
1230
 
          TODO: Rewrite my_b_printf() to support full printf() syntax.
1231
 
         */
1232
 
        char emit_buf[256];
1233
 
        int const bytes_written=
1234
 
          snprintf(emit_buf, sizeof(emit_buf),
1235
 
                   "# %8.8lx %-48.48s |%16s|\n",
1236
 
                   (unsigned long) (hexdump_from + (i & 0xfffffff0)),
1237
 
                   hex_string, char_string);
1238
 
        assert(bytes_written >= 0);
1239
 
        assert(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1240
 
        my_b_write(file, (uchar*) emit_buf, bytes_written);
1241
 
        hex_string[0]= 0;
1242
 
        char_string[0]= 0;
1243
 
        c= char_string;
1244
 
        h= hex_string;
1245
 
      }
1246
 
      else if (i % 8 == 7) *h++ = ' ';
1247
 
    }
1248
 
    *c= '\0';
1249
 
 
1250
 
    if (hex_string[0])
1251
 
    {
1252
 
      char emit_buf[256];
1253
 
      int const bytes_written=
1254
 
        snprintf(emit_buf, sizeof(emit_buf),
1255
 
                    "# %8.8lx %-48.48s |%s|\n",
1256
 
                    (unsigned long) (hexdump_from + (i & 0xfffffff0)),
1257
 
                    hex_string, char_string);
1258
 
      assert(bytes_written >= 0);
1259
 
      assert(static_cast<size_t>(bytes_written) < sizeof(emit_buf));
1260
 
      my_b_write(file, (uchar*) emit_buf, bytes_written);
1261
 
    }
1262
 
    /*
1263
 
      need a # to prefix the rest of printouts for example those of
1264
 
      Rows_log_event::print_helper().
1265
 
    */
1266
 
    my_b_write(file, reinterpret_cast<const uchar*>("# "), 2);
1267
 
  }
1268
 
  return;
1269
 
}
1270
 
 
1271
 
 
1272
 
void Log_event::print_base64(IO_CACHE* file,
1273
 
                             PRINT_EVENT_INFO* print_event_info,
1274
 
                             bool more)
1275
 
{
1276
 
  const uchar *ptr= (const uchar *)temp_buf;
1277
 
  uint32_t size= uint4korr(ptr + EVENT_LEN_OFFSET);
1278
 
 
1279
 
  size_t const tmp_str_sz= base64_needed_encoded_length((int) size);
1280
 
  char *const tmp_str= (char *) my_malloc(tmp_str_sz, MYF(MY_WME));
1281
 
  if (!tmp_str) {
1282
 
    fprintf(stderr, "\nError: Out of memory. "
1283
 
            "Could not print correct binlog event.\n");
1284
 
    return;
1285
 
  }
1286
 
 
1287
 
  if (base64_encode(ptr, (size_t) size, tmp_str))
1288
 
  {
1289
 
    assert(0);
1290
 
  }
1291
 
 
1292
 
  if (my_b_tell(file) == 0)
1293
 
    my_b_printf(file, "\nBINLOG '\n");
1294
 
 
1295
 
  my_b_printf(file, "%s\n", tmp_str);
1296
 
 
1297
 
  if (!more)
1298
 
    my_b_printf(file, "'%s\n", print_event_info->delimiter);
1299
 
 
1300
 
  my_free(tmp_str, MYF(0));
1301
 
  return;
1302
 
}
1303
 
 
1304
 
 
1305
 
/*
1306
 
  Log_event::print_timestamp()
1307
 
*/
1308
 
 
1309
 
void Log_event::print_timestamp(IO_CACHE* file, time_t* ts)
1310
 
{
1311
 
  struct tm *res;
1312
 
  if (!ts)
1313
 
    ts = &when;
1314
 
#ifdef DRIZZLE_SERVER                           // This is always false
1315
 
  struct tm tm_tmp;
1316
 
  localtime_r(ts,(res= &tm_tmp));
1317
 
#else
1318
 
  res=localtime(ts);
1319
 
#endif
1320
 
 
1321
 
  my_b_printf(file,"%02d%02d%02d %2d:%02d:%02d",
1322
 
              res->tm_year % 100,
1323
 
              res->tm_mon+1,
1324
 
              res->tm_mday,
1325
 
              res->tm_hour,
1326
 
              res->tm_min,
1327
 
              res->tm_sec);
1328
 
  return;
1329
 
}
1330
 
 
1331
 
#endif /* DRIZZLE_CLIENT */
1332
 
 
1333
 
 
1334
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
1335
1067
inline Log_event::enum_skip_reason
1336
1068
Log_event::continue_group(Relay_log_info *rli)
1337
1069
{
1339
1071
    return Log_event::EVENT_SKIP_IGNORE;
1340
1072
  return Log_event::do_shall_skip(rli);
1341
1073
}
1342
 
#endif
1343
1074
 
1344
1075
/**************************************************************************
1345
1076
        Query_log_event methods
1346
1077
**************************************************************************/
1347
1078
 
1348
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
1349
 
 
1350
1079
/**
1351
1080
  This (which is used only for SHOW BINLOG EVENTS) could be updated to
1352
1081
  print SET @@session_var=. But this is not urgent, as SHOW BINLOG EVENTS is
1378
1107
  protocol->store(buf, pos-buf, &my_charset_bin);
1379
1108
  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
1380
1109
}
1381
 
#endif
1382
1110
 
1383
 
#ifndef DRIZZLE_CLIENT
1384
1111
 
1385
1112
/**
1386
1113
  Utility function for the next method (Query_log_event::write()) .
1675
1402
  else
1676
1403
    time_zone_len= 0;
1677
1404
}
1678
 
#endif /* DRIZZLE_CLIENT */
1679
1405
 
1680
1406
 
1681
1407
/* 2 utility functions for the next method */
1935
1661
}
1936
1662
 
1937
1663
 
1938
 
#ifdef DRIZZLE_CLIENT
1939
 
/**
1940
 
  Query_log_event::print().
1941
 
 
1942
 
  @todo
1943
 
    print the catalog ??
1944
 
*/
1945
 
void Query_log_event::print_query_header(IO_CACHE* file,
1946
 
                                         PRINT_EVENT_INFO* print_event_info)
1947
 
{
1948
 
  // TODO: print the catalog ??
1949
 
  char buff[40],*end;                           // Enough for SET TIMESTAMP
1950
 
  bool different_db= 1;
1951
 
  uint32_t tmp;
1952
 
 
1953
 
  if (!print_event_info->short_form)
1954
 
  {
1955
 
    print_header(file, print_event_info, false);
1956
 
    my_b_printf(file, "\t%s\tthread_id=%lu\texec_time=%lu\terror_code=%d\n",
1957
 
                get_type_str(), (ulong) thread_id, (ulong) exec_time,
1958
 
                error_code);
1959
 
  }
1960
 
 
1961
 
  if (!(flags & LOG_EVENT_SUPPRESS_USE_F) && db)
1962
 
  {
1963
 
    if ((different_db= memcmp(print_event_info->db, db, db_len + 1)))
1964
 
      memcpy(print_event_info->db, db, db_len + 1);
1965
 
    if (db[0] && different_db) 
1966
 
      my_b_printf(file, "use %s%s\n", db, print_event_info->delimiter);
1967
 
  }
1968
 
 
1969
 
  end=int10_to_str((long) when, my_stpcpy(buff,"SET TIMESTAMP="),10);
1970
 
  end= my_stpcpy(end, print_event_info->delimiter);
1971
 
  *end++='\n';
1972
 
  my_b_write(file, (uchar*) buff, (uint) (end-buff));
1973
 
  if ((!print_event_info->thread_id_printed ||
1974
 
       ((flags & LOG_EVENT_THREAD_SPECIFIC_F) &&
1975
 
        thread_id != print_event_info->thread_id)))
1976
 
  {
1977
 
    // If --short-form, print deterministic value instead of pseudo_thread_id.
1978
 
    my_b_printf(file,"SET @@session.pseudo_thread_id=%lu%s\n",
1979
 
                short_form ? 999999999 : (ulong)thread_id,
1980
 
                print_event_info->delimiter);
1981
 
    print_event_info->thread_id= thread_id;
1982
 
    print_event_info->thread_id_printed= 1;
1983
 
  }
1984
 
 
1985
 
  /*
1986
 
    If flags2_inited==0, this is an event from 3.23 or 4.0; nothing to
1987
 
    print (remember we don't produce mixed relay logs so there cannot be
1988
 
    5.0 events before that one so there is nothing to reset).
1989
 
  */
1990
 
  if (likely(flags2_inited)) /* likely as this will mainly read 5.0 logs */
1991
 
  {
1992
 
    /* tmp is a bitmask of bits which have changed. */
1993
 
    if (likely(print_event_info->flags2_inited)) 
1994
 
      /* All bits which have changed */
1995
 
      tmp= (print_event_info->flags2) ^ flags2;
1996
 
    else /* that's the first Query event we read */
1997
 
    {
1998
 
      print_event_info->flags2_inited= 1;
1999
 
      tmp= ~((uint32_t)0); /* all bits have changed */
2000
 
    }
2001
 
 
2002
 
    if (unlikely(tmp)) /* some bits have changed */
2003
 
    {
2004
 
      bool need_comma= 0;
2005
 
      my_b_printf(file, "SET ");
2006
 
      print_set_option(file, tmp, OPTION_NO_FOREIGN_KEY_CHECKS, ~flags2,
2007
 
                   "@@session.foreign_key_checks", &need_comma);
2008
 
      print_set_option(file, tmp, OPTION_RELAXED_UNIQUE_CHECKS, ~flags2,
2009
 
                   "@@session.unique_checks", &need_comma);
2010
 
      my_b_printf(file,"%s\n", print_event_info->delimiter);
2011
 
      print_event_info->flags2= flags2;
2012
 
    }
2013
 
  }
2014
 
 
2015
 
  /*
2016
 
    Now the session variables;
2017
 
    it's more efficient to pass SQL_MODE as a number instead of a
2018
 
    comma-separated list.
2019
 
    FOREIGN_KEY_CHECKS, SQL_AUTO_IS_NULL, UNIQUE_CHECKS are session-only
2020
 
    variables (they have no global version; they're not listed in
2021
 
    sql_class.h), The tests below work for pure binlogs or pure relay
2022
 
    logs. Won't work for mixed relay logs but we don't create mixed
2023
 
    relay logs (that is, there is no relay log with a format change
2024
 
    except within the 3 first events, which mysqlbinlog handles
2025
 
    gracefully). So this code should always be good.
2026
 
  */
2027
 
 
2028
 
  if (print_event_info->auto_increment_increment != auto_increment_increment ||
2029
 
      print_event_info->auto_increment_offset != auto_increment_offset)
2030
 
  {
2031
 
    my_b_printf(file,"SET @@session.auto_increment_increment=%lu, @@session.auto_increment_offset=%lu%s\n",
2032
 
                auto_increment_increment,auto_increment_offset,
2033
 
                print_event_info->delimiter);
2034
 
    print_event_info->auto_increment_increment= auto_increment_increment;
2035
 
    print_event_info->auto_increment_offset=    auto_increment_offset;
2036
 
  }
2037
 
 
2038
 
  /* TODO: print the catalog when we feature SET CATALOG */
2039
 
 
2040
 
  if (likely(charset_inited) &&
2041
 
      (unlikely(!print_event_info->charset_inited ||
2042
 
                memcmp(print_event_info->charset, charset, 6))))
2043
 
  {
2044
 
    const CHARSET_INFO * const cs_info= get_charset(uint2korr(charset), MYF(MY_WME));
2045
 
    if (cs_info)
2046
 
    {
2047
 
      /* for mysql client */
2048
 
      my_b_printf(file, "/*!\\C %s */%s\n",
2049
 
                  cs_info->csname, print_event_info->delimiter);
2050
 
    }
2051
 
    my_b_printf(file,"SET "
2052
 
                "@@session.character_set_client=%d,"
2053
 
                "@@session.collation_connection=%d,"
2054
 
                "@@session.collation_server=%d"
2055
 
                "%s\n",
2056
 
                uint2korr(charset),
2057
 
                uint2korr(charset+2),
2058
 
                uint2korr(charset+4),
2059
 
                print_event_info->delimiter);
2060
 
    memcpy(print_event_info->charset, charset, 6);
2061
 
    print_event_info->charset_inited= 1;
2062
 
  }
2063
 
  if (time_zone_len)
2064
 
  {
2065
 
    if (memcmp(print_event_info->time_zone_str, time_zone_str, time_zone_len+1))
2066
 
    {
2067
 
      my_b_printf(file,"SET @@session.time_zone='%s'%s\n",
2068
 
                  time_zone_str, print_event_info->delimiter);
2069
 
      memcpy(print_event_info->time_zone_str, time_zone_str, time_zone_len+1);
2070
 
    }
2071
 
  }
2072
 
  if (lc_time_names_number != print_event_info->lc_time_names_number)
2073
 
  {
2074
 
    my_b_printf(file, "SET @@session.lc_time_names=%d%s\n",
2075
 
                lc_time_names_number, print_event_info->delimiter);
2076
 
    print_event_info->lc_time_names_number= lc_time_names_number;
2077
 
  }
2078
 
  if (charset_database_number != print_event_info->charset_database_number)
2079
 
  {
2080
 
    if (charset_database_number)
2081
 
      my_b_printf(file, "SET @@session.collation_database=%d%s\n",
2082
 
                  charset_database_number, print_event_info->delimiter);
2083
 
    else
2084
 
      my_b_printf(file, "SET @@session.collation_database=DEFAULT%s\n",
2085
 
                  print_event_info->delimiter);
2086
 
    print_event_info->charset_database_number= charset_database_number;
2087
 
  }
2088
 
}
2089
 
 
2090
 
 
2091
 
void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
2092
 
{
2093
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
2094
 
 
2095
 
  print_query_header(&cache, print_event_info);
2096
 
  my_b_write(&cache, (uchar*) query, q_len);
2097
 
  my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
2098
 
}
2099
 
#endif /* DRIZZLE_CLIENT */
2100
 
 
2101
 
 
2102
1664
/*
2103
1665
  Query_log_event::do_apply_event()
2104
1666
*/
2105
 
 
2106
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
2107
 
 
2108
1667
int Query_log_event::do_apply_event(Relay_log_info const *rli)
2109
1668
{
2110
1669
  return do_apply_event(rli, query, q_len);
2429
1988
  return(Log_event::do_shall_skip(rli));
2430
1989
}
2431
1990
 
2432
 
#endif
2433
 
 
2434
1991
 
2435
1992
/**************************************************************************
2436
1993
        Start_log_event_v3 methods
2437
1994
**************************************************************************/
2438
1995
 
2439
 
#ifndef DRIZZLE_CLIENT
2440
1996
Start_log_event_v3::Start_log_event_v3()
2441
1997
  :Log_event(), created(0), binlog_version(BINLOG_VERSION),
2442
1998
   artificial_event(0), dont_set_created(0)
2443
1999
{
2444
2000
  memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
2445
2001
}
2446
 
#endif
2447
2002
 
2448
2003
/*
2449
2004
  Start_log_event_v3::pack_info()
2450
2005
*/
2451
2006
 
2452
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
2453
2007
void Start_log_event_v3::pack_info(Protocol *protocol)
2454
2008
{
2455
2009
  char buf[12 + ST_SERVER_VER_LEN + 14 + 22], *pos;
2459
2013
  pos= int10_to_str(binlog_version, pos, 10);
2460
2014
  protocol->store(buf, (uint) (pos-buf), &my_charset_bin);
2461
2015
}
2462
 
#endif
2463
 
 
2464
 
 
2465
 
/*
2466
 
  Start_log_event_v3::print()
2467
 
*/
2468
 
 
2469
 
#ifdef DRIZZLE_CLIENT
2470
 
void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
2471
 
{
2472
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
2473
 
                               Write_on_release_cache::FLUSH_F);
2474
 
 
2475
 
  if (!print_event_info->short_form)
2476
 
  {
2477
 
    print_header(&cache, print_event_info, false);
2478
 
    my_b_printf(&cache, "\tStart: binlog v %d, server v %s created ",
2479
 
                binlog_version, server_version);
2480
 
    print_timestamp(&cache);
2481
 
    if (created)
2482
 
      my_b_printf(&cache," at startup");
2483
 
    my_b_printf(&cache, "\n");
2484
 
    if (flags & LOG_EVENT_BINLOG_IN_USE_F)
2485
 
      my_b_printf(&cache, "# Warning: this binlog was not closed properly. "
2486
 
                  "Most probably mysqld crashed writing it.\n");
2487
 
  }
2488
 
  if (!artificial_event && created)
2489
 
  {
2490
 
#ifdef WHEN_WE_HAVE_THE_RESET_CONNECTION_SQL_COMMAND
2491
 
    /*
2492
 
      This is for mysqlbinlog: like in replication, we want to delete the stale
2493
 
      tmp files left by an unclean shutdown of mysqld (temporary tables)
2494
 
      and rollback unfinished transaction.
2495
 
      Probably this can be done with RESET CONNECTION (syntax to be defined).
2496
 
    */
2497
 
    my_b_printf(&cache,"RESET CONNECTION%s\n", print_event_info->delimiter);
2498
 
#else
2499
 
    my_b_printf(&cache,"ROLLBACK%s\n", print_event_info->delimiter);
2500
 
#endif
2501
 
  }
2502
 
  if (temp_buf &&
2503
 
      print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER &&
2504
 
      !print_event_info->short_form)
2505
 
  {
2506
 
    my_b_printf(&cache, "BINLOG '\n");
2507
 
    print_base64(&cache, print_event_info, false);
2508
 
    print_event_info->printed_fd_event= true;
2509
 
  }
2510
 
  return;
2511
 
}
2512
 
#endif /* DRIZZLE_CLIENT */
 
2016
 
2513
2017
 
2514
2018
/*
2515
2019
  Start_log_event_v3::Start_log_event_v3()
2537
2041
  Start_log_event_v3::write()
2538
2042
*/
2539
2043
 
2540
 
#ifndef DRIZZLE_CLIENT
2541
2044
bool Start_log_event_v3::write(IO_CACHE* file)
2542
2045
{
2543
2046
  char buff[START_V3_HEADER_LEN];
2549
2052
  return (write_header(file, sizeof(buff)) ||
2550
2053
          my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
2551
2054
}
2552
 
#endif
2553
 
 
2554
 
 
2555
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
2055
 
2556
2056
 
2557
2057
/**
2558
2058
  Start_log_event_v3::do_apply_event() .
2617
2117
  }
2618
2118
  return(0);
2619
2119
}
2620
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
2621
2120
 
2622
2121
/***************************************************************************
2623
2122
       Format_description_log_event methods
2869
2368
  return;
2870
2369
}
2871
2370
 
2872
 
#ifndef DRIZZLE_CLIENT
2873
2371
bool Format_description_log_event::write(IO_CACHE* file)
2874
2372
{
2875
2373
  /*
2888
2386
  return (write_header(file, sizeof(buff)) ||
2889
2387
          my_b_safe_write(file, buff, sizeof(buff)));
2890
2388
}
2891
 
#endif
2892
 
 
2893
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
2389
 
 
2390
 
2894
2391
int Format_description_log_event::do_apply_event(Relay_log_info const *rli)
2895
2392
{
2896
2393
  /*
2971
2468
  return Log_event::EVENT_SKIP_NOT;
2972
2469
}
2973
2470
 
2974
 
#endif
2975
 
 
2976
2471
 
2977
2472
/**
2978
2473
   Splits the event's 'server_version' string into three numeric pieces stored
3021
2516
  Load_log_event::pack_info()
3022
2517
*/
3023
2518
 
3024
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
3025
2519
uint Load_log_event::get_query_buffer_length()
3026
2520
{
3027
2521
  return
3136
2630
  protocol->store(buf, end-buf, &my_charset_bin);
3137
2631
  my_free(buf, MYF(0));
3138
2632
}
3139
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
3140
 
 
3141
 
 
3142
 
#ifndef DRIZZLE_CLIENT
 
2633
 
3143
2634
 
3144
2635
/*
3145
2636
  Load_log_event::write_data_header()
3264
2755
  field_lens = (const uchar*)field_lens_buf.ptr();
3265
2756
  fields = fields_buf.ptr();
3266
2757
}
3267
 
#endif /* !DRIZZLE_CLIENT */
3268
2758
 
3269
2759
 
3270
2760
/**
3341
2831
}
3342
2832
 
3343
2833
 
3344
 
/*
3345
 
  Load_log_event::print()
3346
 
*/
3347
 
 
3348
 
#ifdef DRIZZLE_CLIENT
3349
 
void Load_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
3350
 
{
3351
 
  print(file, print_event_info, 0);
3352
 
}
3353
 
 
3354
 
 
3355
 
void Load_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info,
3356
 
                           bool commented)
3357
 
{
3358
 
  Write_on_release_cache cache(&print_event_info->head_cache, file_arg);
3359
 
 
3360
 
  if (!print_event_info->short_form)
3361
 
  {
3362
 
    print_header(&cache, print_event_info, false);
3363
 
    my_b_printf(&cache, "\tQuery\tthread_id=%ld\texec_time=%ld\n",
3364
 
                thread_id, exec_time);
3365
 
  }
3366
 
 
3367
 
  bool different_db= 1;
3368
 
  if (db)
3369
 
  {
3370
 
    /*
3371
 
      If the database is different from the one of the previous statement, we
3372
 
      need to print the "use" command, and we update the last_db.
3373
 
      But if commented, the "use" is going to be commented so we should not
3374
 
      update the last_db.
3375
 
    */
3376
 
    if ((different_db= memcmp(print_event_info->db, db, db_len + 1)) &&
3377
 
        !commented)
3378
 
      memcpy(print_event_info->db, db, db_len + 1);
3379
 
  }
3380
 
  
3381
 
  if (db && db[0] && different_db)
3382
 
    my_b_printf(&cache, "%suse %s%s\n", 
3383
 
            commented ? "# " : "",
3384
 
            db, print_event_info->delimiter);
3385
 
 
3386
 
  if (flags & LOG_EVENT_THREAD_SPECIFIC_F)
3387
 
    my_b_printf(&cache,"%sSET @@session.pseudo_thread_id=%lu%s\n",
3388
 
            commented ? "# " : "", (ulong)thread_id,
3389
 
            print_event_info->delimiter);
3390
 
  my_b_printf(&cache, "%sLOAD DATA ",
3391
 
              commented ? "# " : "");
3392
 
  if (check_fname_outside_temp_buf())
3393
 
    my_b_printf(&cache, "LOCAL ");
3394
 
  my_b_printf(&cache, "INFILE '%-*s' ", fname_len, fname);
3395
 
 
3396
 
  if (sql_ex.opt_flags & REPLACE_FLAG)
3397
 
    my_b_printf(&cache," REPLACE ");
3398
 
  else if (sql_ex.opt_flags & IGNORE_FLAG)
3399
 
    my_b_printf(&cache," IGNORE ");
3400
 
  
3401
 
  my_b_printf(&cache, "INTO Table `%s`", table_name);
3402
 
  my_b_printf(&cache, " FIELDS TERMINATED BY ");
3403
 
  pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
3404
 
 
3405
 
  if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG)
3406
 
    my_b_printf(&cache," OPTIONALLY ");
3407
 
  my_b_printf(&cache, " ENCLOSED BY ");
3408
 
  pretty_print_str(&cache, sql_ex.enclosed, sql_ex.enclosed_len);
3409
 
     
3410
 
  my_b_printf(&cache, " ESCAPED BY ");
3411
 
  pretty_print_str(&cache, sql_ex.escaped, sql_ex.escaped_len);
3412
 
     
3413
 
  my_b_printf(&cache," LINES TERMINATED BY ");
3414
 
  pretty_print_str(&cache, sql_ex.line_term, sql_ex.line_term_len);
3415
 
 
3416
 
 
3417
 
  if (sql_ex.line_start)
3418
 
  {
3419
 
    my_b_printf(&cache," STARTING BY ");
3420
 
    pretty_print_str(&cache, sql_ex.line_start, sql_ex.line_start_len);
3421
 
  }
3422
 
  if ((long) skip_lines > 0)
3423
 
    my_b_printf(&cache, " IGNORE %ld LINES", (long) skip_lines);
3424
 
 
3425
 
  if (num_fields)
3426
 
  {
3427
 
    uint i;
3428
 
    const char* field = fields;
3429
 
    my_b_printf(&cache, " (");
3430
 
    for (i = 0; i < num_fields; i++)
3431
 
    {
3432
 
      if (i)
3433
 
        my_b_printf(&cache, ",");
3434
 
      my_b_printf(&cache, field);
3435
 
          
3436
 
      field += field_lens[i]  + 1;
3437
 
    }
3438
 
    my_b_printf(&cache, ")");
3439
 
  }
3440
 
 
3441
 
  my_b_printf(&cache, "%s\n", print_event_info->delimiter);
3442
 
  return;
3443
 
}
3444
 
#endif /* DRIZZLE_CLIENT */
3445
 
 
3446
 
#ifndef DRIZZLE_CLIENT
3447
 
 
3448
2834
/**
3449
2835
  Load_log_event::set_fields()
3450
2836
 
3468
2854
    field+= field_lens[i]  + 1;
3469
2855
  }
3470
2856
}
3471
 
#endif /* !DRIZZLE_CLIENT */
3472
 
 
3473
 
 
3474
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
2857
 
 
2858
 
3475
2859
/**
3476
2860
  Does the data loading job when executing a LOAD DATA on the slave.
3477
2861
 
3761
3145
 
3762
3146
  return ( use_rli_only_for_errors ? 0 : Log_event::do_apply_event(rli) );
3763
3147
}
3764
 
#endif
3765
3148
 
3766
3149
 
3767
3150
/**************************************************************************
3772
3155
  Rotate_log_event::pack_info()
3773
3156
*/
3774
3157
 
3775
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
3776
3158
void Rotate_log_event::pack_info(Protocol *protocol)
3777
3159
{
3778
3160
  char buf1[256], buf[22];
3783
3165
  tmp.append(llstr(pos,buf));
3784
3166
  protocol->store(tmp.ptr(), tmp.length(), &my_charset_bin);
3785
3167
}
3786
 
#endif
3787
 
 
3788
 
 
3789
 
/*
3790
 
  Rotate_log_event::print()
3791
 
*/
3792
 
 
3793
 
#ifdef DRIZZLE_CLIENT
3794
 
void Rotate_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
3795
 
{
3796
 
  char buf[22];
3797
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
3798
 
                               Write_on_release_cache::FLUSH_F);
3799
 
 
3800
 
  if (print_event_info->short_form)
3801
 
    return;
3802
 
  print_header(&cache, print_event_info, false);
3803
 
  my_b_printf(&cache, "\tRotate to ");
3804
 
  if (new_log_ident)
3805
 
    my_b_write(&cache, (uchar*) new_log_ident, (uint)ident_len);
3806
 
  my_b_printf(&cache, "  pos: %s\n", llstr(pos, buf));
3807
 
}
3808
 
#endif /* DRIZZLE_CLIENT */
3809
 
 
3810
3168
 
3811
3169
 
3812
3170
/*
3814
3172
*/
3815
3173
 
3816
3174
 
3817
 
#ifndef DRIZZLE_CLIENT
3818
3175
Rotate_log_event::Rotate_log_event(const char* new_log_ident_arg,
3819
3176
                                   uint ident_len_arg, uint64_t pos_arg,
3820
3177
                                   uint flags_arg)
3826
3183
    new_log_ident= my_strndup(new_log_ident_arg, ident_len, MYF(MY_WME));
3827
3184
  return;
3828
3185
}
3829
 
#endif
3830
3186
 
3831
3187
 
3832
3188
Rotate_log_event::Rotate_log_event(const char* buf, uint event_len,
3854
3210
  Rotate_log_event::write()
3855
3211
*/
3856
3212
 
3857
 
#ifndef DRIZZLE_CLIENT
3858
3213
bool Rotate_log_event::write(IO_CACHE* file)
3859
3214
{
3860
3215
  char buf[ROTATE_HEADER_LEN];
3863
3218
          my_b_safe_write(file, (uchar*)buf, ROTATE_HEADER_LEN) ||
3864
3219
          my_b_safe_write(file, (uchar*)new_log_ident, (uint) ident_len));
3865
3220
}
3866
 
#endif
3867
 
 
3868
 
 
3869
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
3221
 
3870
3222
 
3871
3223
/*
3872
3224
  Got a rotate log event from the master.
3948
3300
  return Log_event::EVENT_SKIP_NOT;             // To keep compiler happy
3949
3301
}
3950
3302
 
3951
 
#endif
3952
 
 
3953
3303
 
3954
3304
/**************************************************************************
3955
3305
        Intvar_log_event methods
3959
3309
  Intvar_log_event::pack_info()
3960
3310
*/
3961
3311
 
3962
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
3963
3312
void Intvar_log_event::pack_info(Protocol *protocol)
3964
3313
{
3965
3314
  char buf[256], *pos;
3968
3317
  pos= int64_t10_to_str(val, pos, -10);
3969
3318
  protocol->store(buf, (uint) (pos-buf), &my_charset_bin);
3970
3319
}
3971
 
#endif
3972
3320
 
3973
3321
 
3974
3322
/*
4003
3351
  Intvar_log_event::write()
4004
3352
*/
4005
3353
 
4006
 
#ifndef DRIZZLE_CLIENT
4007
3354
bool Intvar_log_event::write(IO_CACHE* file)
4008
3355
{
4009
3356
  uchar buf[9];
4012
3359
  return (write_header(file, sizeof(buf)) ||
4013
3360
          my_b_safe_write(file, buf, sizeof(buf)));
4014
3361
}
4015
 
#endif
4016
3362
 
4017
3363
 
4018
3364
/*
4019
3365
  Intvar_log_event::print()
4020
3366
*/
4021
3367
 
4022
 
#ifdef DRIZZLE_CLIENT
4023
 
void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4024
 
{
4025
 
  char llbuff[22];
4026
 
  const char *msg;
4027
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
4028
 
                               Write_on_release_cache::FLUSH_F);
4029
 
 
4030
 
  if (!print_event_info->short_form)
4031
 
  {
4032
 
    print_header(&cache, print_event_info, false);
4033
 
    my_b_printf(&cache, "\tIntvar\n");
4034
 
  }
4035
 
 
4036
 
  my_b_printf(&cache, "SET ");
4037
 
  switch (type) {
4038
 
  case LAST_INSERT_ID_EVENT:
4039
 
    msg="LAST_INSERT_ID";
4040
 
    break;
4041
 
  case INSERT_ID_EVENT:
4042
 
    msg="INSERT_ID";
4043
 
    break;
4044
 
  case INVALID_INT_EVENT:
4045
 
  default: // cannot happen
4046
 
    msg="INVALID_INT";
4047
 
    break;
4048
 
  }
4049
 
  my_b_printf(&cache, "%s=%s%s\n",
4050
 
              msg, llstr(val,llbuff), print_event_info->delimiter);
4051
 
}
4052
 
#endif
4053
 
 
4054
 
 
4055
3368
/*
4056
3369
  Intvar_log_event::do_apply_event()
4057
3370
*/
4058
3371
 
4059
 
#if defined(HAVE_REPLICATION)&& !defined(DRIZZLE_CLIENT)
4060
3372
int Intvar_log_event::do_apply_event(Relay_log_info const *rli)
4061
3373
{
4062
3374
  /*
4098
3410
  return continue_group(rli);
4099
3411
}
4100
3412
 
4101
 
#endif
4102
 
 
4103
3413
 
4104
3414
/**************************************************************************
4105
3415
  Rand_log_event methods
4106
3416
**************************************************************************/
4107
3417
 
4108
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
4109
3418
void Rand_log_event::pack_info(Protocol *protocol)
4110
3419
{
4111
3420
  char buf1[256], *pos;
4115
3424
  pos= int10_to_str((long) seed2, pos, 10);
4116
3425
  protocol->store(buf1, (uint) (pos-buf1), &my_charset_bin);
4117
3426
}
4118
 
#endif
4119
3427
 
4120
3428
 
4121
3429
Rand_log_event::Rand_log_event(const char* buf,
4128
3436
}
4129
3437
 
4130
3438
 
4131
 
#ifndef DRIZZLE_CLIENT
4132
3439
bool Rand_log_event::write(IO_CACHE* file)
4133
3440
{
4134
3441
  uchar buf[16];
4137
3444
  return (write_header(file, sizeof(buf)) ||
4138
3445
          my_b_safe_write(file, buf, sizeof(buf)));
4139
3446
}
4140
 
#endif
4141
 
 
4142
 
 
4143
 
#ifdef DRIZZLE_CLIENT
4144
 
void Rand_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4145
 
{
4146
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
4147
 
                               Write_on_release_cache::FLUSH_F);
4148
 
 
4149
 
  char llbuff[22],llbuff2[22];
4150
 
  if (!print_event_info->short_form)
4151
 
  {
4152
 
    print_header(&cache, print_event_info, false);
4153
 
    my_b_printf(&cache, "\tRand\n");
4154
 
  }
4155
 
  my_b_printf(&cache, "SET @@RAND_SEED1=%s, @@RAND_SEED2=%s%s\n",
4156
 
              llstr(seed1, llbuff),llstr(seed2, llbuff2),
4157
 
              print_event_info->delimiter);
4158
 
}
4159
 
#endif /* DRIZZLE_CLIENT */
4160
 
 
4161
 
 
4162
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
3447
 
 
3448
 
4163
3449
int Rand_log_event::do_apply_event(Relay_log_info const *rli)
4164
3450
{
4165
3451
  /*
4194
3480
  return continue_group(rli);
4195
3481
}
4196
3482
 
4197
 
#endif /* !DRIZZLE_CLIENT */
4198
 
 
4199
3483
 
4200
3484
/**************************************************************************
4201
3485
  Xid_log_event methods
4202
3486
**************************************************************************/
4203
3487
 
4204
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
4205
3488
void Xid_log_event::pack_info(Protocol *protocol)
4206
3489
{
4207
3490
  char buf[128], *pos;
4210
3493
  pos= my_stpcpy(pos, " */");
4211
3494
  protocol->store(buf, (uint) (pos-buf), &my_charset_bin);
4212
3495
}
4213
 
#endif
4214
3496
 
4215
3497
/**
4216
3498
  @note
4231
3513
}
4232
3514
 
4233
3515
 
4234
 
#ifndef DRIZZLE_CLIENT
4235
3516
bool Xid_log_event::write(IO_CACHE* file)
4236
3517
{
4237
3518
  return write_header(file, sizeof(xid)) ||
4238
3519
         my_b_safe_write(file, (uchar*) &xid, sizeof(xid));
4239
3520
}
4240
 
#endif
4241
 
 
4242
 
 
4243
 
#ifdef DRIZZLE_CLIENT
4244
 
void Xid_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4245
 
{
4246
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
4247
 
                               Write_on_release_cache::FLUSH_F);
4248
 
 
4249
 
  if (!print_event_info->short_form)
4250
 
  {
4251
 
    char buf[64];
4252
 
    int64_t10_to_str(xid, buf, 10);
4253
 
 
4254
 
    print_header(&cache, print_event_info, false);
4255
 
    my_b_printf(&cache, "\tXid = %s\n", buf);
4256
 
  }
4257
 
  my_b_printf(&cache, "COMMIT%s\n", print_event_info->delimiter);
4258
 
}
4259
 
#endif /* DRIZZLE_CLIENT */
4260
 
 
4261
 
 
4262
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
3521
 
 
3522
 
4263
3523
int Xid_log_event::do_apply_event(Relay_log_info const *rli __attribute__((unused)))
4264
3524
{
4265
3525
  return end_trans(thd, COMMIT);
4274
3534
  }
4275
3535
  return(Log_event::do_shall_skip(rli));
4276
3536
}
4277
 
#endif /* !DRIZZLE_CLIENT */
4278
3537
 
4279
3538
 
4280
3539
/**************************************************************************
4281
3540
  User_var_log_event methods
4282
3541
**************************************************************************/
4283
3542
 
4284
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
4285
3543
void User_var_log_event::pack_info(Protocol* protocol)
4286
3544
{
4287
3545
  char *buf= 0;
4359
3617
  protocol->store(buf, event_len, &my_charset_bin);
4360
3618
  my_free(buf, MYF(0));
4361
3619
}
4362
 
#endif /* !DRIZZLE_CLIENT */
4363
3620
 
4364
3621
 
4365
3622
User_var_log_event::
4391
3648
}
4392
3649
 
4393
3650
 
4394
 
#ifndef DRIZZLE_CLIENT
4395
3651
bool User_var_log_event::write(IO_CACHE* file)
4396
3652
{
4397
3653
  char buf[UV_NAME_LEN_SIZE];
4451
3707
          my_b_safe_write(file, (uchar*) buf1, buf1_length) ||
4452
3708
          my_b_safe_write(file, pos, val_len));
4453
3709
}
4454
 
#endif
4455
 
 
4456
 
 
4457
 
/*
4458
 
  User_var_log_event::print()
4459
 
*/
4460
 
 
4461
 
#ifdef DRIZZLE_CLIENT
4462
 
void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4463
 
{
4464
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
4465
 
                               Write_on_release_cache::FLUSH_F);
4466
 
 
4467
 
  if (!print_event_info->short_form)
4468
 
  {
4469
 
    print_header(&cache, print_event_info, false);
4470
 
    my_b_printf(&cache, "\tUser_var\n");
4471
 
  }
4472
 
 
4473
 
  my_b_printf(&cache, "SET @`");
4474
 
  my_b_write(&cache, (uchar*) name, (uint) (name_len));
4475
 
  my_b_printf(&cache, "`");
4476
 
 
4477
 
  if (is_null)
4478
 
  {
4479
 
    my_b_printf(&cache, ":=NULL%s\n", print_event_info->delimiter);
4480
 
  }
4481
 
  else
4482
 
  {
4483
 
    switch (type) {
4484
 
    case REAL_RESULT:
4485
 
      double real_val;
4486
 
      char real_buf[FMT_G_BUFSIZE(14)];
4487
 
      float8get(real_val, val);
4488
 
      sprintf(real_buf, "%.14g", real_val);
4489
 
      my_b_printf(&cache, ":=%s%s\n", real_buf, print_event_info->delimiter);
4490
 
      break;
4491
 
    case INT_RESULT:
4492
 
      char int_buf[22];
4493
 
      int64_t10_to_str(uint8korr(val), int_buf, -10);
4494
 
      my_b_printf(&cache, ":=%s%s\n", int_buf, print_event_info->delimiter);
4495
 
      break;
4496
 
    case DECIMAL_RESULT:
4497
 
    {
4498
 
      char str_buf[200];
4499
 
      int str_len= sizeof(str_buf) - 1;
4500
 
      int precision= (int)val[0];
4501
 
      int scale= (int)val[1];
4502
 
      decimal_digit_t dec_buf[10];
4503
 
      decimal_t dec;
4504
 
      dec.len= 10;
4505
 
      dec.buf= dec_buf;
4506
 
 
4507
 
      bin2decimal((uchar*) val+2, &dec, precision, scale);
4508
 
      decimal2string(&dec, str_buf, &str_len, 0, 0, 0);
4509
 
      str_buf[str_len]= 0;
4510
 
      my_b_printf(&cache, ":=%s%s\n", str_buf, print_event_info->delimiter);
4511
 
      break;
4512
 
    }
4513
 
    case STRING_RESULT:
4514
 
    {
4515
 
      /*
4516
 
        Let's express the string in hex. That's the most robust way. If we
4517
 
        print it in character form instead, we need to escape it with
4518
 
        character_set_client which we don't know (we will know it in 5.0, but
4519
 
        in 4.1 we don't know it easily when we are printing
4520
 
        User_var_log_event). Explanation why we would need to bother with
4521
 
        character_set_client (quoting Bar):
4522
 
        > Note, the parser doesn't switch to another unescaping mode after
4523
 
        > it has met a character set introducer.
4524
 
        > For example, if an SJIS client says something like:
4525
 
        > SET @a= _ucs2 \0a\0b'
4526
 
        > the string constant is still unescaped according to SJIS, not
4527
 
        > according to UCS2.
4528
 
      */
4529
 
      char *hex_str;
4530
 
      const CHARSET_INFO *cs;
4531
 
 
4532
 
      if (!(hex_str= (char *)my_alloca(2*val_len+1+2))) // 2 hex digits / byte
4533
 
        break; // no error, as we are 'void'
4534
 
      str_to_hex(hex_str, val, val_len);
4535
 
      /*
4536
 
        For proper behaviour when mysqlbinlog|mysql, we need to explicitely
4537
 
        specify the variable's collation. It will however cause problems when
4538
 
        people want to mysqlbinlog|mysql into another server not supporting the
4539
 
        character set. But there's not much to do about this and it's unlikely.
4540
 
      */
4541
 
      if (!(cs= get_charset(charset_number, MYF(0))))
4542
 
        /*
4543
 
          Generate an unusable command (=> syntax error) is probably the best
4544
 
          thing we can do here.
4545
 
        */
4546
 
        my_b_printf(&cache, ":=???%s\n", print_event_info->delimiter);
4547
 
      else
4548
 
        my_b_printf(&cache, ":=_%s %s COLLATE `%s`%s\n",
4549
 
                    cs->csname, hex_str, cs->name,
4550
 
                    print_event_info->delimiter);
4551
 
      my_afree(hex_str);
4552
 
    }
4553
 
      break;
4554
 
    case ROW_RESULT:
4555
 
    default:
4556
 
      assert(1);
4557
 
      return;
4558
 
    }
4559
 
  }
4560
 
}
4561
 
#endif
 
3710
 
4562
3711
 
4563
3712
 
4564
3713
/*
4565
3714
  User_var_log_event::do_apply_event()
4566
3715
*/
4567
3716
 
4568
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
4569
3717
int User_var_log_event::do_apply_event(Relay_log_info const *rli)
4570
3718
{
4571
3719
  Item *it= 0;
4656
3804
  */
4657
3805
  return continue_group(rli);
4658
3806
}
4659
 
#endif /* !DRIZZLE_CLIENT */
4660
3807
 
4661
3808
 
4662
3809
/**************************************************************************
4663
3810
  Slave_log_event methods
4664
3811
**************************************************************************/
4665
3812
 
4666
 
#ifdef HAVE_REPLICATION
4667
 
#ifdef DRIZZLE_CLIENT
4668
 
void Unknown_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info)
4669
 
{
4670
 
  Write_on_release_cache cache(&print_event_info->head_cache, file_arg);
4671
 
 
4672
 
  if (print_event_info->short_form)
4673
 
    return;
4674
 
  print_header(&cache, print_event_info, false);
4675
 
  my_b_printf(&cache, "\n# %s", "Unknown event\n");
4676
 
}
4677
 
#endif  
4678
 
 
4679
 
#ifndef DRIZZLE_CLIENT
4680
3813
void Slave_log_event::pack_info(Protocol *protocol)
4681
3814
{
4682
3815
  char buf[256+HOSTNAME_LENGTH], *pos;
4690
3823
  pos= int64_t10_to_str(master_pos, pos, 10);
4691
3824
  protocol->store(buf, pos-buf, &my_charset_bin);
4692
3825
}
4693
 
#endif /* !DRIZZLE_CLIENT */
4694
 
 
4695
 
 
4696
 
#ifndef DRIZZLE_CLIENT
 
3826
 
 
3827
 
4697
3828
/**
4698
3829
  @todo
4699
3830
  re-write this better without holding both locks at the same time
4728
3859
  pthread_mutex_unlock(&mi->data_lock);
4729
3860
  return;
4730
3861
}
4731
 
#endif /* !DRIZZLE_CLIENT */
4732
3862
 
4733
3863
 
4734
3864
Slave_log_event::~Slave_log_event()
4737
3867
}
4738
3868
 
4739
3869
 
4740
 
#ifdef DRIZZLE_CLIENT
4741
 
void Slave_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4742
 
{
4743
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
4744
 
 
4745
 
  char llbuff[22];
4746
 
  if (print_event_info->short_form)
4747
 
    return;
4748
 
  print_header(&cache, print_event_info, false);
4749
 
  my_b_printf(&cache, "\n\
4750
 
Slave: master_host: '%s'  master_port: %d  master_log: '%s'  master_pos: %s\n",
4751
 
          master_host, master_port, master_log, llstr(master_pos, llbuff));
4752
 
}
4753
 
#endif /* DRIZZLE_CLIENT */
4754
 
 
4755
 
 
4756
3870
int Slave_log_event::get_data_size()
4757
3871
{
4758
3872
  return master_host_len + master_log_len + 1 + SL_MASTER_HOST_OFFSET;
4759
3873
}
4760
3874
 
4761
3875
 
4762
 
#ifndef DRIZZLE_CLIENT
4763
3876
bool Slave_log_event::write(IO_CACHE* file)
4764
3877
{
4765
3878
  ulong event_length= get_data_size();
4770
3883
  return (write_header(file, event_length) ||
4771
3884
          my_b_safe_write(file, (uchar*) mem_pool, event_length));
4772
3885
}
4773
 
#endif
4774
3886
 
4775
3887
 
4776
3888
void Slave_log_event::init_from_mem_pool(int data_size)
4805
3917
}
4806
3918
 
4807
3919
 
4808
 
#ifndef DRIZZLE_CLIENT
4809
3920
int Slave_log_event::do_apply_event(Relay_log_info const *rli __attribute__((unused)))
4810
3921
{
4811
3922
  if (mysql_bin_log.is_open())
4812
3923
    mysql_bin_log.write(this);
4813
3924
  return 0;
4814
3925
}
4815
 
#endif /* !DRIZZLE_CLIENT */
4816
3926
 
4817
3927
 
4818
3928
/**************************************************************************
4820
3930
**************************************************************************/
4821
3931
 
4822
3932
/*
4823
 
  Stop_log_event::print()
4824
 
*/
4825
 
 
4826
 
#ifdef DRIZZLE_CLIENT
4827
 
void Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
4828
 
{
4829
 
  Write_on_release_cache cache(&print_event_info->head_cache, file,
4830
 
                               Write_on_release_cache::FLUSH_F);
4831
 
 
4832
 
  if (print_event_info->short_form)
4833
 
    return;
4834
 
 
4835
 
  print_header(&cache, print_event_info, false);
4836
 
  my_b_printf(&cache, "\tStop\n");
4837
 
}
4838
 
#endif /* DRIZZLE_CLIENT */
4839
 
 
4840
 
 
4841
 
#ifndef DRIZZLE_CLIENT
4842
 
/*
4843
3933
  The master stopped.  We used to clean up all temporary tables but
4844
3934
  this is useless as, as the master has shut down properly, it has
4845
3935
  written all DROP TEMPORARY Table (prepared statements' deletion is
4869
3959
  return 0;
4870
3960
}
4871
3961
 
4872
 
#endif /* !DRIZZLE_CLIENT */
4873
 
#endif /* HAVE_REPLICATION */
4874
 
 
4875
3962
 
4876
3963
/**************************************************************************
4877
3964
        Create_file_log_event methods
4881
3968
  Create_file_log_event ctor
4882
3969
*/
4883
3970
 
4884
 
#ifndef DRIZZLE_CLIENT
4885
3971
Create_file_log_event::
4886
3972
Create_file_log_event(THD* thd_arg, sql_exchange* ex,
4887
3973
                      const char* db_arg, const char* table_name_arg,
4940
4026
  return res;
4941
4027
}
4942
4028
 
4943
 
#endif /* !DRIZZLE_CLIENT */
4944
 
 
4945
4029
/*
4946
4030
  Create_file_log_event ctor
4947
4031
*/
4997
4081
 
4998
4082
 
4999
4083
/*
5000
 
  Create_file_log_event::print()
5001
 
*/
5002
 
 
5003
 
#ifdef DRIZZLE_CLIENT
5004
 
void Create_file_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info,
5005
 
                                  bool enable_local)
5006
 
{
5007
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
5008
 
 
5009
 
  if (print_event_info->short_form)
5010
 
  {
5011
 
    if (enable_local && check_fname_outside_temp_buf())
5012
 
      Load_log_event::print(file, print_event_info);
5013
 
    return;
5014
 
  }
5015
 
 
5016
 
  if (enable_local)
5017
 
  {
5018
 
    Load_log_event::print(file, print_event_info,
5019
 
                          !check_fname_outside_temp_buf());
5020
 
    /* 
5021
 
       That one is for "file_id: etc" below: in mysqlbinlog we want the #, in
5022
 
       SHOW BINLOG EVENTS we don't.
5023
 
    */
5024
 
    my_b_printf(&cache, "#"); 
5025
 
  }
5026
 
 
5027
 
  my_b_printf(&cache, " file_id: %d  block_len: %d\n", file_id, block_len);
5028
 
}
5029
 
 
5030
 
 
5031
 
void Create_file_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
5032
 
{
5033
 
  print(file, print_event_info, 0);
5034
 
}
5035
 
#endif /* DRIZZLE_CLIENT */
5036
 
 
5037
 
 
5038
 
/*
5039
4084
  Create_file_log_event::pack_info()
5040
4085
*/
5041
4086
 
5042
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5043
4087
void Create_file_log_event::pack_info(Protocol *protocol)
5044
4088
{
5045
4089
  char buf[NAME_LEN*2 + 30 + 21*2], *pos;
5053
4097
  pos= int10_to_str((long) block_len, pos, 10);
5054
4098
  protocol->store(buf, (uint) (pos-buf), &my_charset_bin);
5055
4099
}
5056
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
5057
4100
 
5058
4101
 
5059
4102
/*
5060
4103
  Create_file_log_event::do_apply_event()
5061
4104
*/
5062
4105
 
5063
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5064
4106
int Create_file_log_event::do_apply_event(Relay_log_info const *rli)
5065
4107
{
5066
4108
  char proc_info[17+FN_REFLEN+10], *fname_buf;
5128
4170
  thd_proc_info(thd, 0);
5129
4171
  return error == 0;
5130
4172
}
5131
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
5132
4173
 
5133
4174
 
5134
4175
/**************************************************************************
5139
4180
  Append_block_log_event ctor
5140
4181
*/
5141
4182
 
5142
 
#ifndef DRIZZLE_CLIENT  
5143
4183
Append_block_log_event::Append_block_log_event(THD *thd_arg,
5144
4184
                                               const char *db_arg,
5145
4185
                                               uchar *block_arg,
5149
4189
   block_len(block_len_arg), file_id(thd_arg->file_id), db(db_arg)
5150
4190
{
5151
4191
}
5152
 
#endif
5153
4192
 
5154
4193
 
5155
4194
/*
5177
4216
  Append_block_log_event::write()
5178
4217
*/
5179
4218
 
5180
 
#ifndef DRIZZLE_CLIENT
5181
4219
bool Append_block_log_event::write(IO_CACHE* file)
5182
4220
{
5183
4221
  uchar buf[APPEND_BLOCK_HEADER_LEN];
5186
4224
          my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) ||
5187
4225
          my_b_safe_write(file, (uchar*) block, block_len));
5188
4226
}
5189
 
#endif
5190
 
 
5191
 
 
5192
 
/*
5193
 
  Append_block_log_event::print()
5194
 
*/
5195
 
 
5196
 
#ifdef DRIZZLE_CLIENT  
5197
 
void Append_block_log_event::print(FILE* file,
5198
 
                                   PRINT_EVENT_INFO* print_event_info)
5199
 
{
5200
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
5201
 
 
5202
 
  if (print_event_info->short_form)
5203
 
    return;
5204
 
  print_header(&cache, print_event_info, false);
5205
 
  my_b_printf(&cache, "\n#%s: file_id: %d  block_len: %d\n",
5206
 
              get_type_str(), file_id, block_len);
5207
 
}
5208
 
#endif /* DRIZZLE_CLIENT */
5209
4227
 
5210
4228
 
5211
4229
/*
5212
4230
  Append_block_log_event::pack_info()
5213
4231
*/
5214
4232
 
5215
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5216
4233
void Append_block_log_event::pack_info(Protocol *protocol)
5217
4234
{
5218
4235
  char buf[256];
5281
4298
  thd_proc_info(thd, 0);
5282
4299
  return(error);
5283
4300
}
5284
 
#endif
5285
4301
 
5286
4302
 
5287
4303
/**************************************************************************
5292
4308
  Delete_file_log_event ctor
5293
4309
*/
5294
4310
 
5295
 
#ifndef DRIZZLE_CLIENT
5296
4311
Delete_file_log_event::Delete_file_log_event(THD *thd_arg, const char* db_arg,
5297
4312
                                             bool using_trans)
5298
4313
  :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg)
5299
4314
{
5300
4315
}
5301
 
#endif
5302
4316
 
5303
4317
/*
5304
4318
  Delete_file_log_event ctor
5320
4334
  Delete_file_log_event::write()
5321
4335
*/
5322
4336
 
5323
 
#ifndef DRIZZLE_CLIENT
5324
4337
bool Delete_file_log_event::write(IO_CACHE* file)
5325
4338
{
5326
4339
 uchar buf[DELETE_FILE_HEADER_LEN];
5328
4341
 return (write_header(file, sizeof(buf)) ||
5329
4342
         my_b_safe_write(file, buf, sizeof(buf)));
5330
4343
}
5331
 
#endif
5332
 
 
5333
 
 
5334
 
/*
5335
 
  Delete_file_log_event::print()
5336
 
*/
5337
 
 
5338
 
#ifdef DRIZZLE_CLIENT  
5339
 
void Delete_file_log_event::print(FILE* file,
5340
 
                                  PRINT_EVENT_INFO* print_event_info)
5341
 
{
5342
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
5343
 
 
5344
 
  if (print_event_info->short_form)
5345
 
    return;
5346
 
  print_header(&cache, print_event_info, false);
5347
 
  my_b_printf(&cache, "\n#Delete_file: file_id=%u\n", file_id);
5348
 
}
5349
 
#endif /* DRIZZLE_CLIENT */
 
4344
 
5350
4345
 
5351
4346
/*
5352
4347
  Delete_file_log_event::pack_info()
5353
4348
*/
5354
4349
 
5355
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5356
4350
void Delete_file_log_event::pack_info(Protocol *protocol)
5357
4351
{
5358
4352
  char buf[64];
5360
4354
  length= (uint) sprintf(buf, ";file_id=%u", (uint) file_id);
5361
4355
  protocol->store(buf, (int32_t) length, &my_charset_bin);
5362
4356
}
5363
 
#endif
5364
4357
 
5365
4358
/*
5366
4359
  Delete_file_log_event::do_apply_event()
5367
4360
*/
5368
4361
 
5369
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5370
4362
int Delete_file_log_event::do_apply_event(Relay_log_info const *rli __attribute__((unused)))
5371
4363
{
5372
4364
  char fname[FN_REFLEN+10];
5376
4368
  (void) my_delete(fname, MYF(MY_WME));
5377
4369
  return 0;
5378
4370
}
5379
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
5380
4371
 
5381
4372
 
5382
4373
/**************************************************************************
5387
4378
  Execute_load_log_event ctor
5388
4379
*/
5389
4380
 
5390
 
#ifndef DRIZZLE_CLIENT  
5391
4381
Execute_load_log_event::Execute_load_log_event(THD *thd_arg,
5392
4382
                                               const char* db_arg,
5393
4383
                                               bool using_trans)
5394
4384
  :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg)
5395
4385
{
5396
4386
}
5397
 
#endif
5398
4387
  
5399
4388
 
5400
4389
/*
5417
4406
  Execute_load_log_event::write()
5418
4407
*/
5419
4408
 
5420
 
#ifndef DRIZZLE_CLIENT
5421
4409
bool Execute_load_log_event::write(IO_CACHE* file)
5422
4410
{
5423
4411
  uchar buf[EXEC_LOAD_HEADER_LEN];
5425
4413
  return (write_header(file, sizeof(buf)) || 
5426
4414
          my_b_safe_write(file, buf, sizeof(buf)));
5427
4415
}
5428
 
#endif
5429
 
 
5430
 
 
5431
 
/*
5432
 
  Execute_load_log_event::print()
5433
 
*/
5434
 
 
5435
 
#ifdef DRIZZLE_CLIENT  
5436
 
void Execute_load_log_event::print(FILE* file,
5437
 
                                   PRINT_EVENT_INFO* print_event_info)
5438
 
{
5439
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
5440
 
 
5441
 
  if (print_event_info->short_form)
5442
 
    return;
5443
 
  print_header(&cache, print_event_info, false);
5444
 
  my_b_printf(&cache, "\n#Exec_load: file_id=%d\n",
5445
 
              file_id);
5446
 
}
5447
 
#endif
 
4416
 
5448
4417
 
5449
4418
/*
5450
4419
  Execute_load_log_event::pack_info()
5451
4420
*/
5452
4421
 
5453
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5454
4422
void Execute_load_log_event::pack_info(Protocol *protocol)
5455
4423
{
5456
4424
  char buf[64];
5551
4519
  return error;
5552
4520
}
5553
4521
 
5554
 
#endif /* defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
5555
 
 
5556
4522
 
5557
4523
/**************************************************************************
5558
4524
        Begin_load_query_log_event methods
5559
4525
**************************************************************************/
5560
4526
 
5561
 
#ifndef DRIZZLE_CLIENT
5562
4527
Begin_load_query_log_event::
5563
4528
Begin_load_query_log_event(THD* thd_arg, const char* db_arg, uchar* block_arg,
5564
4529
                           uint block_len_arg, bool using_trans)
5567
4532
{
5568
4533
   file_id= thd_arg->file_id= mysql_bin_log.next_file_id();
5569
4534
}
5570
 
#endif
5571
4535
 
5572
4536
 
5573
4537
Begin_load_query_log_event::
5578
4542
}
5579
4543
 
5580
4544
 
5581
 
#if defined( HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
5582
4545
int Begin_load_query_log_event::get_create_or_append() const
5583
4546
{
5584
4547
  return 1; /* create the file */
5585
4548
}
5586
 
#endif /* defined( HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT) */
5587
 
 
5588
 
 
5589
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
 
4549
 
 
4550
 
5590
4551
Log_event::enum_skip_reason
5591
4552
Begin_load_query_log_event::do_shall_skip(Relay_log_info *rli)
5592
4553
{
5596
4557
  */
5597
4558
  return continue_group(rli);
5598
4559
}
5599
 
#endif
5600
4560
 
5601
4561
 
5602
4562
/**************************************************************************
5604
4564
**************************************************************************/
5605
4565
 
5606
4566
 
5607
 
#ifndef DRIZZLE_CLIENT
5608
4567
Execute_load_query_log_event::
5609
4568
Execute_load_query_log_event(THD *thd_arg, const char* query_arg,
5610
4569
                             ulong query_length_arg, uint fn_pos_start_arg,
5618
4577
  fn_pos_end(fn_pos_end_arg), dup_handling(dup_handling_arg)
5619
4578
{
5620
4579
}
5621
 
#endif /* !DRIZZLE_CLIENT */
5622
4580
 
5623
4581
 
5624
4582
Execute_load_query_log_event::
5650
4608
}
5651
4609
 
5652
4610
 
5653
 
#ifndef DRIZZLE_CLIENT
5654
4611
bool
5655
4612
Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file)
5656
4613
{
5661
4618
  *(buf + 4 + 4 + 4)= (uchar) dup_handling;
5662
4619
  return my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN);
5663
4620
}
5664
 
#endif
5665
 
 
5666
 
 
5667
 
#ifdef DRIZZLE_CLIENT
5668
 
void Execute_load_query_log_event::print(FILE* file,
5669
 
                                         PRINT_EVENT_INFO* print_event_info)
5670
 
{
5671
 
  print(file, print_event_info, 0);
5672
 
}
5673
 
 
5674
 
/**
5675
 
  Prints the query as LOAD DATA LOCAL and with rewritten filename.
5676
 
*/
5677
 
void Execute_load_query_log_event::print(FILE* file,
5678
 
                                         PRINT_EVENT_INFO* print_event_info,
5679
 
                                         const char *local_fname)
5680
 
{
5681
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
5682
 
 
5683
 
  print_query_header(&cache, print_event_info);
5684
 
 
5685
 
  if (local_fname)
5686
 
  {
5687
 
    my_b_write(&cache, (uchar*) query, fn_pos_start);
5688
 
    my_b_printf(&cache, " LOCAL INFILE \'");
5689
 
    my_b_printf(&cache, local_fname);
5690
 
    my_b_printf(&cache, "\'");
5691
 
    if (dup_handling == LOAD_DUP_REPLACE)
5692
 
      my_b_printf(&cache, " REPLACE");
5693
 
    my_b_printf(&cache, " INTO");
5694
 
    my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end);
5695
 
    my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
5696
 
  }
5697
 
  else
5698
 
  {
5699
 
    my_b_write(&cache, (uchar*) query, q_len);
5700
 
    my_b_printf(&cache, "\n%s\n", print_event_info->delimiter);
5701
 
  }
5702
 
 
5703
 
  if (!print_event_info->short_form)
5704
 
    my_b_printf(&cache, "# file_id: %d \n", file_id);
5705
 
}
5706
 
#endif
5707
 
 
5708
 
 
5709
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
4621
 
 
4622
 
5710
4623
void Execute_load_query_log_event::pack_info(Protocol *protocol)
5711
4624
{
5712
4625
  char *buf, *pos;
5788
4701
  my_free(buf, MYF(MY_ALLOW_ZERO_PTR));
5789
4702
  return error;
5790
4703
}
5791
 
#endif
5792
4704
 
5793
4705
 
5794
4706
/**************************************************************************
5884
4796
        Rows_log_event member functions
5885
4797
**************************************************************************/
5886
4798
 
5887
 
#ifndef DRIZZLE_CLIENT
5888
4799
Rows_log_event::Rows_log_event(THD *thd_arg, Table *tbl_arg, ulong tid,
5889
4800
                               MY_BITMAP const *cols, bool is_transactional)
5890
4801
  : Log_event(thd_arg, 0, is_transactional),
5893
4804
    m_table_id(tid),
5894
4805
    m_width(tbl_arg ? tbl_arg->s->fields : 1),
5895
4806
    m_rows_buf(0), m_rows_cur(0), m_rows_end(0), m_flags(0) 
5896
 
#ifdef HAVE_REPLICATION
5897
4807
    , m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL)
5898
 
#endif
5899
4808
{
5900
4809
  /*
5901
4810
    We allow a special form of dummy event when the table, and cols
5928
4837
    m_cols.bitmap= 0;
5929
4838
  }
5930
4839
}
5931
 
#endif
 
4840
 
5932
4841
 
5933
4842
Rows_log_event::Rows_log_event(const char *buf, uint event_len,
5934
4843
                               Log_event_type event_type,
5936
4845
                               *description_event)
5937
4846
  : Log_event(buf, description_event),
5938
4847
    m_row_count(0),
5939
 
#ifndef DRIZZLE_CLIENT
5940
4848
    m_table(NULL),
5941
 
#endif
5942
4849
    m_table_id(0), m_rows_buf(0), m_rows_cur(0), m_rows_end(0)
5943
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
5944
4850
    , m_curr_row(NULL), m_curr_row_end(NULL), m_key(NULL)
5945
 
#endif
5946
4851
{
5947
4852
  uint8_t const common_header_len= description_event->common_header_len;
5948
4853
  uint8_t const post_header_len= description_event->post_header_len[event_type-1];
6014
4919
  m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME));
6015
4920
  if (likely((bool)m_rows_buf))
6016
4921
  {
6017
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
6018
4922
    m_curr_row= m_rows_buf;
6019
 
#endif
6020
4923
    m_rows_end= m_rows_buf + data_size;
6021
4924
    m_rows_cur= m_rows_end;
6022
4925
    memcpy(m_rows_buf, ptr_rows_data, data_size);
6054
4957
}
6055
4958
 
6056
4959
 
6057
 
#ifndef DRIZZLE_CLIENT
6058
4960
int Rows_log_event::do_add_row_data(uchar *row_data, size_t length)
6059
4961
{
6060
4962
  /*
6111
5013
  m_row_count++;
6112
5014
  return(0);
6113
5015
}
6114
 
#endif
6115
5016
 
6116
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
6117
5017
int Rows_log_event::do_apply_event(Relay_log_info const *rli)
6118
5018
{
6119
5019
  int error= 0;
6607
5507
  return(error);
6608
5508
}
6609
5509
 
6610
 
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
6611
 
 
6612
 
#ifndef DRIZZLE_CLIENT
6613
5510
bool Rows_log_event::write_data_header(IO_CACHE *file)
6614
5511
{
6615
5512
  uchar buf[ROWS_HEADER_LEN];   // No need to init the buffer
6648
5545
  return res;
6649
5546
 
6650
5547
}
6651
 
#endif
6652
 
 
6653
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
5548
 
 
5549
 
6654
5550
void Rows_log_event::pack_info(Protocol *protocol)
6655
5551
{
6656
5552
  char buf[256];
6660
5556
                         "table_id: %lu%s", m_table_id, flagstr);
6661
5557
  protocol->store(buf, bytes, &my_charset_bin);
6662
5558
}
6663
 
#endif
6664
 
 
6665
 
#ifdef DRIZZLE_CLIENT
6666
 
void Rows_log_event::print_helper(FILE *file,
6667
 
                                  PRINT_EVENT_INFO *print_event_info,
6668
 
                                  char const *const name)
6669
 
{
6670
 
  IO_CACHE *const head= &print_event_info->head_cache;
6671
 
  IO_CACHE *const body= &print_event_info->body_cache;
6672
 
  if (!print_event_info->short_form)
6673
 
  {
6674
 
    bool const last_stmt_event= get_flags(STMT_END_F);
6675
 
    print_header(head, print_event_info, !last_stmt_event);
6676
 
    my_b_printf(head, "\t%s: table id %lu%s\n",
6677
 
                name, m_table_id,
6678
 
                last_stmt_event ? " flags: STMT_END_F" : "");
6679
 
    print_base64(body, print_event_info, !last_stmt_event);
6680
 
  }
6681
 
 
6682
 
  if (get_flags(STMT_END_F))
6683
 
  {
6684
 
    copy_event_cache_to_file_and_reinit(head, file);
6685
 
    copy_event_cache_to_file_and_reinit(body, file);
6686
 
  }
6687
 
}
6688
 
#endif
 
5559
 
6689
5560
 
6690
5561
/**************************************************************************
6691
5562
        Table_map_log_event member functions and support functions
6723
5594
  type used is uint32_t. 
6724
5595
*/
6725
5596
 
6726
 
#if !defined(DRIZZLE_CLIENT)
6727
5597
/**
6728
5598
  Save the field metadata based on the real_type of the field.
6729
5599
  The metadata saved depends on the type of the field. Some fields
6755
5625
    index+= m_table->s->field[i]->save_field_metadata(&m_field_metadata[index]);
6756
5626
  return(index);
6757
5627
}
6758
 
#endif /* !defined(DRIZZLE_CLIENT) */
6759
5628
 
6760
5629
/*
6761
5630
  Constructor used to build an event for writing to the binary log.
6762
5631
  Mats says tbl->s lives longer than this event so it's ok to copy pointers
6763
5632
  (tbl->s->db etc) and not pointer content.
6764
5633
 */
6765
 
#if !defined(DRIZZLE_CLIENT)
6766
5634
Table_map_log_event::Table_map_log_event(THD *thd, Table *tbl, ulong tid,
6767
5635
                                         bool is_transactional __attribute__((unused)),
6768
5636
                                         uint16_t flags)
6843
5711
      m_null_bits[(i / 8)]+= 1 << (i % 8);
6844
5712
 
6845
5713
}
6846
 
#endif /* !defined(DRIZZLE_CLIENT) */
 
5714
 
6847
5715
 
6848
5716
/*
6849
5717
  Constructor used by slave to read the event from the binary log.
6850
5718
 */
6851
 
#if defined(HAVE_REPLICATION)
6852
5719
Table_map_log_event::Table_map_log_event(const char *buf, uint event_len,
6853
5720
                                         const Format_description_log_event
6854
5721
                                         *description_event)
6855
5722
 
6856
5723
  : Log_event(buf, description_event),
6857
 
#ifndef DRIZZLE_CLIENT
6858
5724
    m_table(NULL),
6859
 
#endif
6860
5725
    m_dbnam(NULL), m_dblen(0), m_tblnam(NULL), m_tbllen(0),
6861
5726
    m_colcnt(0), m_coltype(0),
6862
5727
    m_memory(NULL), m_table_id(ULONG_MAX), m_flags(0),
6938
5803
 
6939
5804
  return;
6940
5805
}
6941
 
#endif
6942
5806
 
6943
5807
Table_map_log_event::~Table_map_log_event()
6944
5808
{
6957
5821
       4     Daisy-chaining RBR with SBR not possible
6958
5822
 */
6959
5823
 
6960
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
6961
5824
int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
6962
5825
{
6963
5826
  RPL_TableList *table_list;
7110
5973
  return 0;
7111
5974
}
7112
5975
 
7113
 
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
7114
5976
 
7115
 
#ifndef DRIZZLE_CLIENT
7116
5977
bool Table_map_log_event::write_data_header(IO_CACHE *file)
7117
5978
{
7118
5979
  assert(m_table_id != UINT32_MAX);
7153
6014
          my_b_safe_write(file, m_field_metadata, m_field_metadata_size),
7154
6015
          my_b_safe_write(file, m_null_bits, (m_colcnt + 7) / 8));
7155
6016
 }
7156
 
#endif
7157
6017
 
7158
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
7159
6018
 
7160
6019
/*
7161
6020
  Print some useful information for the SHOW BINARY LOG information
7162
6021
  field.
7163
6022
 */
7164
6023
 
7165
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
7166
6024
void Table_map_log_event::pack_info(Protocol *protocol)
7167
6025
{
7168
6026
    char buf[256];
7171
6029
                           m_table_id, m_dbnam, m_tblnam);
7172
6030
    protocol->store(buf, bytes, &my_charset_bin);
7173
6031
}
7174
 
#endif
7175
 
 
7176
 
 
7177
 
#endif
7178
 
 
7179
 
 
7180
 
#ifdef DRIZZLE_CLIENT
7181
 
void Table_map_log_event::print(FILE * /* unused */,
7182
 
                                PRINT_EVENT_INFO *print_event_info)
7183
 
{
7184
 
  if (!print_event_info->short_form)
7185
 
  {
7186
 
    print_header(&print_event_info->head_cache, print_event_info, true);
7187
 
    my_b_printf(&print_event_info->head_cache,
7188
 
                "\tTable_map: `%s`.`%s` mapped to number %lu\n",
7189
 
                m_dbnam, m_tblnam, m_table_id);
7190
 
    print_base64(&print_event_info->body_cache, print_event_info, true);
7191
 
  }
7192
 
}
7193
 
#endif
 
6032
 
7194
6033
 
7195
6034
/**************************************************************************
7196
6035
        Write_rows_log_event member functions
7199
6038
/*
7200
6039
  Constructor used to build an event for writing to the binary log.
7201
6040
 */
7202
 
#if !defined(DRIZZLE_CLIENT)
7203
6041
Write_rows_log_event::Write_rows_log_event(THD *thd_arg, Table *tbl_arg,
7204
6042
                                           ulong tid_arg,
7205
6043
                                           bool is_transactional)
7206
6044
  : Rows_log_event(thd_arg, tbl_arg, tid_arg, tbl_arg->write_set, is_transactional)
7207
6045
{
7208
6046
}
7209
 
#endif
7210
6047
 
7211
6048
/*
7212
6049
  Constructor used by slave to read the event from the binary log.
7213
6050
 */
7214
 
#ifdef HAVE_REPLICATION
7215
6051
Write_rows_log_event::Write_rows_log_event(const char *buf, uint event_len,
7216
6052
                                           const Format_description_log_event
7217
6053
                                           *description_event)
7218
6054
: Rows_log_event(buf, event_len, WRITE_ROWS_EVENT, description_event)
7219
6055
{
7220
6056
}
7221
 
#endif
7222
6057
 
7223
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
7224
6058
int 
7225
6059
Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
7226
6060
{
7298
6132
  return error? error : local_error;
7299
6133
}
7300
6134
 
7301
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
7302
6135
 
7303
6136
/*
7304
6137
  Check if there are more UNIQUE keys after the given key.
7547
6380
  return(error);
7548
6381
}
7549
6382
 
7550
 
#endif
7551
6383
 
7552
6384
int 
7553
6385
Write_rows_log_event::do_exec_row(const Relay_log_info *const rli)
7566
6398
  return error; 
7567
6399
}
7568
6400
 
7569
 
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
7570
 
 
7571
 
#ifdef DRIZZLE_CLIENT
7572
 
void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info)
7573
 
{
7574
 
  Rows_log_event::print_helper(file, print_event_info, "Write_rows");
7575
 
}
7576
 
#endif
7577
6401
 
7578
6402
/**************************************************************************
7579
6403
        Delete_rows_log_event member functions
7580
6404
**************************************************************************/
7581
6405
 
7582
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
7583
6406
/*
7584
6407
  Compares table->record[0] and table->record[1]
7585
6408
 
7876
6699
  return(error);
7877
6700
}
7878
6701
 
7879
 
#endif
7880
6702
 
7881
6703
/*
7882
6704
  Constructor used to build an event for writing to the binary log.
7883
6705
 */
7884
6706
 
7885
 
#ifndef DRIZZLE_CLIENT
7886
6707
Delete_rows_log_event::Delete_rows_log_event(THD *thd_arg, Table *tbl_arg,
7887
6708
                                             ulong tid,
7888
6709
                                             bool is_transactional)
7889
6710
  : Rows_log_event(thd_arg, tbl_arg, tid, tbl_arg->read_set, is_transactional)
7890
6711
{
7891
6712
}
7892
 
#endif /* #if !defined(DRIZZLE_CLIENT) */
7893
6713
 
7894
6714
/*
7895
6715
  Constructor used by slave to read the event from the binary log.
7896
6716
 */
7897
 
#ifdef HAVE_REPLICATION
7898
6717
Delete_rows_log_event::Delete_rows_log_event(const char *buf, uint event_len,
7899
6718
                                             const Format_description_log_event
7900
6719
                                             *description_event)
7901
6720
  : Rows_log_event(buf, event_len, DELETE_ROWS_EVENT, description_event)
7902
6721
{
7903
6722
}
7904
 
#endif
7905
6723
 
7906
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
7907
6724
 
7908
6725
int 
7909
6726
Delete_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
7955
6772
  return error;
7956
6773
}
7957
6774
 
7958
 
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
7959
 
 
7960
 
#ifdef DRIZZLE_CLIENT
7961
 
void Delete_rows_log_event::print(FILE *file,
7962
 
                                  PRINT_EVENT_INFO* print_event_info)
7963
 
{
7964
 
  Rows_log_event::print_helper(file, print_event_info, "Delete_rows");
7965
 
}
7966
 
#endif
7967
 
 
7968
6775
 
7969
6776
/**************************************************************************
7970
6777
        Update_rows_log_event member functions
7973
6780
/*
7974
6781
  Constructor used to build an event for writing to the binary log.
7975
6782
 */
7976
 
#if !defined(DRIZZLE_CLIENT)
7977
6783
Update_rows_log_event::Update_rows_log_event(THD *thd_arg, Table *tbl_arg,
7978
6784
                                             ulong tid,
7979
6785
                                             bool is_transactional)
7998
6804
    }
7999
6805
  }
8000
6806
}
8001
 
#endif /* !defined(DRIZZLE_CLIENT) */
8002
6807
 
8003
6808
 
8004
6809
Update_rows_log_event::~Update_rows_log_event()
8012
6817
/*
8013
6818
  Constructor used by slave to read the event from the binary log.
8014
6819
 */
8015
 
#ifdef HAVE_REPLICATION
8016
6820
Update_rows_log_event::Update_rows_log_event(const char *buf, uint event_len,
8017
6821
                                             const
8018
6822
                                             Format_description_log_event
8020
6824
  : Rows_log_event(buf, event_len, UPDATE_ROWS_EVENT, description_event)
8021
6825
{
8022
6826
}
8023
 
#endif
8024
6827
 
8025
 
#if !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION)
8026
6828
 
8027
6829
int 
8028
6830
Update_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
8101
6903
  return error;
8102
6904
}
8103
6905
 
8104
 
#endif /* !defined(DRIZZLE_CLIENT) && defined(HAVE_REPLICATION) */
8105
 
 
8106
 
#ifdef DRIZZLE_CLIENT
8107
 
void Update_rows_log_event::print(FILE *file,
8108
 
                                  PRINT_EVENT_INFO* print_event_info)
8109
 
{
8110
 
  Rows_log_event::print_helper(file, print_event_info, "Update_rows");
8111
 
}
8112
 
#endif
8113
 
 
8114
6906
 
8115
6907
Incident_log_event::Incident_log_event(const char *buf, uint event_len,
8116
6908
                                       const Format_description_log_event *descr_event)
8153
6945
}
8154
6946
 
8155
6947
 
8156
 
#ifndef DRIZZLE_CLIENT
8157
6948
void Incident_log_event::pack_info(Protocol *protocol)
8158
6949
{
8159
6950
  char buf[256];
8166
6957
                    m_incident, description(), m_message.str);
8167
6958
  protocol->store(buf, bytes, &my_charset_bin);
8168
6959
}
8169
 
#endif
8170
 
 
8171
 
 
8172
 
#ifdef DRIZZLE_CLIENT
8173
 
void
8174
 
Incident_log_event::print(FILE *file,
8175
 
                          PRINT_EVENT_INFO *print_event_info)
8176
 
{
8177
 
  if (print_event_info->short_form)
8178
 
    return;
8179
 
 
8180
 
  Write_on_release_cache cache(&print_event_info->head_cache, file);
8181
 
  print_header(&cache, print_event_info, false);
8182
 
  my_b_printf(&cache, "\n# Incident: %s", description());
8183
 
}
8184
 
#endif
8185
 
 
8186
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
 
6960
 
 
6961
 
8187
6962
int
8188
6963
Incident_log_event::do_apply_event(Relay_log_info const *rli)
8189
6964
{
8193
6968
              m_message.length > 0 ? m_message.str : "<none>");
8194
6969
  return(1);
8195
6970
}
8196
 
#endif
 
6971
 
8197
6972
 
8198
6973
bool
8199
6974
Incident_log_event::write_data_header(IO_CACHE *file)
8209
6984
  return(write_str(file, m_message.str, m_message.length));
8210
6985
}
8211
6986
 
8212
 
#if defined(HAVE_REPLICATION) && !defined(DRIZZLE_CLIENT)
8213
6987
Heartbeat_log_event::Heartbeat_log_event(const char* buf, uint event_len,
8214
6988
                    const Format_description_log_event* description_event)
8215
6989
  :Log_event(buf, description_event)
8219
6993
  set_if_smaller(ident_len,FN_REFLEN-1);
8220
6994
  log_ident= buf + header_size;
8221
6995
}
8222
 
#endif
8223
 
 
8224
 
 
8225
 
#ifdef DRIZZLE_CLIENT
8226
 
/**
8227
 
  The default values for these variables should be values that are
8228
 
  *incorrect*, i.e., values that cannot occur in an event.  This way,
8229
 
  they will always be printed for the first event.
8230
 
*/
8231
 
st_print_event_info::st_print_event_info()
8232
 
  :flags2_inited(0), sql_mode_inited(0),
8233
 
   auto_increment_increment(0),auto_increment_offset(0), charset_inited(0),
8234
 
   lc_time_names_number(UINT32_MAX),
8235
 
   charset_database_number(ILLEGAL_CHARSET_INFO_NUMBER),
8236
 
   thread_id(0), thread_id_printed(false),
8237
 
   base64_output_mode(BASE64_OUTPUT_UNSPEC), printed_fd_event(false)
8238
 
{
8239
 
  /*
8240
 
    Currently we only use static PRINT_EVENT_INFO objects, so zeroed at
8241
 
    program's startup, but these explicit memset() is for the day someone
8242
 
    creates dynamic instances.
8243
 
  */
8244
 
  memset(db, 0, sizeof(db));
8245
 
  memset(charset, 0, sizeof(charset));
8246
 
  memset(time_zone_str, 0, sizeof(time_zone_str));
8247
 
  delimiter[0]= ';';
8248
 
  delimiter[1]= 0;
8249
 
  myf const flags = MYF(MY_WME | MY_NABP);
8250
 
  open_cached_file(&head_cache, NULL, NULL, 0, flags);
8251
 
  open_cached_file(&body_cache, NULL, NULL, 0, flags);
8252
 
}
8253
 
#endif