~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/mysqlbinlog.cc

Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#define MYSQL_CLIENT
32
32
#undef MYSQL_SERVER
 
33
#include <my_global.h>
33
34
#include "client_priv.h"
34
35
#include <my_time.h>
35
36
/* That one is necessary for defines of OPTION_NO_FOREIGN_KEY_CHECKS etc */
54
55
static uint opt_protocol= 0;
55
56
static FILE *result_file;
56
57
 
57
 
#ifndef DBUG_OFF
58
 
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
59
 
#endif
60
58
static const char *load_default_groups[]= { "mysqlbinlog","client",0 };
61
59
 
62
60
static void error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
71
69
static enum_base64_output_mode opt_base64_output_mode= BASE64_OUTPUT_UNSPEC;
72
70
static const char *opt_base64_output_mode_str= NullS;
73
71
static const char* database= 0;
74
 
static my_bool force_opt= 0, short_form= 0, remote_opt= 0;
75
 
static my_bool debug_info_flag, debug_check_flag;
76
 
static my_bool force_if_open_opt= 1;
77
 
static ulonglong offset = 0;
 
72
static bool force_opt= 0, short_form= 0, remote_opt= 0;
 
73
static bool debug_info_flag, debug_check_flag;
 
74
static bool force_if_open_opt= 1;
 
75
static uint64_t offset = 0;
78
76
static const char* host = 0;
79
77
static int port= 0;
80
78
static uint my_end_arg;
83
81
static char* pass = 0;
84
82
static char *charset= 0;
85
83
 
86
 
static ulonglong start_position, stop_position;
 
84
static uint64_t start_position, stop_position;
87
85
#define start_position_mot ((my_off_t)start_position)
88
86
#define stop_position_mot  ((my_off_t)stop_position)
89
87
 
90
88
static char *start_datetime_str, *stop_datetime_str;
91
89
static my_time_t start_datetime= 0, stop_datetime= MY_TIME_T_MAX;
92
 
static ulonglong rec_count= 0;
 
90
static uint64_t rec_count= 0;
93
91
static short binlog_flags = 0; 
94
92
static MYSQL* mysql = NULL;
95
93
static const char* dirname_for_local_load= 0;
419
417
  char *fname, *ptr;
420
418
  File file;
421
419
  File_name_record rec;
422
 
  DBUG_ENTER("Load_log_processor::process_first_event");
 
420
 
423
421
 
424
422
  if (!(fname= (char*) my_malloc(full_len,MYF(MY_WME))))
425
423
  {
426
424
    error("Out of memory.");
427
425
    delete ce;
428
 
    DBUG_RETURN(ERROR_STOP);
 
426
    return(ERROR_STOP);
429
427
  }
430
428
 
431
429
  memcpy(fname, target_dir_name, target_dir_name_len);
439
437
    error("Could not construct local filename %s%s.",
440
438
          target_dir_name,bname);
441
439
    delete ce;
442
 
    DBUG_RETURN(ERROR_STOP);
 
440
    return(ERROR_STOP);
443
441
  }
444
442
 
445
443
  rec.fname= fname;
449
447
  {
450
448
    error("Out of memory.");
451
449
    delete ce;
452
 
    DBUG_RETURN(ERROR_STOP);
 
450
    return(ERROR_STOP);
453
451
  }
454
452
 
455
453
  if (ce)
465
463
    error("Failed closing file.");
466
464
    retval= ERROR_STOP;
467
465
  }
468
 
  DBUG_RETURN(retval);
 
466
  return(retval);
469
467
}
470
468
 
471
469
 
530
528
*/
531
529
Exit_status Load_log_processor::process(Append_block_log_event *ae)
532
530
{
533
 
  DBUG_ENTER("Load_log_processor::process");
 
531
 
534
532
  const char* fname= ((ae->file_id < file_names.elements) ?
535
533
                       dynamic_element(&file_names, ae->file_id,
536
534
                                       File_name_record*)->fname : 0);
543
541
                        O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0))
544
542
    {
545
543
      error("Failed opening file %s", fname);
546
 
      DBUG_RETURN(ERROR_STOP);
 
544
      return(ERROR_STOP);
547
545
    }
548
546
    if (my_write(file,(uchar*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)))
549
547
    {
555
553
      error("Failed closing file %s", fname);
556
554
      retval= ERROR_STOP;
557
555
    }
558
 
    DBUG_RETURN(retval);
 
556
    return(retval);
559
557
  }
560
558
 
561
559
  /*
565
563
  */
