diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/get_password.c | 2 | ||||
-rw-r--r-- | client/mysql.cc | 15 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 68 | ||||
-rw-r--r-- | client/mysqltest.c | 3 |
4 files changed, 22 insertions, 66 deletions
diff --git a/client/get_password.c b/client/get_password.c index f187c113644..1b7b4e65a9f 100644 --- a/client/get_password.c +++ b/client/get_password.c @@ -70,7 +70,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; diff --git a/client/mysql.cc b/client/mysql.cc index ed0c1bf102b..0b6485172e4 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2645,7 +2645,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 @@ -2924,12 +2925,11 @@ static void mysql_end_timer(ulong start_time,char *buff) static const char* construct_prompt() { - //erase the old prompt - 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) @@ -2938,8 +2938,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); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 0ef0cb9b8c1..9fdda0a3853 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 MySQL AB +/* Copyright (C) 2001-2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,21 +51,19 @@ 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; static bool use_remote = 0; static short binlog_flags = 0; static MYSQL* mysql = NULL; -static const char* table = 0; - 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); 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(); @@ -224,8 +222,9 @@ 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}, + {"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}, @@ -369,7 +368,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; @@ -383,35 +382,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; @@ -491,7 +461,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])); @@ -527,8 +497,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); @@ -673,7 +643,7 @@ int main(int argc, char** argv) MY_INIT(argv[0]); parse_args(&argc, (char***)&argv); - if (!argc && !table) + if (!argc) { usage(); return -1; @@ -696,22 +666,8 @@ int main(int argc, char** argv) else load_processor.init_by_cur_dir(); - 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 (tmpdir.list) free_tmpdir(&tmpdir); if (result_file != stdout) diff --git a/client/mysqltest.c b/client/mysqltest.c index 26e72560eff..a3b5facae9c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1014,7 +1014,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) |