diff options
Diffstat (limited to 'client/mysqlbinlog.cc')
-rw-r--r-- | client/mysqlbinlog.cc | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index fd5fd88c58d..cedf837c9ab 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -488,6 +488,15 @@ end: static struct my_option my_long_options[] = { + /* + mysqlbinlog needs charsets knowledge, to be able to convert a charset + number found in binlog to a charset name (to be able to print things + like this: + SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`; + */ + {"character-sets-dir", OPT_CHARSETS_DIR, + "Directory where character sets are.", (gptr*) &charsets_dir, + (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF {"debug", '#', "Output debug log.", (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -744,7 +753,7 @@ static int parse_args(int *argc, char*** argv) static MYSQL* safe_connect() { - MYSQL *local_mysql = mysql_init(NULL); + MYSQL *local_mysql= mysql_init(NULL); if (!local_mysql) die("Failed on mysql_init"); @@ -752,9 +761,13 @@ static MYSQL* safe_connect() if (opt_protocol) mysql_options(local_mysql, MYSQL_OPT_PROTOCOL, (char*) &opt_protocol); if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) - die("failed on connect: %s", mysql_error(local_mysql)); + { + char errmsg[256]; + strmake(errmsg, mysql_error(local_mysql), sizeof(errmsg)-1); + mysql_close(local_mysql); + die("failed on connect: %s", errmsg); + } local_mysql->reconnect= 1; - return local_mysql; } @@ -781,9 +794,10 @@ static int check_master_version(MYSQL* mysql, if (mysql_query(mysql, "SELECT VERSION()") || !(res = mysql_store_result(mysql))) { + char errmsg[256]; + strmake(errmsg, mysql_error(mysql), sizeof(errmsg)-1); mysql_close(mysql); - die("Error checking master version: %s", - mysql_error(mysql)); + die("Error checking master version: %s", errmsg); } if (!(row = mysql_fetch_row(res))) { @@ -1116,15 +1130,15 @@ static int dump_local_log_entries(const char* logname) } check_header(file, &description_event); } - else // reading from stdin; TODO: check that it works + else // reading from stdin; { - if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0, + if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) return 1; check_header(file, &description_event); if (start_position) { - /* skip 'start_position' characters from stdout */ + /* skip 'start_position' characters from stdin */ byte buff[IO_SIZE]; my_off_t length,tmp; for (length= start_position_mot ; length > 0 ; length-=tmp) @@ -1137,8 +1151,6 @@ static int dump_local_log_entries(const char* logname) } } } - file->pos_in_file= start_position_mot; - file->seek_not_done=0; } if (!description_event || !description_event->is_valid()) @@ -1273,8 +1285,14 @@ int main(int argc, char** argv) */ #ifdef __WIN__ +#include "my_decimal.h" +#include "decimal.c" +#include "my_decimal.cpp" #include "log_event.cpp" #else +#include "my_decimal.h" +#include "decimal.c" +#include "my_decimal.cc" #include "log_event.cc" #endif |