diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/get_password.c | 2 | ||||
-rw-r--r-- | client/mysql.cc | 24 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 68 | ||||
-rw-r--r-- | client/mysqltest.c | 26 |
4 files changed, 42 insertions, 78 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..b249ccbfbc5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -133,7 +133,8 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, opt_compress=0, using_opt_local_infile=0, vertical=0, line_numbers=1, column_names=1,opt_html=0, opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0, - tty_password= 0, opt_nobeep=0, opt_reconnect=1; + tty_password= 0, opt_nobeep=0, opt_reconnect=1, + default_charset_used= 0; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; static my_string opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; @@ -651,6 +652,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), strmov(mysql_charsets_dir, argument); charsets_dir = mysql_charsets_dir; break; + case OPT_DEFAULT_CHARSET: + default_charset_used= 1; + break; case OPT_DELIMITER: if (argument == disabled_my_option) strmov(delimiter, DEFAULT_DELIMITER); @@ -2563,7 +2567,8 @@ sql_real_connect(char *host,char *database,char *user,char *password, select_limit,max_join_size); mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command); } - mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); + if (default_charset_used) + mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (!mysql_real_connect(&mysql, host, user, password, database, opt_mysql_port, opt_mysql_unix_port, connect_flag | CLIENT_MULTI_QUERIES)) @@ -2645,7 +2650,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 +2930,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 +2943,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..3b814b27810 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -722,8 +722,8 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused))) int done; LINT_INIT(res); - if (mysql_query(mysql,"show status like 'Slave_running'") - || !(res=mysql_store_result(mysql))) + if (mysql_query(mysql,"show status like 'Slave_running'") || + !(res=mysql_store_result(mysql))) die("Query failed while probing slave for stop: %s", mysql_error(mysql)); if (!(row=mysql_fetch_row(res)) || !row[1]) @@ -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) @@ -2182,19 +2183,21 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) goto end; /* Ok */ } } + DBUG_PRINT("info",("i: %d expected_errors: %d", i, q->expected_errors)); + dynstr_append_mem(ds,"ERROR ",6); + replace_dynstr_append_mem(ds, mysql_sqlstate(mysql), + strlen(mysql_sqlstate(mysql))); + dynstr_append_mem(ds,": ",2); + replace_dynstr_append_mem(ds, mysql_error(mysql), + strlen(mysql_error(mysql))); + dynstr_append_mem(ds,"\n",1); if (i) { - replace_dynstr_append_mem(ds, mysql_error(mysql), - strlen(mysql_error(mysql))); - dynstr_append_mem(ds,"\n",1); verbose_msg("query '%s' failed with wrong errno %d instead of %d...", q->query, mysql_errno(mysql), q->expected_errno[0]); - error=1; + error= 1; goto end; } - replace_dynstr_append_mem(ds,mysql_error(mysql), - strlen(mysql_error(mysql))); - dynstr_append_mem(ds,"\n",1); verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql), mysql_error(mysql)); /* @@ -2607,7 +2610,8 @@ int main(int argc, char **argv) } dynstr_free(&ds_res); - if (!silent) { + if (!silent) + { if (error) printf("not ok\n"); else |