summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc174
-rw-r--r--client/mysqladmin.c28
-rw-r--r--client/mysqlbinlog.cc81
-rw-r--r--client/mysqldump.c20
-rw-r--r--client/mysqlmanager-pwgen.c7
-rw-r--r--client/mysqlmanagerc.c8
-rw-r--r--client/mysqltest.c98
7 files changed, 213 insertions, 203 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 656f8afcad5..aa4965e1119 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -343,7 +343,7 @@ int main(int argc,char *argv[])
signal(SIGINT, mysql_end); // Catch SIGINT to clean up
/*
- ** Run in interactive mode like the ingres/postgres monitor
+ Run in interactive mode like the ingres/postgres monitor
*/
put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
@@ -357,7 +357,7 @@ int main(int argc,char *argv[])
initialize_readline(my_progname);
if (!status.batch && !quick && !opt_html && !opt_xml)
{
- /*read-history from file, default ~/.mysql_history*/
+ /* read-history from file, default ~/.mysql_history*/
if (getenv("MYSQL_HISTFILE"))
histfile=my_strdup(getenv("MYSQL_HISTFILE"),MYF(MY_WME));
else if (getenv("HOME"))
@@ -438,7 +438,7 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0},
{"auto-rehash", OPT_AUTO_REHASH,
"Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.",
- (gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (gptr*) &rehash, (gptr*) &rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"no-auto-rehash", 'A',
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -488,7 +488,7 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.",
(gptr*) &line_numbers, (gptr*) &line_numbers, 0, GET_BOOL,
- NO_ARG, 0, 0, 0, 0, 0, 0},
+ NO_ARG, 1, 0, 0, 0, 0, 0},
{"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#ifndef __WIN__
@@ -590,7 +590,7 @@ static void usage(int version)
if (version)
return;
printf("\
-Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB\n\
+Copyright (C) 2002 MySQL AB\n\
This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\
and you are welcome to modify and redistribute it under the GPL license\n");
printf("Usage: %s [OPTIONS] [database]\n", my_progname);
@@ -827,8 +827,10 @@ static int read_lines(bool execute_commands)
line[0] == 0))
continue; // Skip comment lines
- /* Check if line is a mysql command line */
- /* (We want to allow help, print and clear anywhere at line start */
+ /*
+ Check if line is a mysql command line
+ (We want to allow help, print and clear anywhere at line start
+ */
if (execute_commands && (named_cmds || glob_buffer.is_empty())
&& !in_string && (com=find_command(line,0)))
{
@@ -1011,20 +1013,20 @@ static bool add_line(String &buffer,char *line,char *in_string)
return 0;
}
-/* **************************************************************** */
-/* */
-/* Interface to Readline Completion */
-/* */
-/* **************************************************************** */
+/*****************************************************************
+ Interface to Readline Completion
+******************************************************************/
#ifdef HAVE_READLINE
static char *new_command_generator(char *text, int);
static char **new_mysql_completion (char *text, int start, int end);
-/* Tell the GNU Readline library how to complete. We want to try to complete
- on command names if this is the first word in the line, or on filenames
- if not. */
+/*
+ Tell the GNU Readline library how to complete. We want to try to complete
+ on command names if this is the first word in the line, or on filenames
+ if not.
+*/
char **no_completion (char *text __attribute__ ((unused)),
char *word __attribute__ ((unused)))
@@ -1043,11 +1045,12 @@ static void initialize_readline (char *name)
rl_completion_entry_function=(Function *) no_completion;
}
-/* Attempt to complete on the contents of TEXT. START and END show the
- region of TEXT that contains the word to complete. We can use the
- entire line in case we want to do some simple parsing. Return the
- array of matches, or NULL if there aren't any. */
-
+/*
+ Attempt to complete on the contents of TEXT. START and END show the
+ region of TEXT that contains the word to complete. We can use the
+ entire line in case we want to do some simple parsing. Return the
+ array of matches, or NULL if there aren't any.
+*/
static char **new_mysql_completion (char *text,
int start __attribute__((unused)),
@@ -1067,67 +1070,72 @@ static char *new_command_generator(char *text,int state)
static entry *e;
static uint i;
- if (!state) {
+ if (!state)
textlen=(uint) strlen(text);
- }
- if (textlen>0) { /* lookup in the hash */
- if (!state) {
+ if (textlen>0)
+ { /* lookup in the hash */
+ if (!state)
+ {
uint len;
b = find_all_matches(&ht,text,(uint) strlen(text),&len);
- if (!b) {
+ if (!b)
return NullS;
- }
e = b->pData;
}
- while (e) {
+ if (e)
+ {
ptr= strdup(e->str);
e = e->pNext;
return ptr;
}
- } else { /* traverse the entire hash, ugly but works */
+ }
+ else
+ { /* traverse the entire hash, ugly but works */
- if (!state) {
- i=0;
+ if (!state)
+ {
/* find the first used bucket */
- while (i<ht.nTableSize) {
- if (ht.arBuckets[i]) {
+ for (i=0 ; i < ht.nTableSize ; i++)
+ {
+ if (ht.arBuckets[i])
+ {
b = ht.arBuckets[i];
e = b->pData;
break;
}
- i++;
}
}
ptr= NullS;
- while (e && !ptr) { /* find valid entry in bucket */
- if ((uint) strlen(e->str)==b->nKeyLength) {
+ while (e && !ptr)
+ { /* find valid entry in bucket */
+ if ((uint) strlen(e->str) == b->nKeyLength)
ptr = strdup(e->str);
- }
/* find the next used entry */
e = e->pNext;
- if (!e) { /* find the next used bucket */
+ if (!e)
+ { /* find the next used bucket */
b = b->pNext;
- if (!b) {
- i++;
- while (i<ht.nTableSize) {
- if (ht.arBuckets[i]) {
+ if (!b)
+ {
+ for (i++ ; i<ht.nTableSize; i++)
+ {
+ if (ht.arBuckets[i])
+ {
b = ht.arBuckets[i];
e = b->pData;
break;
}
- i++;
}
- } else {
- e = b->pData;
}
+ else
+ e = b->pData;
}
}
- if (ptr) {
+ if (ptr)
return ptr;
- }
}
return NullS;
}
@@ -1262,7 +1270,6 @@ You can turn off this feature to get a quicker startup with -A\n\n");
DBUG_VOID_RETURN;
}
-
/* for gnu readline */
#ifndef HAVE_INDEX
@@ -1294,13 +1301,15 @@ char *rindex(const char *s,pchar c)
#endif
#endif /* HAVE_READLINE */
+
static int reconnect(void)
{
if (!status.batch)
{
put_info("No connection. Trying to reconnect...",INFO_INFO);
(void) com_connect((String *) 0, 0);
- if(rehash) com_rehash(NULL, NULL);
+ if (rehash)
+ com_rehash(NULL, NULL);
}
if (!connected)
return put_info("Can't connect to the server\n",INFO_ERROR);
@@ -1347,10 +1356,10 @@ com_clear(String *buffer,char *line __attribute__((unused)))
/*
-** Execute command
-** Returns: 0 if ok
-** -1 if not fatal error
-** 1 if fatal error
+ Execute command
+ Returns: 0 if ok
+ -1 if not fatal error
+ 1 if fatal error
*/
@@ -1368,7 +1377,7 @@ com_go(String *buffer,char *line __attribute__((unused)))
old_buffer.copy();
}
- /* Remove garbage for nicer messages */
+ /* Remove garbage for nicer messages */
LINT_INIT(buff[0]);
remove_cntrl(*buffer);
@@ -1511,10 +1520,9 @@ static void end_pager()
static void init_tee()
{
if (opt_outfile)
- end_tee();
+ end_tee(); // This resets opt_outfile
if (!(OUTFILE= my_fopen(outfile, O_APPEND | O_WRONLY, MYF(MY_WME))))
{
- opt_outfile= 0;
init_pager();
return;
}
@@ -1867,7 +1875,7 @@ com_notee(String *buffer __attribute__((unused)),
}
/*
-** Sorry, this command is not available in Windows.
+ Sorry, this command is not available in Windows.
*/
#ifndef __WIN__
@@ -1923,7 +1931,7 @@ com_nopager(String *buffer __attribute__((unused)),
/*
-** Sorry, you can't send the result to an editor in Win32
+ Sorry, you can't send the result to an editor in Win32
*/
#ifndef __WIN__
@@ -1999,9 +2007,11 @@ com_shell(String *buffer, char *line __attribute__((unused)))
put_info("Usage: \\! shell-command", INFO_ERROR);
return -1;
}
- /* The output of the shell command does not
- get directed to the pager or the outfile */
- if(system(shell_cmd) == -1)
+ /*
+ The output of the shell command does not
+ get directed to the pager or the outfile
+ */
+ if (system(shell_cmd) == -1)
{
put_info(strerror(errno), INFO_ERROR, errno);
return -1;
@@ -2397,7 +2407,7 @@ put_info(const char *str,INFO_TYPE info_type,uint error)
}
if (info_type == INFO_ERROR)
{
- if(!opt_nobeep)
+ if (!opt_nobeep)
putchar('\007'); /* This should make a bell */
vidattr(A_STANDOUT);
if (error)
@@ -2541,18 +2551,20 @@ static void mysql_end_timer(ulong start_time,char *buff)
strmov(strend(buff),")");
}
-static const char* construct_prompt() {
+static const char* construct_prompt()
+{
//erase the old prompt
processed_prompt.free();
//get the date struct
time_t lclock = time(NULL);
struct tm *t = localtime(&lclock);
//parse thru the settings for the prompt
- for (char *c = current_prompt;*c;*c++) {
- if (*c != PROMPT_CHAR) {
+ for (char *c = current_prompt; *c ; *c++)
+ {
+ if (*c != PROMPT_CHAR)
processed_prompt.append(*c);
- }
- else {
+ else
+ {
switch (*++c) {
case '\0':
//stop it from going beyond if ends with %
@@ -2674,13 +2686,16 @@ static const char* construct_prompt() {
return processed_prompt.ptr();
}
-static void add_int_to_prompt(int toadd) {
+
+static void add_int_to_prompt(int toadd)
+{
char buffer[16];
int10_to_str(toadd,buffer,10);
processed_prompt.append(buffer);
}
-static void init_username() {
+static void init_username()
+{
my_free(full_username,MYF(MY_ALLOW_ZERO_PTR));
my_free(part_username,MYF(MY_ALLOW_ZERO_PTR));
@@ -2688,22 +2703,21 @@ static void init_username() {
LINT_INIT(result);
if (!mysql_query(&mysql,"select USER()") &&
(result=mysql_use_result(&mysql)))
- {
- MYSQL_ROW cur=mysql_fetch_row(result);
- full_username=my_strdup(cur[0],MYF(MY_WME));
- part_username=my_strdup(strtok(cur[0],"@"),MYF(MY_WME));
- (void) mysql_fetch_row(result); // Read eof
- }
+ {
+ MYSQL_ROW cur=mysql_fetch_row(result);
+ full_username=my_strdup(cur[0],MYF(MY_WME));
+ part_username=my_strdup(strtok(cur[0],"@"),MYF(MY_WME));
+ (void) mysql_fetch_row(result); // Read eof
+ }
}
-static int
-com_prompt(String *buffer, char *line __attribute__((unused))) {
+static int com_prompt(String *buffer, char *line)
+{
+ char *ptr=strchr(line, ' ');
prompt_counter = 0;
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
- current_prompt=my_strdup(strchr(line, ' ') ?
- strchr(line, ' ')+1 :
- default_prompt,MYF(MY_WME));
- if (!strchr(line, ' '))
+ current_prompt=my_strdup(ptr ? ptr+1 : default_prompt,MYF(MY_WME));
+ if (!ptr)
tee_fprintf(stdout, "Returning to default PROMPT of %s\n", default_prompt);
else
tee_fprintf(stdout, "PROMPT set to '%s'\n", current_prompt);
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index fd2a17eee31..b790880be6f 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -24,7 +24,7 @@
#endif
#define ADMIN_VERSION "8.35"
-#define MAX_MYSQL_VAR 64
+#define MAX_MYSQL_VAR 128
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */
#define MAX_TRUNC_LENGTH 3
@@ -40,9 +40,12 @@ static uint tcp_port = 0, option_wait = 0, option_silent=0;
static ulong opt_connect_timeout, opt_shutdown_timeout;
static my_string unix_port=0;
-/* When using extended-status relatively, ex_val_max_len is the estimated
- maximum length for any relative value printed by extended-status. The
- idea is to try to keep the length of output as short as possible. */
+/*
+ When using extended-status relatively, ex_val_max_len is the estimated
+ maximum length for any relative value printed by extended-status. The
+ idea is to try to keep the length of output as short as possible.
+*/
+
static uint ex_val_max_len[MAX_MYSQL_VAR];
static my_bool ex_status_printed = 0; /* First output is not relative. */
static uint ex_var_count, max_var_length, max_val_length;
@@ -235,17 +238,12 @@ int main(int argc,char *argv[])
{
int error, ho_error;
MYSQL mysql;
- char **commands;
- char** save_argv;
+ char **commands, **save_argv;
+
MY_INIT(argv[0]);
mysql_init(&mysql);
load_defaults("my",load_default_groups,&argc,&argv);
- save_argv = argv;
- /* Sasha: with the change to handle_options() we now need to do this fix
- with save_argv in all client utilities. The problem is that
- handle_options may modify argv, and that wreaks havoc with
- free_defaults()
- */
+ save_argv = argv; /* Save for free_defaults */
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
@@ -444,8 +442,10 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
char pidfile[FN_REFLEN];
my_bool got_pidfile=0;
- /* Only wait for pidfile on local connections */
- /* If pidfile doesn't exist, continue without pid file checking */
+ /*
+ Only wait for pidfile on local connections
+ If pidfile doesn't exist, continue without pid file checking
+ */
if (mysql->unix_socket)
got_pidfile= !get_pidfile(mysql, pidfile);
if (mysql_shutdown(mysql))
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 3020e105954..f7b381d72fa 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -20,7 +20,9 @@
#include <time.h>
#include "log_event.h"
-#define PROBE_HEADER_LEN (4+EVENT_LEN_OFFSET+4)
+#define BIN_LOG_HEADER_SIZE 4
+#define PROBE_HEADER_LEN (BIN_LOG_HEADER_SIZE+EVENT_LEN_OFFSET+4)
+
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
@@ -178,8 +180,7 @@ static 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 +235,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, 0, 0))
die("failed on connect: %s", mysql_error(local_mysql));
return local_mysql;
@@ -242,7 +243,7 @@ static MYSQL* safe_connect()
static void dump_log_entries(const char* logname)
{
- if(use_remote)
+ if (use_remote)
dump_remote_log_entries(logname);
else
dump_local_log_entries(logname);
@@ -254,7 +255,7 @@ static void dump_remote_table(NET* net, const char* db, const char* table)
char * p = buf;
uint table_len = (uint) strlen(table);
uint db_len = (uint) strlen(db);
- if(table_len + db_len > sizeof(buf) - 2)
+ if (table_len + db_len > sizeof(buf) - 2)
die("Buffer overrun");
*p++ = db_len;
@@ -263,14 +264,14 @@ static void dump_remote_table(NET* net, const char* db, const char* table)
*p++ = table_len;
memcpy(p, table, table_len);
- if(simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
+ if (simple_command(mysql, COM_TABLE_DUMP, buf, p - buf + table_len, 1))
die("Error sending the table dump command");
- for(;;)
+ for (;;)
{
uint packet_len = my_net_read(net);
- if(packet_len == 0) break; // end of file
- if(packet_len == packet_error)
+ 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);
@@ -284,8 +285,8 @@ static int check_master_version(MYSQL* mysql)
const char* version;
int old_format = 0;
- if (mysql_query(mysql, "SELECT VERSION()")
- || !(res = mysql_store_result(mysql)))
+ if (mysql_query(mysql, "SELECT VERSION()") ||
+ !(res = mysql_store_result(mysql)))
{
mysql_close(mysql);
die("Error checking master version: %s",
@@ -305,12 +306,12 @@ static int check_master_version(MYSQL* mysql)
die("Master reported NULL for the version");
}
- switch (*version)
- {
+ switch (*version) {
case '3':
old_format = 1;
break;
case '4':
+ case '5':
old_format = 0;
break;
default:
@@ -324,6 +325,7 @@ static int check_master_version(MYSQL* mysql)
return old_format;
}
+
static void dump_remote_log_entries(const char* logname)
{
char buf[128];
@@ -333,38 +335,38 @@ static void dump_remote_log_entries(const char* logname)
int old_format;
old_format = check_master_version(mysql);
- if(!position) position = 4; // protect the innocent from spam
- if (position < 4)
+ if (!position)
+ position = BIN_LOG_HEADER_SIZE; // protect the innocent from spam
+ if (position < BIN_LOG_HEADER_SIZE)
{
- position = 4;
+ position = BIN_LOG_HEADER_SIZE;
// warn the guity
- sql_print_error("Warning: The position in the binary log can't be less than 4.\nStarting from position 4\n");
+ sql_print_error("Warning: The position in the binary log can't be less than %d.\nStarting from position %d\n", BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE);
}
int4store(buf, position);
- int2store(buf + 4, binlog_flags);
+ int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);
len = (uint) strlen(logname);
int4store(buf + 6, 0);
memcpy(buf + 10, logname,len);
if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1))
die("Error sending the log dump command");
- for(;;)
+ for (;;)
{
const char *error;
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 == 1 && 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]));
- Log_event * ev = Log_event::read_log_event(
- (const char*) net->read_pos + 1 ,
- len - 1, &error, old_format);
+ Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 ,
+ len - 1, &error, old_format);
if (ev)
{
ev->print(result_file, short_form, last_db);
- if(ev->get_type_code() == LOAD_EVENT)
+ if (ev->get_type_code() == LOAD_EVENT)
dump_remote_file(net, ((Load_log_event*)ev)->fname);
delete ev;
}
@@ -373,10 +375,11 @@ static void dump_remote_log_entries(const char* logname)
}
}
+
static int check_header(IO_CACHE* file)
{
byte buf[PROBE_HEADER_LEN];
- int old_format;
+ int old_format=0;
my_off_t pos = my_b_tell(file);
my_b_seek(file, (my_off_t)0);
@@ -388,8 +391,6 @@ static int check_header(IO_CACHE* file)
event_len = uint4korr(buf + EVENT_LEN_OFFSET + 4);
old_format = (event_len < LOG_EVENT_HEADER_LEN + START_HEADER_LEN);
}
- else
- old_format = 0;
my_b_seek(file, pos);
return old_format;
}
@@ -425,7 +426,7 @@ static void dump_local_log_entries(const char* logname)
for (length= (my_off_t) position ; length > 0 ; length-=tmp)
{
tmp=min(length,sizeof(buff));
- if (my_b_read(file,buff, (uint) tmp))
+ if (my_b_read(file, buff, (uint) tmp))
exit(1);
}
}
@@ -435,10 +436,10 @@ static void dump_local_log_entries(const char* logname)
if (!position)
{
- char magic[4];
+ char magic[BIN_LOG_HEADER_SIZE];
if (my_b_read(file, (byte*) magic, sizeof(magic)))
die("I/O error reading binlog magic number");
- if(memcmp(magic, BINLOG_MAGIC, 4))
+ if (memcmp(magic, BINLOG_MAGIC, 4))
die("Bad magic number; The file is probably not a MySQL binary log");
}
@@ -498,7 +499,7 @@ Could not read entry at offset %s : Error in log format or read error",
rec_count++;
delete ev;
}
- if(fd >= 0)
+ if (fd >= 0)
my_close(fd, MYF(MY_WME));
end_io_cache(file);
}
@@ -509,34 +510,30 @@ int main(int argc, char** argv)
MY_INIT(argv[0]);
parse_args(&argc, (char***)&argv);
- if(!argc && !table)
+ if (!argc && !table)
{
usage();
return -1;
}
- if(use_remote)
- {
+ if (use_remote)
mysql = safe_connect();
- }
if (table)
{
- if(!use_remote)
+ if (!use_remote)
die("You must specify connection parameter to get table dump");
- char* db = (char*)table;
+ char* db = (char*) table;
char* tbl = (char*) strchr(table, '.');
- if(!tbl)
+ 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)
- {
+ while (--argc >= 0)
dump_log_entries(*(argv++));
- }
}
if (result_file != stdout)
my_fclose(result_file, MYF(0));
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 8d9e44eba1b..93352e96335 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1348,9 +1348,6 @@ int main(int argc, char **argv)
MYSQL_RES *master;
MY_INIT(argv[0]);
- /*
- ** Check out the args
- */
if (get_options(&argc, &argv))
{
my_end(0);
@@ -1374,12 +1371,16 @@ int main(int argc, char **argv)
}
if (opt_alldbs)
dump_all_databases();
- /* Only one database and selected table(s) */
else if (argc > 1 && !opt_databases)
+ {
+ /* Only one database and selected table(s) */
dump_selected_tables(*argv, (argv + 1), (argc - 1));
- /* One or more databases, all tables */
+ }
else
+ {
+ /* One or more databases, all tables */
dump_databases(argv);
+ }
if (opt_first_slave)
{
@@ -1387,14 +1388,13 @@ int main(int argc, char **argv)
{
if (mysql_query(sock, "SHOW MASTER STATUS") ||
!(master = mysql_store_result(sock)))
- {
my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s",
MYF(0), mysql_error(sock));
- }
else
{
row = mysql_fetch_row(master);
- if(row[0] && row[1]) {
+ if (row[0] && row[1])
+ {
fprintf(md_result_file,
"\n--\n-- Position to start replication from\n--\n\n");
fprintf(md_result_file,
@@ -1406,15 +1406,11 @@ int main(int argc, char **argv)
}
}
if (mysql_query(sock, "FLUSH MASTER"))
- {
my_printf_error(0, "Error: Couldn't execute 'FLUSH MASTER': %s",
MYF(0), mysql_error(sock));
- }
if (mysql_query(sock, "UNLOCK TABLES"))
- {
my_printf_error(0, "Error: Couldn't execute 'UNLOCK TABLES': %s",
MYF(0), mysql_error(sock));
- }
}
dbDisconnect(current_host);
fputs("\n", md_result_file);
diff --git a/client/mysqlmanager-pwgen.c b/client/mysqlmanager-pwgen.c
index 40126e279b5..57d91b52f49 100644
--- a/client/mysqlmanager-pwgen.c
+++ b/client/mysqlmanager-pwgen.c
@@ -105,8 +105,10 @@ void get_pass(char* pw, int len)
{
FILE* fp;
char* pw_end=pw+len;
-/* /dev/random is more secure than rand() because the seed is easy to
- predict, so we resort to rand() only if /dev/random is not available */
+ /*
+ /dev/random is more secure than rand() because the seed is easy to
+ predict, so we resort to rand() only if /dev/random is not available
+ */
if ((fp=fopen("/dev/random","r")))
{
fread(pw,len,1,fp);
@@ -129,6 +131,7 @@ void get_pass(char* pw, int len)
*pw_end=0;
}
+
int main(int argc, char** argv)
{
FILE* fp;
diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c
index f200b993147..0001a0266e6 100644
--- a/client/mysqlmanagerc.c
+++ b/client/mysqlmanagerc.c
@@ -138,6 +138,8 @@ int parse_args(int argc, char **argv)
return 0;
}
+
+
int main(int argc, char** argv)
{
MY_INIT(argv[0]);
@@ -147,7 +149,7 @@ int main(int argc, char** argv)
if (!(manager=mysql_manager_init(0)))
die("Failed in mysql_manager_init()");
if (!mysql_manager_connect(manager,host,user,pass,port))
- die("Could not connect to MySQL manager: %s(%d)",manager->last_error,
+ die("Could not connect to MySQL manager: %s (%d)",manager->last_error,
manager->last_errno);
for (;!feof(fp);)
{
@@ -157,11 +159,11 @@ int main(int argc, char** argv)
if (!quiet)
fprintf(fp_out,"<<%s",buf);
if (mysql_manager_command(manager,buf,strlen(buf)))
- die("Error in command: %s(%d)",manager->last_error,manager->last_errno);
+ die("Error in command: %s (%d)",manager->last_error,manager->last_errno);
while (!manager->eof)
{
if (mysql_manager_fetch_line(manager,buf,sizeof(buf)))
- die("Error fetching result line: %s(%d)", manager->last_error,
+ die("Error fetching result line: %s (%d)", manager->last_error,
manager->last_errno);
if (!quiet)
fprintf(fp_out,">>%s\n",buf);
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 8fad182193b..72c5c6bee5a 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -1425,7 +1425,7 @@ int do_connect(struct st_query* q)
con_port = var_port->int_val;
}
else
- con_port=atoi(con_port_str);
+ con_port=atoi(con_port_str);
p = safe_get_param(p, &con_sock, "missing connection socket");
if (*con_sock == '$')
{
@@ -1469,6 +1469,7 @@ int do_connect(struct st_query* q)
DBUG_RETURN(0);
}
+
int do_done(struct st_query* q)
{
q->type = Q_END_BLOCK;
@@ -1480,8 +1481,8 @@ int do_done(struct st_query* q)
}
else
{
- ++parser.current_line;
- --cur_block;
+ ++parser.current_line;
+ --cur_block;
}
return 0;
}
@@ -1492,14 +1493,14 @@ int do_while(struct st_query* q)
const char* expr_start, *expr_end;
VAR v;
if (cur_block == block_stack_end)
- die("Nesting too deeply");
+ die("Nesting too deeply");
if (!*block_ok)
- {
- ++false_block_depth;
- *++block_ok = 0;
- *cur_block++ = parser.current_line++;
- return 0;
- }
+ {
+ ++false_block_depth;
+ *++block_ok = 0;
+ *cur_block++ = parser.current_line++;
+ return 0;
+ }
expr_start = strchr(p, '(');
if (!expr_start)
@@ -1511,10 +1512,10 @@ int do_while(struct st_query* q)
eval_expr(&v, ++expr_start, &expr_end);
*cur_block++ = parser.current_line++;
if (!v.int_val)
- {
- *++block_ok = 0;
- false_block_depth++;
- }
+ {
+ *++block_ok = 0;
+ false_block_depth++;
+ }
else
*++block_ok = 1;
var_free(&v);
@@ -1530,45 +1531,42 @@ int safe_copy_unescape(char* dest, char* src, int size)
size--; /* just to make life easier */
- for(; p_dest - size < dest && p_src - size < src
- && (c = *p_src) != '\n' && c; ++p_src )
- {
- switch(state)
- {
- case ST_NORMAL:
- if (c == '\\')
- {
- state = ST_ESCAPED;
- }
- else
- *p_dest++ = c;
- break;
- case ST_ESCAPED:
- if ((val = hex_val(c)) > 0)
- {
- *p_dest = val;
- state = ST_HEX2;
- }
- else
- {
- state = ST_NORMAL;
- *p_dest++ = c;
- }
- break;
- case ST_HEX2:
- if ((val = hex_val(c)) > 0)
- {
- *p_dest = (*p_dest << 4) + val;
- p_dest++;
- }
- else
- *p_dest++ = c;
+ for (; p_dest - size < dest && p_src - size < src &&
+ (c = *p_src) != '\n' && c; ++p_src)
+ {
+ switch(state) {
+ case ST_NORMAL:
+ if (c == '\\')
+ state = ST_ESCAPED;
+ else
+ *p_dest++ = c;
+ break;
+ case ST_ESCAPED:
+ if ((val = hex_val(c)) > 0)
+ {
+ *p_dest = val;
+ state = ST_HEX2;
+ }
+ else
+ {
+ state = ST_NORMAL;
+ *p_dest++ = c;
+ }
+ break;
+ case ST_HEX2:
+ if ((val = hex_val(c)) > 0)
+ {
+ *p_dest = (*p_dest << 4) + val;
+ p_dest++;
+ }
+ else
+ *p_dest++ = c;
- state = ST_NORMAL;
- break;
+ state = ST_NORMAL;
+ break;
- }
}
+ }
*p_dest = 0;
return (p_dest - dest);