summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/Makefile.am3
-rw-r--r--client/mysql.cc4
-rw-r--r--client/mysql_upgrade.c65
-rw-r--r--client/mysqlcheck.c55
-rw-r--r--client/mysqlshow.c3
-rw-r--r--client/mysqltest.cc21
6 files changed, 97 insertions, 54 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
index bfca0ba4bb2..f4855a03797 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -123,6 +123,3 @@ link_sources:
rm -f $(srcdir)/my_user.c; \
@LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c;
echo timestamp > link_sources;
-
-# Don't update the files from bitkeeper
-%::SCCS/s.%
diff --git a/client/mysql.cc b/client/mysql.cc
index 5d6018fd910..e72f27aeeff 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -3663,7 +3663,7 @@ xmlencode_print(const char *src, uint length)
tee_fputs("NULL", PAGER);
else
{
- for (const char *p = src; length; *p++, length--)
+ for (const char *p = src; length; p++, length--)
{
const char *t;
if ((t = array_value(xmlmeta, *p)))
@@ -4833,7 +4833,7 @@ static const char *construct_prompt()
struct tm *t = localtime(&lclock);
/* parse thru the settings for the prompt */
- for (char *c = current_prompt; *c ; *c++)
+ for (char *c = current_prompt; *c ; c++)
{
if (*c != PROMPT_CHAR)
processed_prompt.append(*c);
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index a61b67d67c8..c72f13eded6 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1,4 +1,5 @@
/* Copyright (C) 2000 MySQL AB
+ Copyright (C) 2010 Monty Program 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
@@ -17,7 +18,7 @@
#include <sslopt-vars.h>
#include "../scripts/mysql_fix_privilege_tables_sql.c"
-#define VER "1.1"
+#define VER "1.2"
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
@@ -34,8 +35,9 @@
static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN];
-static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag;
-static uint my_end_arg= 0;
+static my_bool opt_force, debug_info_flag, debug_check_flag, opt_silent;
+static my_bool opt_not_used; /* For compatiblity */
+static uint my_end_arg= 0, opt_verbose;
static char *opt_user= (char*)"root";
static DYNAMIC_STRING ds_args;
@@ -62,12 +64,14 @@ static struct my_option my_long_options[]=
{
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
- {"basedir", 'b', "Not used by mysql_upgrade. Only for backward compatibility.",
+ {"basedir", 'b',
+ "Not used by mysql_upgrade. Only for backward compatibility.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR,
- "Directory for character set files.", 0,
- 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"compress", OPT_COMPRESS, "Use compression in server/client protocol.",
+ "Not used by mysql_upgrade. Only for backward compatibility.",
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ {"compress", OPT_COMPRESS,
+ "Not used by mysql_upgrade. Only for backward compatibility.",
&not_used, &not_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"datadir", 'd',
"Not used by mysql_upgrade. Only for backward compatibility.",
@@ -80,18 +84,17 @@ static struct my_option my_long_options[]=
&default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
- &debug_check_flag, &debug_check_flag, 0,
- GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ &debug_check_flag, &debug_check_flag,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"debug-info", 'T', "Print some debug info at exit.", &debug_info_flag,
&debug_info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"default-character-set", OPT_DEFAULT_CHARSET,
- "Set the default character set.", 0,
- 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ "Not used by mysql_upgrade. Only for backward compatibility.",
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade "
"has already been executed for the current version of MySQL.",
- &opt_force, &opt_force, 0,
- GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"host",'h', "Connect to host.", 0,
+ &opt_force, &opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"host", 'h', "Connect to host.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
"Password to use when connecting to server. If password is not given,"
@@ -116,6 +119,8 @@ static struct my_option my_long_options[]=
"Base name of shared memory.", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"silent", 's', "Print less information", &opt_silent,
+ &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "The socket file to use for connection.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h>
@@ -124,8 +129,7 @@ static struct my_option my_long_options[]=
{"user", 'u', "User for login if not current user.", &opt_user,
&opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Display more output about the process.",
- &opt_verbose, &opt_verbose, 0,
- GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
+ &opt_not_used, &opt_not_used, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"write-binlog", OPT_WRITE_BINLOG,
"All commands including mysqlcheck are binlogged. Enabled by default;"
"use --skip-write-binlog when commands should not be sent to replication slaves.",
@@ -173,7 +177,7 @@ static void verbose(const char *fmt, ...)
{
va_list args;
- if (!opt_verbose)
+ if (opt_silent)
return;
/* Print the verbose message */
@@ -266,6 +270,18 @@ get_one_option(int optid, const struct my_option *opt,
/* FALLTHROUGH */
case 'v': /* --verbose */
+ opt_verbose++;
+ if (argument == disabled_my_option)
+ {
+ opt_verbose= 0;
+ opt_silent= 1;
+ }
+ add_option= 0;
+ break;
+ case 's':
+ opt_verbose= 0;
+ add_option= 0;
+ break;
case 'f': /* --force */
add_option= FALSE;
break;
@@ -426,7 +442,8 @@ static void find_tool(char *tool_executable_name, const char *tool_name,
len, self_name, FN_LIBCHAR, tool_name);
}
- verbose("Looking for '%s' as: %s", tool_name, tool_executable_name);
+ if (opt_verbose)
+ verbose("Looking for '%s' as: %s", tool_name, tool_executable_name);
/*
Make sure it can be executed
@@ -496,7 +513,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
"--database=mysql",
"--batch", /* Turns off pager etc. */
force ? "--force": "--skip-force",
- ds_res ? "--silent": "",
+ ds_res || opt_silent ? "--silent": "",
"<",
query_file_path,
"2>&1",
@@ -649,6 +666,8 @@ static void create_mysql_upgrade_info_file(void)
static void print_conn_args(const char *tool_name)
{
+ if (opt_verbose < 2)
+ return;
if (conn_args.str[0])
verbose("Running '%s' with connection arguments: %s", tool_name,
conn_args.str);
@@ -664,6 +683,7 @@ static void print_conn_args(const char *tool_name)
static int run_mysqlcheck_upgrade(void)
{
+ verbose("Phase 2/3: Checking and upgrading tables");
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
@@ -672,6 +692,8 @@ static int run_mysqlcheck_upgrade(void)
"--check-upgrade",
"--all-databases",
"--auto-repair",
+ !opt_silent || opt_verbose ? "--verbose": "",
+ opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
NULL);
}
@@ -679,6 +701,7 @@ static int run_mysqlcheck_upgrade(void)
static int run_mysqlcheck_fixnames(void)
{
+ verbose("Phase 1/3: Fixing table and database names");
print_conn_args("mysqlcheck");
return run_tool(mysqlcheck_path,
NULL, /* Send output from mysqlcheck directly to screen */
@@ -687,6 +710,8 @@ static int run_mysqlcheck_fixnames(void)
"--all-databases",
"--fix-db-names",
"--fix-table-names",
+ opt_verbose ? "--verbose": "",
+ opt_silent ? "--silent": "",
opt_write_binlog ? "--write-binlog" : "--skip-write-binlog",
NULL);
}
@@ -756,7 +781,7 @@ static int run_sql_fix_privilege_tables(void)
if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory");
- verbose("Running 'mysql_fix_privilege_tables'...");
+ verbose("Phase 3/3: Running 'mysql_fix_privilege_tables'...");
run_query(mysql_fix_privilege_tables,
&ds_result, /* Collect result */
TRUE);
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 62eab5bf6e4..41249949633 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (C) 2000 MySQL AB & Jani Tolonen
+ Copyright (C) 2010 Monty Program 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
@@ -15,7 +16,7 @@
/* By Jani Tolonen, 2001-04-20, MySQL Development Team */
-#define CHECK_VERSION "2.5.0"
+#define CHECK_VERSION "2.6.0"
#include "client_priv.h"
#include <m_ctype.h>
@@ -222,24 +223,26 @@ static void usage(void)
{
print_version();
puts("By Jani Tolonen, 2001-04-20, MySQL Development Team.\n");
- puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n");
+ puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,");
puts("and you are welcome to modify and redistribute it under the GPL license.\n");
+ printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
+ printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
+ my_progname);
+ printf("OR %s [OPTIONS] --all-databases\n\n", my_progname);
puts("This program can be used to CHECK (-c, -m, -C), REPAIR (-r), ANALYZE (-a),");
puts("or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be");
puts("used at the same time. Not all options are supported by all storage engines.");
- puts("Please consult the MySQL manual for latest information about the");
- puts("above. The options -c, -r, -a, and -o are exclusive to each other, which");
+ puts("The options -c, -r, -a, and -o are exclusive to each other, which");
puts("means that the last option will be used, if several was specified.\n");
- puts("The option -c will be used by default, if none was specified. You");
- puts("can change the default behavior by making a symbolic link, or");
+ puts("The option -c (--check) will be used by default, if none was specified.");
+ puts("You can change the default behavior by making a symbolic link, or");
puts("copying this file somewhere with another name, the alternatives are:");
puts("mysqlrepair: The default option will be -r");
puts("mysqlanalyze: The default option will be -a");
puts("mysqloptimize: The default option will be -o\n");
- printf("Usage: %s [OPTIONS] database [tables]\n", my_progname);
- printf("OR %s [OPTIONS] --databases DB1 [DB2 DB3...]\n",
- my_progname);
- printf("OR %s [OPTIONS] --all-databases\n", my_progname);
+ puts("Please consult the MariaDB/MySQL knowledgebase at");
+ puts("http://kb.askmonty.org/v/mysqlcheck for latest information about");
+ puts("this program.");
print_defaults("my", load_default_groups);
my_print_help(my_long_options);
my_print_variables(my_long_options);
@@ -416,6 +419,8 @@ static int process_all_databases()
MYF(0), mysql_error(sock));
return 1;
}
+ if (verbose)
+ printf("Processing databases\n");
while ((row = mysql_fetch_row(tableres)))
{
if (process_one_db(row[0]))
@@ -429,6 +434,8 @@ static int process_all_databases()
static int process_databases(char **db_names)
{
int result = 0;
+ if (verbose)
+ printf("Processing databases\n");
for ( ; *db_names ; db_names++)
{
if (process_one_db(*db_names))
@@ -521,6 +528,7 @@ static int process_all_tables_in_db(char *database)
MYSQL_RES *res;
MYSQL_ROW row;
uint num_columns;
+ my_bool system_database= 0;
LINT_INIT(res);
if (use_db(database))
@@ -534,6 +542,9 @@ static int process_all_tables_in_db(char *database)
return 1;
}
+ if (!strcmp(database, "mysql") || !strcmp(database, "MYSQL"))
+ system_database= 1;
+
num_columns= mysql_num_fields(res);
if (opt_all_in_1 && what_to_do != DO_UPGRADE)
@@ -576,6 +587,10 @@ static int process_all_tables_in_db(char *database)
/* Skip views if we don't perform renaming. */
if ((what_to_do != DO_UPGRADE) && (num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
continue;
+ if (system_database &&
+ (!strcmp(row[0], "general_log") ||
+ !strcmp(row[0], "slow_log")))
+ continue; /* Skip logging tables */
handle_request_for_tables(row[0], fixed_name_length(row[0]));
}
@@ -624,6 +639,8 @@ static int fix_database_storage_name(const char *name)
static int process_one_db(char *database)
{
+ if (verbose)
+ puts(database);
if (what_to_do == DO_UPGRADE)
{
int rc= 0;
@@ -731,7 +748,7 @@ static void print_result()
{
MYSQL_RES *res;
MYSQL_ROW row;
- char prev[NAME_LEN*2+2];
+ char prev[(NAME_LEN+9)*2+2];
uint i;
my_bool found_error=0;
@@ -761,7 +778,15 @@ static void print_result()
printf("%-50s %s", row[0], row[3]);
else if (!status && changed)
{
- printf("%s\n%-9s: %s", row[0], row[2], row[3]);
+ /*
+ If the error message includes REPAIR TABLE, we assume it means
+ we have to run upgrade on it. In this case we write a nicer message
+ than "Please do "REPAIR TABLE""...
+ */
+ if (!strcmp(row[2],"error") && strinstr(row[3],"REPAIR TABLE") != 0)
+ printf("%-50s %s", row[0], "Needs upgrade");
+ else
+ printf("%s\n%-9s: %s", row[0], row[2], row[3]);
if (strcmp(row[2],"note"))
found_error=1;
}
@@ -780,7 +805,7 @@ static void print_result()
static int dbConnect(char *host, char *user, char *passwd)
{
DBUG_ENTER("dbConnect");
- if (verbose)
+ if (verbose > 1)
{
fprintf(stderr, "# Connecting to %s...\n", host ? host : "localhost");
}
@@ -813,7 +838,7 @@ static int dbConnect(char *host, char *user, char *passwd)
static void dbDisconnect(char *host)
{
- if (verbose)
+ if (verbose > 1)
fprintf(stderr, "# Disconnecting from %s...\n", host ? host : "localhost");
mysql_close(sock);
} /* dbDisconnect */
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 2c9a59a2d54..698516e0794 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -669,8 +669,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
char query[1024],*end;
MYSQL_RES *result;
MYSQL_ROW row;
- ulong rows;
- LINT_INIT(rows);
+ ulong UNINIT_VAR(rows);
if (mysql_select_db(mysql,db))
{
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 0a7bf9b556d..9780317689a 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -5828,7 +5828,7 @@ int read_command(struct st_command** command_ptr)
(struct st_command*) my_malloc(sizeof(*command),
MYF(MY_WME|MY_ZEROFILL))) ||
insert_dynamic(&q_lines, (uchar*) &command))
- die(NullS);
+ die("Out of memory");
command->type= Q_UNKNOWN;
read_command_buf[0]= 0;
@@ -6325,7 +6325,7 @@ void init_win_path_patterns()
}
if (insert_dynamic(&patterns, (uchar*) &p))
- die(NullS);
+ die("Out of memory");
DBUG_PRINT("info", ("p: %s", p));
while (*p)
@@ -9405,8 +9405,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
for (i=1 ; i <= found_sets ; i++)
{
pos=from[found_set[i-1].table_offset];
- rep_str[i].found= !bcmp((const uchar*) pos,
- (const uchar*) "\\^", 3) ? 2 : 1;
+ rep_str[i].found= !memcmp(pos, "\\^", 3) ? 2 : 1;
rep_str[i].replace_string=to_array[found_set[i-1].table_offset];
rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos);
rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+
@@ -9534,8 +9533,8 @@ void copy_bits(REP_SET *to,REP_SET *from)
int cmp_bits(REP_SET *set1,REP_SET *set2)
{
- return bcmp((uchar*) set1->bits,(uchar*) set2->bits,
- sizeof(uint) * set1->size_of_bits);
+ return memcmp(set1->bits, set2->bits,
+ sizeof(uint) * set1->size_of_bits);
}
@@ -9604,17 +9603,15 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
uint start_at_word(char * pos)
{
- return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) ||
- !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0);
+ return (((!memcmp(pos, "\\b",2) && pos[2]) ||
+ !memcmp(pos, "\\^", 2)) ? 1 : 0);
}
uint end_of_word(char * pos)
{
char * end=strend(pos);
- return ((end > pos+2 && !bcmp((const uchar*) end-2,
- (const uchar*) "\\b", 2)) ||
- (end >= pos+2 && !bcmp((const uchar*) end-2,
- (const uchar*) "\\$",2))) ? 1 : 0;
+ return ((end > pos+2 && !memcmp(end-2, "\\b", 2)) ||
+ (end >= pos+2 && !memcmp(end-2, "\\$",2))) ? 1 : 0;
}
/****************************************************************************