566
564
  warning("Ignoring Append_block as there is no "
567
565
          "Create_file event for file_id: %u", ae->file_id);
568
 
  DBUG_RETURN(OK_CONTINUE);
 
566
  return(OK_CONTINUE);
569
567
}
570
568
 
571
569
 
636
634
{
637
635
  IO_CACHE *head= &print_event_info->head_cache;
638
636
  IO_CACHE *body= &print_event_info->body_cache;
639
 
  DBUG_ENTER("write_event_header_and_base64");
 
637
 
640
638
 
641
639
  /* Write header and base64 output to cache */
642
 
  ev->print_header(head, print_event_info, FALSE);
643
 
  ev->print_base64(body, print_event_info, FALSE);
 
640
  ev->print_header(head, print_event_info, false);
 
641
  ev->print_base64(body, print_event_info, false);
644
642
 
645
643
  /* Read data from cache and write to result file */
646
644
  if (copy_event_cache_to_file_and_reinit(head, result_file) ||
647
645
      copy_event_cache_to_file_and_reinit(body, result_file))
648
646
  {
649
647
    error("Error writing event to file.");
650
 
    DBUG_RETURN(ERROR_STOP);
 
648
    return(ERROR_STOP);
651
649
  }
652
 
  DBUG_RETURN(OK_CONTINUE);
 
650
  return(OK_CONTINUE);
653
651
}
654
652
 
655
653
 
678
676
{
679
677
  char ll_buff[21];
680
678
  Log_event_type ev_type= ev->get_type_code();
681
 
  DBUG_ENTER("process_event");
 
679
 
682
680
  print_event_info->short_form= short_form;
683
681
  Exit_status retval= OK_CONTINUE;
684
682
 
718
716
 
719
717
    print_event_info->base64_output_mode= opt_base64_output_mode;
720
718
 
721
 
    DBUG_PRINT("debug", ("event_type: %s", ev->get_type_str()));
722
 
 
723
719
    switch (ev_type) {
724
720
    case QUERY_EVENT:
725
721
      if (shall_skip_database(((Query_log_event*)ev)->db))
761
757
          goto end;
762
758
      }
763
759
      else
764
 
        ce->print(result_file, print_event_info, TRUE);
 
760
        ce->print(result_file, print_event_info, true);
765
761
 
766
762
      // If this binlog is not 3.23 ; why this test??
767
763
      if (glob_description_event->binlog_version >= 3)
806
802
          my_open() in Load_log_processor::append().
807
803
        */
808
804
        convert_path_to_forward_slashes((char*) ce->fname);
809
 
        ce->print(result_file, print_event_info, TRUE);
 
805
        ce->print(result_file, print_event_info, true);
810
806
        my_free((char*)ce->fname,MYF(MY_WME));
811
807
        delete ce;
812
808
      }
835
831
        error("Attempting to dump binlog '%s', which was not closed properly. "
836
832
              "Most probably, mysqld is still writing it, or it crashed. "
837
833
              "Rerun with --force-if-open to ignore this problem.", logname);
838
 
        DBUG_RETURN(ERROR_STOP);
 
834
        return(ERROR_STOP);
839
835
      }
840
836
      break;
841
837
    case BEGIN_LOAD_QUERY_EVENT:
916
912
      ev->temp_buf= 0;
917
913
    delete ev;
918
914
  }
919
 
  DBUG_RETURN(retval);
 
915
  return(retval);
920
916
}
921
917
 
922
918
 
932
928
   "'always' prints base64 whenever possible. 'always' is for debugging "
933
929
   "only and should not be used in a production system. The default is "
934
930
   "'auto'. --base64-output is a short form for --base64-output=always."
935
 
   ,(uchar**) &opt_base64_output_mode_str,
936
 
   (uchar**) &opt_base64_output_mode_str,
 
931
   ,(char**) &opt_base64_output_mode_str,
 
932
   (char**) &opt_base64_output_mode_str,
937
933
   0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
938
934
  /*
939
935
    mysqlbinlog needs charsets knowledge, to be able to convert a charset
942
938
    SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`;
943
939
  */
