From 9d97b5ff8ce69b1c9ec10d822c094b1e11351dd8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 May 2003 20:01:39 +0300 Subject: A fix for the crashing bug in mysql client program --- client/mysql.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index a237561d83d..4ab97f1b3cf 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2593,6 +2593,8 @@ static void mysql_end_timer(ulong start_time,char *buff) static const char* construct_prompt() { //erase the old prompt + if (!mysql_get_host_info(&mysql)) + return processed_prompt.ptr(); processed_prompt.free(); //get the date struct time_t lclock = time(NULL); -- cgit v1.2.1 From 366fd92e8d882737268f354e0a744d576868a043 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Jun 2003 15:49:54 +0200 Subject: Fix for nightly build test failure (test update). More messages. Testcase for bug 651. client/mysqltest.c: More explicit error message if MASTER_POS_WAIT() returns NULL. mysql-test/r/rpl_loaddata.result: result update mysql-test/r/rpl_master_pos_wait.result: result update mysql-test/t/rpl000001.test: sync_with_master (=MASTER_POS_WAIT()) was called when we could expect the SQL slave thread had stopped. As I yesterday changed code so that "SQL thread stops => MASTER_POS_WAIT() returns NULL immediately" (bugfix), sync_with_master received NULL (on build.mysql.com, not on my machine; this is a question of milliseconds, if the slave server will process MASTER_POS_WAIT() before or after the slave SQL thread has stopped), and in mysqltest.c, sync_with_master complained that it could not sync. So I just remove this sync_with_master, which does not make sense anymore: we just wait for the slave SQL thread to stop. mysql-test/t/rpl_loaddata.test: Discovered we had wait_for_slave_to_stop, so used it as it automates things. mysql-test/t/rpl_master_pos_wait.test: Discovered we had 'send' to send a query without waiting for the resultn so could had a testcase for bug 651. Shorter timeouts as there is no risk the position is reached. sql/slave.cc: A longer DBUG_PRINT. --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqltest.c b/client/mysqltest.c index f6c999b18e4..f5afa0fa0df 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -996,7 +996,8 @@ int do_sync_with_master2(const char* p) if (!(row = mysql_fetch_row(res))) die("line %u: empty result in %s", start_lineno, query_buf); if (!row[0]) - die("Error on slave while syncing with master"); + die("line %u: could not sync with master ('%s' returned NULL)", + start_lineno, query_buf); mysql_free_result(res); last_result=0; if (rpl_parse) -- cgit v1.2.1 From 656fdcc722c67706b897444e5b33312d609957cb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Jun 2003 15:48:52 +0200 Subject: fix for BUG#691 (4.0 mysqlbinlog couldn't read 3.23 binlog). Safe parenthesis. --- client/mysqlbinlog.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 75b875b4f4e..9ef340197a7 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -396,8 +396,8 @@ static int check_header(IO_CACHE* file) if (buf[4] == START_EVENT) { uint event_len; - event_len = uint4korr(buf + 4); - old_format = (event_len < LOG_EVENT_HEADER_LEN + START_HEADER_LEN); + event_len = uint4korr(buf + EVENT_LEN_OFFSET); + old_format = (event_len < (LOG_EVENT_HEADER_LEN + START_HEADER_LEN)); } } my_b_seek(file, pos); -- cgit v1.2.1 From f1ef7dd0d78da1277a81800e550ce1f5863c8882 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Jul 2003 13:17:03 -0400 Subject: removed --table option (fixed Bug #671) client/mysqlbinlog.cc: removed --table option --- client/mysqlbinlog.cc | 54 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 75b875b4f4e..d6da9d81664 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -55,13 +55,11 @@ static ulonglong position = 0; static bool use_remote = 0; static short binlog_flags = 0; static MYSQL* mysql = NULL; -static const char* table = 0; static void dump_local_log_entries(const char* logname); static void dump_remote_log_entries(const char* logname); static void dump_log_entries(const char* logname); static void dump_remote_file(NET* net, const char* fname); -static void dump_remote_table(NET* net, const char* db, const char* table); static void die(const char* fmt, ...); static MYSQL* safe_connect(); @@ -96,8 +94,6 @@ static struct my_option my_long_options[] = {"short-form", 's', "Just show the queries, no extra info", (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"table", 't', "Get raw table dump using COM_TABLE_DUMB", (gptr*) &table, - (gptr*) &table, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "Connect to the remote server as username", (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -252,35 +248,6 @@ static void dump_log_entries(const char* logname) dump_local_log_entries(logname); } -static void dump_remote_table(NET* net, const char* db, const char* table) -{ - char buf[1024]; - char * p = buf; - uint table_len = (uint) strlen(table); - uint db_len = (uint) strlen(db); - if (table_len + db_len > sizeof(buf) - 2) - die("Buffer overrun"); - - *p++ = db_len; - memcpy(p, db, db_len); - p += db_len; - *p++ = table_len; - memcpy(p, table, table_len); - - if (simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1)) - die("Error sending the table dump command"); - - for (;;) - { - uint packet_len = my_net_read(net); - if (packet_len == 0) break; // end of file - if (packet_len == packet_error) - die("Error reading packet in table dump"); - my_fwrite(result_file, (byte*)net->read_pos, packet_len, MYF(MY_WME)); - fflush(result_file); - } -} - static int check_master_version(MYSQL* mysql) { MYSQL_RES* res = 0; @@ -516,7 +483,7 @@ int main(int argc, char** argv) MY_INIT(argv[0]); parse_args(&argc, (char***)&argv); - if (!argc && !table) + if (!argc) { usage(); return -1; @@ -525,22 +492,9 @@ int main(int argc, char** argv) if (use_remote) mysql = safe_connect(); - if (table) - { - if (!use_remote) - die("You must specify connection parameter to get table dump"); - char* db = (char*) table; - char* tbl = (char*) strchr(table, '.'); - if (!tbl) - die("You must use database.table syntax to specify the table"); - *tbl++ = 0; - dump_remote_table(&mysql->net, db, tbl); - } - else - { - while (--argc >= 0) - dump_log_entries(*(argv++)); - } + while (--argc >= 0) + dump_log_entries(*(argv++)); + if (result_file != stdout) my_fclose(result_file, MYF(0)); if (use_remote) -- cgit v1.2.1 From f3381e73832ec486f5a77ec0bb7994c39dbc13f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Jul 2003 14:00:57 -0400 Subject: made error output more detailed --- client/mysqlbinlog.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 98e03a7e8f1..842dfa28f88 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -346,7 +346,7 @@ static void dump_remote_log_entries(const char* logname) } -static int check_header(IO_CACHE* file) +static int check_header(IO_CACHE* file, const char *fname) { byte header[BIN_LOG_HEADER_SIZE]; byte buf[PROBE_HEADER_LEN]; @@ -357,7 +357,7 @@ static int check_header(IO_CACHE* file) if (my_b_read(file, header, sizeof(header))) die("Failed reading header; Probably an empty file"); if (memcmp(header, BINLOG_MAGIC, sizeof(header))) - die("File is not a binary log file"); + die("File %s is not a binary log file",fname); if (!my_b_read(file, buf, sizeof(buf))) { if (buf[4] == START_EVENT) @@ -390,14 +390,14 @@ static void dump_local_log_entries(const char* logname) if (init_io_cache(file, fd, 0, READ_CACHE, (my_off_t) position, 0, MYF(MY_WME | MY_NABP))) exit(1); - old_format = check_header(file); + old_format = check_header(file,logname); } else { if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) exit(1); - old_format = check_header(file); + old_format = check_header(file,""); if (position) { /* skip 'position' characters from stdout */ -- cgit v1.2.1 From 71373afb5c48a27bde3e80a5207a14101d740cc8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 2 Jul 2003 16:56:27 -0400 Subject: fixed bug #672 client/mysqlbinlog.cc: changed format of eof-packet for protocol 4.1 --- client/mysqlbinlog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 75b875b4f4e..109e9095b7a 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -360,7 +360,7 @@ static void dump_remote_log_entries(const char* logname) len = net_safe_read(mysql); if (len == packet_error) die("Error reading packet from server: %s", mysql_error(mysql)); - if (len == 1 && net->read_pos[0] == 254) + if (len < 8 && net->read_pos[0] == 254) break; // end of data DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n", len, net->read_pos[5])); -- cgit v1.2.1 From 2373397e13d4004816b61df38a234906eb361e0d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jul 2003 11:55:36 +0300 Subject: Cleaner implementation if INSERT ... SELECT with same tables Tests cleanup (put drop database first in tests) client/mysql.cc: Cleanup of code in last pull include/config-win.h: Remove HAVE_CHSIZE on windows as it's not 64 bit clean include/my_global.h: Portability fix mysql-test/r/drop.result: Clean up results mysql-test/r/flush.result: Clean up results mysql-test/r/grant_cache.result: Clean up results mysql-test/r/innodb.result: Clean up results mysql-test/r/insert_select.result: Clean up results mysql-test/r/merge.result: Clean up results mysql-test/r/query_cache.result: Clean up results mysql-test/t/drop.test: Clean up tests mysql-test/t/flush.test: Clean up tests mysql-test/t/grant_cache.test: Clean up tests mysql-test/t/innodb.test: Clean up tests mysql-test/t/insert_select.test: Added more tests mysql-test/t/merge.test: Test of bug 515 mysql-test/t/query_cache.test: Clean up tests mysql-test/t/symlink.test: Clean up tests sql/mysql_priv.h: Cleaner implementation if INSERT ... SELECT with same tables sql/sql_lex.h: Cleaner implementation if INSERT ... SELECT with same tables sql/sql_list.h: Indentation cleanup sql/sql_parse.cc: Cleaner implementation if INSERT ... SELECT with same tables sql/sql_yacc.yy: Cleaner implementation if INSERT ... SELECT with same tables --- client/mysql.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 171bd9cf0a8..81f4b19f7c6 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2592,14 +2592,11 @@ static void mysql_end_timer(ulong start_time,char *buff) static const char* construct_prompt() { - //erase the old prompt - if (!mysql_get_host_info(&mysql)) - return processed_prompt.ptr(); - processed_prompt.free(); - //get the date struct - time_t lclock = time(NULL); + processed_prompt.free(); // Erase the old prompt + time_t lclock = time(NULL); // Get the date struct struct tm *t = localtime(&lclock); - //parse thru the settings for the prompt + + /* parse thru the settings for the prompt */ for (char *c = current_prompt; *c ; *c++) { if (*c != PROMPT_CHAR) @@ -2608,8 +2605,7 @@ static const char* construct_prompt() { switch (*++c) { case '\0': - //stop it from going beyond if ends with % - c--; + c--; // stop it from going beyond if ends with % break; case 'c': add_int_to_prompt(++prompt_counter); -- cgit v1.2.1 From 2d5d754c8c28ca087f44f479e0fca614789b42e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2003 03:18:15 +0300 Subject: Status query on killed mysql connection results in segmentation fault (Bug #738) Added MAX_PASSWORD_LENGTH. This increased master-slave passwords to 32 bytes (Bug #766) Fixed server crash on purge master logs or show master logs when binlog is off. (Bug #733) client/mysql.cc: status query on killed mysql connection results in segmentation fault (Bug #738) configure.in: Portability fix for Unixware include/my_global.h: Removed wrong patch from previous changeset sql/mysql_priv.h: Added MAX_PASSWORD_LENGTH. This increased master-slave passwords to 32 bytes sql/slave.h: Optimized structure sql/sql_repl.cc: Memory overrun safety fixes (not critical) Fixed server crash on purge master logs or show master logs when binlog is off. (Bug #733) sql/sql_repl.h: Fixed to use right define strings/strmake.c: Fixed comment --- client/mysql.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 81f4b19f7c6..4fe832a790e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2329,7 +2329,8 @@ com_status(String *buffer __attribute__((unused)), (void) mysql_fetch_row(result); // Read eof } #ifdef HAVE_OPENSSL - if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) + if (mysql.net.vio && mysql.net.vio->ssl_ && + SSL_get_cipher(mysql.net.vio->ssl_)) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_)); else -- cgit v1.2.1 From cdb44cd45529dfece3e98b4941201cb228070159 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2003 16:06:17 -0400 Subject: fixed bug #670 --- client/mysqlbinlog.cc | 286 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 266 insertions(+), 20 deletions(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index b0175103840..ac1c9db30e6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -18,7 +18,9 @@ #undef MYSQL_SERVER #include "client_priv.h" #include +#include #include "log_event.h" +#include "include/my_sys.h" #define BIN_LOG_HEADER_SIZE 4 #define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4) @@ -49,6 +51,7 @@ static bool short_form = 0; static ulonglong offset = 0; static const char* host = "localhost"; static int port = MYSQL_PORT; +static const char* sock= MYSQL_UNIX_ADDR; static const char* user = "test"; static const char* pass = ""; static ulonglong position = 0; @@ -56,6 +59,8 @@ static bool use_remote = 0; static short binlog_flags = 0; static MYSQL* mysql = NULL; +static const char* dirname_for_local_load= 0; + static void dump_local_log_entries(const char* logname); static void dump_remote_log_entries(const char* logname); static void dump_log_entries(const char* logname); @@ -63,40 +68,170 @@ static void dump_remote_file(NET* net, const char* fname); static void die(const char* fmt, ...); static MYSQL* safe_connect(); +class Load_log_processor +{ + char target_dir_name[MY_NFILE]; + int target_dir_name_len; + DYNAMIC_ARRAY file_names; + + const char* create_file(Create_file_log_event *ce) + { + const char *bname= ce->fname + ce->fname_len -1; + while (bname>ce->fname && bname[-1]!=FN_LIBCHAR) + bname--; + + uint blen= ce->fname_len - (bname-ce->fname); + uint full_len= target_dir_name_len + blen; + char *tmp; + if (!(tmp= my_malloc(full_len + 9 + 1,MYF(MY_WME))) || + set_dynamic(&file_names,(gptr)&ce,ce->file_id)) + { + die("Could not construct local filename %s%s",target_dir_name,bname); + return 0; + } + + char *ptr= tmp; + memcpy(ptr,target_dir_name,target_dir_name_len); + ptr+= target_dir_name_len; + memcpy(ptr,bname,blen); + ptr+= blen; + sprintf(ptr,"-%08x",ce->file_id); + + ce->set_fname_outside_temp_buf(tmp,full_len); + + return tmp; + } + + void append_to_file(const char* fname, int flags, + gptr data, uint size) + { + File file; + if (((file= my_open(fname,flags,MYF(MY_WME))) < 0) || + my_write(file,(byte*) data,size,MYF(MY_WME|MY_NABP)) || + my_close(file,MYF(MY_WME))) + exit(1); + } + +public: + + Load_log_processor() + { + init_dynamic_array(&file_names,sizeof(Create_file_log_event*), + 100,100 CALLER_INFO); + } + + ~Load_log_processor() + { + destroy(); + delete_dynamic(&file_names); + } + + void init_by_dir_name(const char *atarget_dir_name) + { + char *end= strmov(target_dir_name,atarget_dir_name); + if (end[-1]!=FN_LIBCHAR) + *end++= FN_LIBCHAR; + target_dir_name_len= end-target_dir_name; + } + void init_by_file_name(const char *file_name) + { + int len= strlen(file_name); + const char *end= file_name + len - 1; + while (end>file_name && *end!=FN_LIBCHAR) + end--; + if (*end!=FN_LIBCHAR) + target_dir_name_len= 0; + else + { + target_dir_name_len= end - file_name + 1; + memmove(target_dir_name,file_name,target_dir_name_len); + } + } + void init_by_cur_dir() + { + if (my_getwd(target_dir_name,sizeof(target_dir_name),MYF(MY_WME))) + exit(1); + target_dir_name_len= strlen(target_dir_name); + } + void destroy() + { + Create_file_log_event **ptr= (Create_file_log_event**)file_names.buffer; + Create_file_log_event **end= ptr + file_names.elements; + for (; ptrfname,MYF(MY_WME)); + delete *ptr; + *ptr= 0; + } + } + } + Create_file_log_event *grab_event(uint file_id) + { + Create_file_log_event **ptr= + (Create_file_log_event**)file_names.buffer + file_id; + Create_file_log_event *res= *ptr; + *ptr= 0; + return res; + } + void process(Create_file_log_event *ce) + { + const char *fname= create_file(ce); + append_to_file(fname,O_CREAT|O_EXCL|O_BINARY|O_WRONLY,ce->block,ce->block_len); + } + void process(Append_block_log_event *ae) + { + if (ae->file_id >= file_names.elements) + die("Skiped CreateFile event for file_id: %u",ae->file_id); + Create_file_log_event* ce= + *((Create_file_log_event**)file_names.buffer + ae->file_id); + append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len); + } +}; + +Load_log_processor load_processor; + static struct my_option my_long_options[] = { #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}, #endif - {"database", 'd', "List entries for just this database (local log only)", + {"database", 'd', "List entries for just this database (local log only).", (gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"force-read", 'f', "Force reading unknown binlog events", + {"force-read", 'f', "Force reading unknown binlog events.", (gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"help", '?', "Display this help and exit", + {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Get the binlog from server", (gptr*) &host, (gptr*) &host, + {"host", 'h', "Get the binlog from server.", (gptr*) &host, (gptr*) &host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"offset", 'o', "Skip the first N entries", (gptr*) &offset, (gptr*) &offset, + {"offset", 'o', "Skip the first N entries.", (gptr*) &offset, (gptr*) &offset, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"password", 'p', "Password to connect to remote server", + {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Use port to connect to the remote server", + {"port", 'P', "Use port to connect to the remote server.", (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"position", 'j', "Start reading the binlog at position N", + {"position", 'j', "Start reading the binlog at position N.", (gptr*) &position, (gptr*) &position, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"result-file", 'r', "Direct output to a given file", 0, 0, 0, GET_STR, + {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"short-form", 's', "Just show the queries, no extra info", + {"short-form", 's', "Just show the queries, no extra info.", (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "Connect to the remote server as username", + {"socket", 'S', "Socket file to use for connection.", + (gptr*) &sock, (gptr*) &sock, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, + 0, 0}, + {"user", 'u', "Connect to the remote server as username.", (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"local-load", 'l', "Prepare files for local load in directory.", + (gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0, + GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -180,7 +315,7 @@ extern "C" my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch(optid) { + switch (optid) { #ifndef DBUG_OFF case '#': DBUG_PUSH(argument ? argument : default_dbug_option); @@ -234,7 +369,7 @@ static MYSQL* safe_connect() if(!local_mysql) die("Failed on mysql_init"); - if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, 0, 0)) + if (!mysql_real_connect(local_mysql, host, user, pass, 0, port, sock, 0)) die("failed on connect: %s", mysql_error(local_mysql)); return local_mysql; @@ -346,7 +481,7 @@ static void dump_remote_log_entries(const char* logname) } -static int check_header(IO_CACHE* file, const char *fname) +static int check_header(IO_CACHE* file) { byte header[BIN_LOG_HEADER_SIZE]; byte buf[PROBE_HEADER_LEN]; @@ -357,7 +492,7 @@ static int check_header(IO_CACHE* file, const char *fname) if (my_b_read(file, header, sizeof(header))) die("Failed reading header; Probably an empty file"); if (memcmp(header, BINLOG_MAGIC, sizeof(header))) - die("File %s is not a binary log file",fname); + die("File is not a binary log file"); if (!my_b_read(file, buf, sizeof(buf))) { if (buf[4] == START_EVENT) @@ -390,14 +525,14 @@ static void dump_local_log_entries(const char* logname) if (init_io_cache(file, fd, 0, READ_CACHE, (my_off_t) position, 0, MYF(MY_WME | MY_NABP))) exit(1); - old_format = check_header(file,logname); + old_format = check_header(file); } else { if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) exit(1); - old_format = check_header(file,""); + old_format = check_header(file); if (position) { /* skip 'position' characters from stdout */ @@ -466,17 +601,112 @@ Could not read entry at offset %s : Error in log format or read error", } if (!short_form) fprintf(result_file, "# at %s\n",llstr(old_off,llbuff)); - - ev->print(result_file, short_form, last_db); + + switch (ev->get_type_code()) { + case CREATE_FILE_EVENT: + { + Create_file_log_event* ce= (Create_file_log_event*)ev; + ce->print(result_file, short_form, last_db,true); + load_processor.process(ce); + ev= 0; + break; + } + case APPEND_BLOCK_EVENT: + ev->print(result_file, short_form, last_db); + load_processor.process((Append_block_log_event*)ev); + break; + case EXEC_LOAD_EVENT: + { + ev->print(result_file, short_form, last_db); + Execute_load_log_event *exv= (Execute_load_log_event*)ev; + Create_file_log_event *ce= load_processor.grab_event(exv->file_id); + ce->print(result_file, short_form, last_db,true); + my_free((char*)ce->fname,MYF(MY_WME)); + delete ce; + break; + } + default: + ev->print(result_file, short_form, last_db); + } } rec_count++; - delete ev; + if (ev) + delete ev; } if (fd >= 0) my_close(fd, MYF(MY_WME)); end_io_cache(file); } +#if MYSQL_VERSION_ID < 40101 + +typedef struct st_my_tmpdir +{ + char **list; + uint cur, max; +} MY_TMPDIR; + +#if defined( __WIN__) || defined(OS2) +#define DELIM ';' +#else +#define DELIM ':' +#endif + +my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist) +{ + char *end, *copy; + char buff[FN_REFLEN]; + DYNAMIC_ARRAY t_arr; + if (my_init_dynamic_array(&t_arr, sizeof(char*), 1, 5)) + return TRUE; + if (!pathlist || !pathlist[0]) + { + /* Get default temporary directory */ + pathlist=getenv("TMPDIR"); /* Use this if possible */ +#if defined( __WIN__) || defined(OS2) + if (!pathlist) + pathlist=getenv("TEMP"); + if (!pathlist) + pathlist=getenv("TMP"); +#endif + if (!pathlist || !pathlist[0]) + pathlist=(char*) P_tmpdir; + } + do + { + end=strcend(pathlist, DELIM); + convert_dirname(buff, pathlist, end); + if (!(copy=my_strdup(buff, MYF(MY_WME)))) + return TRUE; + if (insert_dynamic(&t_arr, (gptr)©)) + return TRUE; + pathlist=end+1; + } + while (*end); + freeze_size(&t_arr); + tmpdir->list=(char **)t_arr.buffer; + tmpdir->max=t_arr.elements-1; + tmpdir->cur=0; + return FALSE; +} + +char *my_tmpdir(MY_TMPDIR *tmpdir) +{ + char *dir; + dir=tmpdir->list[tmpdir->cur]; + tmpdir->cur= (tmpdir->cur == tmpdir->max) ? 0 : tmpdir->cur+1; + return dir; +} + +void free_tmpdir(MY_TMPDIR *tmpdir) +{ + uint i; + for (i=0; i<=tmpdir->max; i++) + my_free(tmpdir->list[i], MYF(0)); + my_free((gptr)tmpdir->list, MYF(0)); +} + +#endif int main(int argc, char** argv) { @@ -492,9 +722,25 @@ int main(int argc, char** argv) if (use_remote) mysql = safe_connect(); + MY_TMPDIR tmpdir; + tmpdir.list= 0; + if (!dirname_for_local_load) + { + if (init_tmpdir(&tmpdir, 0)) + exit(1); + dirname_for_local_load= my_tmpdir(&tmpdir); + } + + if (dirname_for_local_load) + load_processor.init_by_dir_name(dirname_for_local_load); + else + load_processor.init_by_cur_dir(); + while (--argc >= 0) dump_log_entries(*(argv++)); + if (tmpdir.list) + free_tmpdir(&tmpdir); if (result_file != stdout) my_fclose(result_file, MYF(0)); if (use_remote) -- cgit v1.2.1 From 1793513891acd81f6d422e3913c0c1d382afc6ed Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Jul 2003 18:15:35 -0400 Subject: fixed bug Bug #683 (Prompt for password doesn't go to console for Windows) --- client/get_password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/get_password.c b/client/get_password.c index 9928d24de32..5d78656ab0a 100644 --- a/client/get_password.c +++ b/client/get_password.c @@ -71,7 +71,7 @@ char *get_tty_password(char *opt_message) char *pos=to,*end=to+sizeof(to)-1; int i=0; DBUG_ENTER("get_tty_password"); - fprintf(stderr,opt_message ? opt_message : "Enter password: "); + _cputs(opt_message ? opt_message : "Enter password: "); for (;;) { char tmp; -- cgit v1.2.1