944
940
  {"character-sets-dir", OPT_CHARSETS_DIR,
945
 
   "Directory where character sets are.", (uchar**) &charsets_dir,
946
 
   (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
941
   "Directory where character sets are.", (char**) &charsets_dir,
 
942
   (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
947
943
  {"database", 'd', "List entries for just this database (local log only).",
948
 
   (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
 
944
   (char**) &database, (char**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
949
945
   0, 0, 0, 0, 0, 0},
950
 
#ifndef DBUG_OFF
951
 
  {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option,
952
 
   (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
953
 
#endif
954
946
  {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
955
 
   (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
 
947
   (char**) &debug_check_flag, (char**) &debug_check_flag, 0,
956
948
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
957
949
  {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
958
 
   (uchar**) &debug_info_flag, (uchar**) &debug_info_flag,
 
950
   (char**) &debug_info_flag, (char**) &debug_info_flag,
959
951
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
960
952
  {"disable-log-bin", 'D', "Disable binary log. This is useful, if you "
961
953
    "enabled --to-last-log and are sending the output to the same MySQL server. "
962
954
    "This way you could avoid an endless loop. You would also like to use it "
963
955
    "when restoring after a crash to avoid duplication of the statements you "
964
956
    "already have. NOTE: you will need a SUPER privilege to use this option.",
965
 
   (uchar**) &disable_log_bin, (uchar**) &disable_log_bin, 0, GET_BOOL,
 
957
   (char**) &disable_log_bin, (char**) &disable_log_bin, 0, GET_BOOL,
966
958
   NO_ARG, 0, 0, 0, 0, 0, 0},
967
959
  {"force-if-open", 'F', "Force if binlog was not closed properly.",
968
 
   (uchar**) &force_if_open_opt, (uchar**) &force_if_open_opt, 0, GET_BOOL, NO_ARG,
 
960
   (char**) &force_if_open_opt, (char**) &force_if_open_opt, 0, GET_BOOL, NO_ARG,
969
961
   1, 0, 0, 0, 0, 0},
970
962
  {"force-read", 'f', "Force reading unknown binlog events.",
971
 
   (uchar**) &force_opt, (uchar**) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
963
   (char**) &force_opt, (char**) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
972
964
   0, 0},
973
965
  {"hexdump", 'H', "Augment output with hexadecimal and ASCII event dump.",
974
 
   (uchar**) &opt_hexdump, (uchar**) &opt_hexdump, 0, GET_BOOL, NO_ARG,
 
966
   (char**) &opt_hexdump, (char**) &opt_hexdump, 0, GET_BOOL, NO_ARG,
975
967
   0, 0, 0, 0, 0, 0},
976
 
  {"host", 'h', "Get the binlog from server.", (uchar**) &host, (uchar**) &host,
 
968
  {"host", 'h', "Get the binlog from server.", (char**) &host, (char**) &host,
977
969
   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
978
970
  {"local-load", 'l', "Prepare local temporary files for LOAD DATA INFILE in the specified directory.",
979
 
   (uchar**) &dirname_for_local_load, (uchar**) &dirname_for_local_load, 0,
 
971
   (char**) &dirname_for_local_load, (char**) &dirname_for_local_load, 0,
980
972
   GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
981
 
  {"offset", 'o', "Skip the first N entries.", (uchar**) &offset, (uchar**) &offset,
 
973
  {"offset", 'o', "Skip the first N entries.", (char**) &offset, (char**) &offset,
982
974
   0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
983
975
  {"password", 'p', "Password to connect to remote server.",
984
976
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
988
980
   "/etc/services, "
989
981
#endif
990
982
   "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").",
991
 
   (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG,
 
983
   (char**) &port, (char**) &port, 0, GET_INT, REQUIRED_ARG,
992
984
   0, 0, 0, 0, 0, 0},
993
985
  {"position", 'j', "Deprecated. Use --start-position instead.",
994
 
   (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL,
 
986
   (char**) &start_position, (char**) &start_position, 0, GET_ULL,
995
987
   REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE,
996
988
   /* COM_BINLOG_DUMP accepts only 4 bytes for the position */
997
 
   (ulonglong)(~(uint32)0), 0, 0, 0},
 
989
   (uint64_t)(~(uint32)0), 0, 0, 0},
998
990
  {"protocol", OPT_MYSQL_PROTOCOL,
999
991
   "The protocol of connection (tcp,socket,pipe,memory).",
1000
992
   0, 0, 0, GET_STR,  REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1001
993
  {"read-from-remote-server", 'R', "Read binary logs from a MySQL server",
1002
 
   (uchar**) &remote_opt, (uchar**) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
994
   (char**) &remote_opt, (char**) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1003
995
   0, 0},
1004
996
  {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR,
1005
997
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1006
998
  {"server-id", OPT_SERVER_ID,
1007
999
   "Extract only binlog entries created by the server having the given id.",
1008
 
   (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG,
 
1000
   (char**) &server_id, (char**) &server_id, 0, GET_ULONG,
1009
1001
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1010
1002
  {"set-charset", OPT_SET_CHARSET,
1011
 
   "Add 'SET NAMES character_set' to the output.", (uchar**) &charset,
1012
 
   (uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1003
   "Add 'SET NAMES character_set' to the output.", (char**) &charset,
 
1004
   (char**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1013
1005
  {"short-form", 's', "Just show regular queries: no extra info and no "
1014
1006
   "row-based events. This is for testing only, and should not be used in "
1015
1007
   "production systems. If you want to suppress base64-output, consider "
1016
1008
   "using --base64-output=never instead.",
1017
 
   (uchar**) &short_form, (uchar**) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
 
1009
   (char**) &short_form, (char**) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1018
1010
   0, 0},
1019
1011
  {"socket", 'S', "Socket file to use for connection.",
1020
 
   (uchar**) &sock, (uchar**) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 
 
1012
   (char**) &sock, (char**) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 
1021
1013
   0, 0},
1022
1014
  {"start-datetime", OPT_START_DATETIME,
1023
1015
   "Start reading the binlog at first event having a datetime equal or "
1025
1017
   "in the local time zone, in any format accepted by the MySQL server "
1026
1018
   "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 "
1027
1019
   "(you should probably use quotes for your shell to set it properly).",
1028
 
   (uchar**) &start_datetime_str, (uchar**) &start_datetime_str,
 
1020
   (char**) &start_datetime_str, (char**) &start_datetime_str,
1029
1021
   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1030
1022
  {"start-position", OPT_START_POSITION,
1031
1023
   "Start reading the binlog at position N. Applies to the first binlog "
1032
1024
   "passed on the command line.",
1033
 
   (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL,
 
1025
   (char**) &start_position, (char**) &start_position, 0, GET_ULL,
1034
1026
   REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE,
1035
1027
   /* COM_BINLOG_DUMP accepts only 4 bytes for the position */
1036
 
   (ulonglong)(~(uint32)0), 0, 0, 0},
 
1028
   (uint64_t)(~(uint32)0), 0, 0, 0},
1037
1029
  {"stop-datetime", OPT_STOP_DATETIME,
1038
1030
   "Stop reading the binlog at first event having a datetime equal or "
1039
1031
   "posterior to the argument; the argument must be a date and time "
1040
1032
   "in the local time zone, in any format accepted by the MySQL server "
1041
1033
   "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 "
1042
1034
   "(you should probably use quotes for your shell to set it properly).",
1043
 
   (uchar**) &stop_datetime_str, (uchar**) &stop_datetime_str,
 
1035
   (char**) &stop_datetime_str, (char**) &stop_datetime_str,
1044
1036
   0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1045
1037
  {"stop-position", OPT_STOP_POSITION,
1046
1038
   "Stop reading the binlog at position N. Applies to the last binlog "
1047
1039
   "passed on the command line.",
1048
 
   (uchar**) &stop_position, (uchar**) &stop_position, 0, GET_ULL,
1049
 
   REQUIRED_ARG, (ulonglong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE,
1050
 
   (ulonglong)(~(my_off_t)0), 0, 0, 0},
 
1040
   (char**) &stop_position, (char**) &stop_position, 0, GET_ULL,
 
1041
   REQUIRED_ARG, (uint64_t)(~(my_off_t)0), BIN_LOG_HEADER_SIZE,
 
1042
   (uint64_t)(~(my_off_t)0), 0, 0, 0},
1051
1043
  {"to-last-log", 't', "Requires -R. Will not stop at the end of the \
1052
1044
requested binlog but rather continue printing until the end of the last \
1053
1045
binlog of the MySQL server. If you send the output to the same MySQL server, \
1054
1046
that may lead to an endless loop.",
1055
 
   (uchar**) &to_last_remote_log, (uchar**) &to_last_remote_log, 0, GET_BOOL,
 
1047
   (char**) &to_last_remote_log, (char**) &to_last_remote_log, 0, GET_BOOL,
1056
1048
   NO_ARG, 0, 0, 0, 0, 0, 0},
1057
1049
  {"user", 'u', "Connect to the remote server as username.",
1058
 
   (uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
 
1050
   (char**) &user, (char**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
1059
1051
   0, 0},
1060
1052
  {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1061
1053
   0, 0, 0, 0, 0},
1062
1054
  {"open_files_limit", OPT_OPEN_FILES_LIMIT,
1063
1055
   "Used to reserve file descriptors for usage by this program",
1064
 
   (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG,
 
1056
   (char**) &open_files_limit, (char**) &open_files_limit, 0, GET_ULONG,
1065
1057
   REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0},
1066
1058
  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1067
1059
};
1193
1185
 
1194
1186
#include <help_end.h>
1195
1187
 
1196
 
extern "C" my_bool
 
1188
extern "C" bool
1197
1189
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
1198
1190
               char *argument)
1199
1191
{
1200
1192
  bool tty_password=0;
1201
1193
  switch (optid) {
1202
 
#ifndef DBUG_OFF
1203
 
  case '#':
1204
 
    DBUG_PUSH(argument ? argument : default_dbug_option);
1205
 
    break;
1206
 
#endif
1207
1194
  case 'd':
1208
1195
    one_database = 1;
1209
1196
    break;
1442
1429
  my_off_t old_off= start_position_mot;
1443
1430
  char fname[FN_REFLEN+1];
1444
1431
  Exit_status retval= OK_CONTINUE;
1445
 
  DBUG_ENTER("dump_remote_log_entries");
 
1432
 
1446
1433
 
1447
1434
  /*
1448
1435
    Even if we already read one binlog (case of >=2 binlogs on command line),
1450
1437
    (COM_BINLOG_DUMP kills the thread when it finishes).
1451
1438
  */
1452
1439
  if ((retval= safe_connect()) != OK_CONTINUE)
1453
 
    DBUG_RETURN(retval);
 
1440
    return(retval);
1454
1441
  net= &mysql->net;
1455
1442
 
1456
1443
  if ((retval= check_master_version()) != OK_CONTINUE)
1457
 
    DBUG_RETURN(retval);
 
1444
    return(retval);
1458
1445
 
1459
1446
  /*
1460
1447
    COM_BINLOG_DUMP accepts only 4 bytes for the position, so we are forced to
1467
1454
  if (tlen > UINT_MAX) 
1468
1455
  {
1469
1456
    error("Log name too long.");
1470
 
    DBUG_RETURN(ERROR_STOP);
 
1457
    return(ERROR_STOP);
1471
1458
  }
1472
1459
  logname_len = (uint) tlen;
1473
1460
  int4store(buf + 6, 0);
1475
1462
  if (simple_command(mysql, COM_BINLOG_DUMP, buf, logname_len + 10, 1))
1476
1463
  {
1477
1464
    error("Got fatal error sending the log dump command.");
1478
 
    DBUG_RETURN(ERROR_STOP);
 
1465
    return(ERROR_STOP);
1479
1466
  }
1480
1467
 
1481
1468
  for (;;)
1487
1474
    if (len == packet_error)
1488
1475
    {
1489
1476
      error("Got error reading packet from server: %s", mysql_error(mysql));
1490
 
      DBUG_RETURN(ERROR_STOP);
 
1477
      return(ERROR_STOP);
1491
1478
    }
1492
1479
    if (len < 8 && net->read_pos[0] == 254)
1493
1480
      break; // end of data
1494
 
    DBUG_PRINT("info",( "len: %lu  net->read_pos[5]: %d\n",
1495
 
                        len, net->read_pos[5]));
1496
1481
    if (!(ev= Log_event::read_log_event((const char*) net->read_pos + 1 ,
1497
1482
                                        len - 1, &error_msg,
1498
1483
                                        glob_description_event)))
1499
1484
    {
1500
1485
      error("Could not construct log event object: %s", error_msg);
1501
 
      DBUG_RETURN(ERROR_STOP);
 
1486
      return(ERROR_STOP);
1502
1487
    }   
1503
1488
    /*
1504
1489
      If reading from a remote host, ensure the temp_buf for the
1537
1522
            if ((rev->ident_len != logname_len) ||
1538
1523
                memcmp(rev->new_log_ident, logname, logname_len))
1539
1524
            {
1540
 
              DBUG_RETURN(OK_CONTINUE);
 
1525
              return(OK_CONTINUE);
1541
1526
            }
1542
1527
            /*
1543
1528
              Otherwise, this is a fake Rotate for our log, at the very
1564
1549
      }
1565
1550
      Exit_status retval= process_event(print_event_info, ev, old_off, logname);
1566
1551
      if (retval != OK_CONTINUE)
1567
 
        DBUG_RETURN(retval);
 
1552
        return(retval);
1568
1553
    }
1569
1554
    else
1570
1555
    {
1575
1560
      Exit_status retval;
1576
1561
 
1577
1562
      if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0)
1578
 
        DBUG_RETURN(ERROR_STOP);
 
1563
        return(ERROR_STOP);
1579
1564
 
1580
1565
      retval= process_event(print_event_info, ev, old_off, logname);
1581
1566
      if (retval != OK_CONTINUE)
1582
1567
      {
1583
1568
        my_close(file,MYF(MY_WME));
1584
 
        DBUG_RETURN(retval);
 
1569
        return(retval);
1585
1570
      }
1586
1571
      retval= load_processor.load_old_format_file(net,old_fname,old_len,file);
1587
1572
      my_close(file,MYF(MY_WME));
1588
1573
      if (retval != OK_CONTINUE)
1589
 
        DBUG_RETURN(retval);
 
1574
        return(retval);
1590
1575
    }
1591
1576
    /*
1592
1577
      Let's adjust offset for remote log as for local log to produce
1595
1580
    old_off+= len-1;
1596
1581
  }
1597
1582
 
1598
 
  DBUG_RETURN(OK_CONTINUE);
 
1583
  return(OK_CONTINUE);
1599
1584
}
1600
1585
 
1601
1586
 
1631
1616
{
1632
1617
  uchar header[BIN_LOG_HEADER_SIZE];
1633
1618
  uchar buf[PROBE_HEADER_LEN];
1634
 
  my_off_t tmp_pos, pos;
 
1619
  uint64_t tmp_pos, pos;
1635
1620
 
1636
1621
  delete glob_description_event;
1637
1622
  if (!(glob_description_event= new Format_description_log_event(3)))
1673
1658
    {
1674
1659
      if (file->error)
1675
1660
      {
1676
 
        error("Could not read entry at offset %lu: "
1677
 
              "Error in log format or read error.", (ulonglong)tmp_pos);
 
1661
        error("Could not read entry at offset %"PRIu64": "
 
1662
              "Error in log format or read error.", tmp_pos);
1678
1663
        return ERROR_STOP;
1679
1664
      }
1680
1665
      /*
1695
1680
    }
1696
1681
    else
1697
1682
    {
1698
 
      DBUG_PRINT("info",("buf[EVENT_TYPE_OFFSET=%d]=%d",
1699
 
                         EVENT_TYPE_OFFSET, buf[EVENT_TYPE_OFFSET]));
1700
1683
      /* always test for a Start_v3, even if no --start-position */
1701
1684
      if (buf[EVENT_TYPE_OFFSET] == START_EVENT_V3)
1702
1685
      {
1727
1710
          /* EOF can't be hit here normally, so it's a real error */
1728
1711
        {
1729
1712
          error("Could not read a Format_description_log_event event at "
1730
 
                "offset %lu; this could be a log format error or read error.",
1731
 
                (ulonglong)tmp_pos);
 
1713
                "offset %"PRIu64"; this could be a log format error or read error.",
 
1714
                tmp_pos);
1732
1715
          return ERROR_STOP;
1733
1716
        }
1734
1717
        if (opt_base64_output_mode == BASE64_OUTPUT_AUTO
1750
1733
          delete glob_description_event;
1751
1734
          glob_description_event= new_description_event;
1752
1735
        }
1753
 
        DBUG_PRINT("info",("Setting description_event"));
1754
1736
      }
1755
1737
      else if (buf[EVENT_TYPE_OFFSET] == ROTATE_EVENT)
1756
1738
      {
1759
1741
        if (!(ev= Log_event::read_log_event(file, glob_description_event)))
1760
1742
        {
1761
1743
          /* EOF can't be hit here normally, so it's a real error */
1762
 
          error("Could not read a Rotate_log_event event at offset %lu;"
 
1744
          error("Could not read a Rotate_log_event event at offset "
 
1745
                "%"PRIu64";"
1763
1746
                " this could be a log format error or read error.",
1764
 
                (ulonglong)tmp_pos);
 
1747
                tmp_pos);
1765
1748
          return ERROR_STOP;
1766
1749
        }
1767
1750
        delete ev;
1894
1877
{
1895
1878
  char **defaults_argv;
1896
1879
  Exit_status retval= OK_CONTINUE;
1897
 
  ulonglong save_stop_position;
 
1880
  uint64_t save_stop_position;
1898
1881
  MY_INIT(argv[0]);
1899
 
  DBUG_ENTER("main");
1900
 
  DBUG_PROCESS(argv[0]);
1901
1882
 
1902
1883
  init_time(); // for time functions
1903
1884