summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-11-21 15:56:48 +0200
committerunknown <monty@mashka.mysql.fi>2002-11-21 15:56:48 +0200
commit0be190c0ff1ca0e035e835d97ffad10ead1c5e84 (patch)
treed3df5d3fc1abf364dcbcc8eb2305a1cf62540192 /client
parent0ee69d7bb14d38557784e57711eb3574dbaba82f (diff)
parent293d5c6e68d5ea81e97c2799a8d2b615ce2b12fb (diff)
downloadmariadb-git-0be190c0ff1ca0e035e835d97ffad10ead1c5e84.tar.gz
Merge with 4.0
BitKeeper/etc/gone: auto-union BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-.my_sys.h.swp~f6a4a7f8dae03f18: Auto merged BitKeeper/etc/config: Auto merged acconfig.h: Auto merged acinclude.m4: Auto merged Docs/manual.texi: Auto merged client/mysqlcheck.c: Auto merged client/mysqlshow.c: Auto merged include/myisam.h: Auto merged include/violite.h: Auto merged isam/pack_isam.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/Makefile.am: Auto merged myisam/ft_nlq_search.c: Auto merged myisam/mi_open.c: Auto merged myisam/mi_write.c: Auto merged myisam/sort.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_test.result: Auto merged mysql-test/r/isam.result: Auto merged mysql-test/r/rpl_replicate_do.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/func_test.test: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/rpl_rotate_logs.test: Auto merged mysql-test/t/variables.test: Auto merged mysys/hash.c: Auto merged mysys/tree.c: Auto merged scripts/Makefile.am: Auto merged sql/Makefile.am: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/hash_filo.h: Auto merged sql/hostname.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/log_event.h: Auto merged sql/mini_client.cc: Auto merged sql/opt_range.cc: Auto merged sql/opt_sum.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.h: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_analyse.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_udf.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/danish/errmsg.txt: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/french/errmsg.txt: Auto merged sql/share/german/errmsg.txt: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/italian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/table.h: Auto merged sql/unireg.cc: Auto merged sql-bench/server-cfg.sh: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged sql/ha_myisam.cc: Merge with 4.0 Removed some commented code sql/sql_db.cc: Merge with 4.0 Optimized the logging of the drop db call a bit sql/sql_update.cc: Added comment
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h4
-rw-r--r--client/mysqlbinlog.cc3
-rw-r--r--client/mysqlcheck.c44
-rw-r--r--client/mysqldump.c42
-rw-r--r--client/mysqlshow.c43
-rw-r--r--client/mysqltest.c12
6 files changed, 102 insertions, 46 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index 1d17165f2b4..eb4473cb10f 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -17,7 +17,7 @@
/* Common defines for all clients */
#include <my_global.h>
-#include <my_sys.h>
+#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
#include <mysql_embed.h>
@@ -38,4 +38,4 @@ enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_SSL_KEY, OPT_SSL_CERT, OPT_SSL_CA, OPT_SSL_CAPATH,
OPT_SSL_CIPHER, OPT_SHUTDOWN_TIMEOUT, OPT_LOCAL_INFILE,
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
- OPT_SHARED_MEMORY_BASE_NAME };
+ OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM };
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index b2100ac1596..4cf86eb31c7 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -176,7 +176,7 @@ static void dump_remote_file(NET* net, const char* fname)
}
-static my_bool
+extern "C" my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
{
@@ -210,7 +210,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
print_version();
exit(0);
case '?':
- default:
usage();
exit(0);
}
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 6b56603946a..f9719f05bf3 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -34,7 +34,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
opt_compress = 0, opt_databases = 0, opt_fast = 0,
opt_medium_check = 0, opt_quick = 0, opt_all_in_1 = 0,
opt_silent = 0, opt_auto_repair = 0, ignore_errors = 0,
- tty_password = 0;
+ tty_password = 0, opt_frm = 0;
static uint verbose = 0, opt_mysql_port=0;
static my_string opt_mysql_unix_port = 0;
static char *opt_password = 0, *current_user = 0, *default_charset = 0,
@@ -139,13 +139,17 @@ static struct my_option my_long_options[] =
{"user", 'u', "User for login if not current user.", (gptr*) &current_user,
(gptr*) &current_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
+ {"use-frm", OPT_FRM,
+ "When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.",
+ (gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+ 0},
{"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information 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}
};
-
+
static const char *load_default_groups[] = { "mysqlcheck", "client", 0 };
@@ -234,7 +238,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_password = my_strdup(argument, MYF(MY_FAE));
while (*argument) *argument++= 'x'; /* Destroy argument */
if (*start)
- start[1] = 0; /* Cut length of argument */
+ start[1] = 0; /* Cut length of argument */
}
else
tty_password = 1;
@@ -368,21 +372,25 @@ static int process_selected_tables(char *db, char **table_names, int tables)
return 1;
if (opt_all_in_1)
{
+ /*
+ We need table list in form `a`, `b`, `c`
+ that's why we need 4 more chars added to to each table name
+ space is for more readable output in logs and in case of error
+ */
char *table_names_comma_sep, *end;
int i, tot_length = 0;
for (i = 0; i < tables; i++)
- tot_length += strlen(*(table_names + i)) + 1;
+ tot_length += strlen(*(table_names + i)) + 4;
if (!(table_names_comma_sep = (char *)
- my_malloc((sizeof(char) * tot_length) + 1, MYF(MY_WME))))
+ my_malloc((sizeof(char) * tot_length) + 4, MYF(MY_WME))))
return 1;
for (end = table_names_comma_sep + 1; tables > 0;
tables--, table_names++)
{
- end = strmov(end, *table_names);
- *end++= ',';
+ end = strxmov(end, " `", *table_names, "`,", NullS);
}
*--end = 0;
handle_request_for_tables(table_names_comma_sep + 1, tot_length - 1);
@@ -409,22 +417,27 @@ static int process_all_tables_in_db(char *database)
if (opt_all_in_1)
{
+ /*
+ We need table list in form `a`, `b`, `c`
+ that's why we need 4 more chars added to to each table name
+ space is for more readable output in logs and in case of error
+ */
+
char *tables, *end;
uint tot_length = 0;
while ((row = mysql_fetch_row(res)))
- tot_length += strlen(row[0]) + 1;
+ tot_length += strlen(row[0]) + 4;
mysql_data_seek(res, 0);
- if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+1, MYF(MY_WME))))
+ if (!(tables=(char *) my_malloc(sizeof(char)*tot_length+4, MYF(MY_WME))))
{
mysql_free_result(res);
return 1;
}
for (end = tables + 1; (row = mysql_fetch_row(res)) ;)
{
- end = strmov(end, row[0]);
- *end++= ',';
+ end = strxmov(end, " `", row[0], "`,", NullS);
}
*--end = 0;
if (tot_length)
@@ -472,6 +485,7 @@ static int handle_request_for_tables(char *tables, uint length)
op = "REPAIR";
if (opt_quick) end = strmov(end, " QUICK");
if (opt_extended) end = strmov(end, " EXTENDED");
+ if (opt_frm) end = strmov(end, " USE_FRM");
break;
case DO_ANALYZE:
op = "ANALYZE";
@@ -483,10 +497,14 @@ static int handle_request_for_tables(char *tables, uint length)
if (!(query =(char *) my_malloc((sizeof(char)*(length+110)), MYF(MY_WME))))
return 1;
- sprintf(query, "%s TABLE %s %s", op, tables, options);
+ if (opt_all_in_1)
+ /* No backticks here as we added them before */
+ sprintf(query, "%s TABLE %s %s", op, tables, options);
+ else
+ sprintf(query, "%s TABLE `%s` %s", op, tables, options);
if (mysql_query(sock, query))
{
- sprintf(message, "when executing '%s TABLE `%s` %s", op, tables,options);
+ sprintf(message, "when executing '%s TABLE ... %s'", op, options);
DBerror(sock, message);
return 1;
}
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 4333058fad7..9534cc68ed4 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -305,7 +305,10 @@ static void short_usage(void)
static void write_header(FILE *sql_file, char *db_name)
{
if (opt_xml)
+ {
fprintf(sql_file,"<?xml version=\"1.0\"?>\n");
+ fprintf(sql_file,"<mysqldump>\n");
+ }
else
{
fprintf(sql_file, "-- MySQL dump %s\n--\n", DUMP_VERSION);
@@ -319,6 +322,12 @@ static void write_header(FILE *sql_file, char *db_name)
return;
} /* write_header */
+static void write_footer(FILE *sql_file)
+{
+ if (opt_xml)
+ fprintf(sql_file,"</mysqldump>");
+ fputs("\n", sql_file);
+} /* write_footer */
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
@@ -1004,7 +1013,7 @@ static void dumpTable(uint numFields, char *table)
rownr=0;
init_length=(uint) strlen(insert_pat)+4;
if (opt_xml)
- fprintf(md_result_file, "\t<%s>\n", table);
+ fprintf(md_result_file, "\t<table name=\"%s\">\n", table);
if (opt_autocommit)
fprintf(md_result_file, "set autocommit=0;\n");
@@ -1094,9 +1103,9 @@ static void dumpTable(uint numFields, char *table)
/* change any strings ("inf","nan",..) into NULL */
char *ptr = row[i];
if (opt_xml)
- fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
+ fprintf(md_result_file, "\t\t<field name=\"%s\">%s</field>\n",
field->name,
- !my_isalpha(system_charset_info,*ptr) ?ptr: "NULL",field->name);
+ !my_isalpha(system_charset_info, *ptr) ? ptr: "NULL");
else
fputs((!my_isalpha(system_charset_info,*ptr)) ?
ptr : "NULL", md_result_file);
@@ -1105,8 +1114,8 @@ static void dumpTable(uint numFields, char *table)
else
{
if (opt_xml)
- fprintf(md_result_file, "\t\t<%s>%s</%s>\n",
- field->name, "NULL", field->name);
+ fprintf(md_result_file, "\t\t<field name=\"%s\">%s</field>\n",
+ field->name, "NULL");
else
fputs("NULL", md_result_file);
}
@@ -1147,7 +1156,7 @@ static void dumpTable(uint numFields, char *table)
/* XML - close table tag and supress regular output */
if (opt_xml)
- fprintf(md_result_file, "\t</%s>\n", table);
+ fprintf(md_result_file, "\t</table>\n");
else if (extended_insert && row_break)
fputs(";\n", md_result_file); /* If not empty table */
fflush(md_result_file);
@@ -1179,7 +1188,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
{
const char *end;
- fprintf(output, "\t\t<%s>", fname);
+ fprintf(output, "\t\t<field name=\"%s\">", fname);
for (end = str + len; str != end; str++)
{
if (*str == '<')
@@ -1193,7 +1202,7 @@ static void print_quoted_xml(FILE *output, char *fname, char *str, uint len)
else
fputc(*str, output);
}
- fprintf(output, "</%s>\n", fname);
+ fprintf(output, "</field>\n");
}
static char *getTableName(int reset)
@@ -1248,13 +1257,8 @@ static int dump_databases(char **db_names)
int result=0;
for ( ; *db_names ; db_names++)
{
- /* XML edit - add database element */
- if (opt_xml)
- fprintf(md_result_file, "<%s>\n", *db_names);
if (dump_all_tables_in_db(*db_names))
result=1;
- if (opt_xml)
- fprintf(md_result_file, "</%s>\n", *db_names);
}
return result;
} /* dump_databases */
@@ -1267,7 +1271,7 @@ static int init_dumping(char *database)
DBerror(sock, "when selecting the database");
return 1; /* If --force */
}
- if (!path)
+ if (!path && !opt_xml)
{
if (opt_databases || opt_alldbs)
{
@@ -1313,6 +1317,8 @@ static int dump_all_tables_in_db(char *database)
if (init_dumping(database))
return 1;
+ if (opt_xml)
+ fprintf(md_result_file, "<database name=\"%s\">\n", database);
if (lock_tables)
{
DYNAMIC_STRING query;
@@ -1339,6 +1345,8 @@ static int dump_all_tables_in_db(char *database)
if (!dFlag && numrows > 0)
dumpTable(numrows,table);
}
+ if (opt_xml)
+ fprintf(md_result_file, "</database>\n");
if (lock_tables)
mysql_query(sock,"UNLOCK_TABLES");
return 0;
@@ -1375,12 +1383,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
DBerror(sock, "when doing refresh");
/* We shall countinue here, if --force was given */
}
+ if (opt_xml)
+ fprintf(md_result_file, "<database name=\"%s\">\n", db);
for (; tables > 0 ; tables-- , table_names++)
{
numrows = getTableStructure(*table_names, db);
if (!dFlag && numrows > 0)
dumpTable(numrows, *table_names);
}
+ if (opt_xml)
+ fprintf(md_result_file, "</database>\n");
if (lock_tables)
mysql_query(sock,"UNLOCK_TABLES");
return 0;
@@ -1514,7 +1526,7 @@ int main(int argc, char **argv)
}
}
dbDisconnect(current_host);
- fputs("\n", md_result_file);
+ write_footer(md_result_file);
if (md_result_file != stdout)
my_fclose(md_result_file, MYF(0));
my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR));
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index dc1d37b98f6..df624a02c55 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -56,6 +56,7 @@ static my_string opt_mysql_unix_port=0;
int main(int argc, char **argv)
{
int error;
+ my_bool first_argument_uses_wildcards=0;
char *wild;
MYSQL mysql;
MY_INIT(argv[0]);
@@ -63,21 +64,37 @@ int main(int argc, char **argv)
get_options(&argc,&argv);
wild=0;
- if (argc && strcont(argv[argc-1],"*?%_"))
+ if (argc)
{
- char *pos;
-
- wild=argv[--argc];
- for (pos=wild ; *pos ; pos++)
- { /* Unix wildcards to sql */
- if (*pos == '*')
- *pos='%';
- else if (*pos == '?')
- *pos='_';
- }
+ char *pos= argv[argc-1], *to;
+ for (to= pos ; *pos ; pos++, to++)
+ {
+ switch (*pos)
+ {
+ case '*':
+ *pos= '%';
+ first_argument_uses_wildcards= 1;
+ break;
+ case '?':
+ *pos= '_';
+ first_argument_uses_wildcards= 1;
+ break;
+ case '%':
+ case '_':
+ first_argument_uses_wildcards= 1;
+ break;
+ case '\\':
+ pos++;
+ default: break;
+ }
+ *to= *pos;
+ }
+ *to= *pos; // just to copy a '\0' if '\\' was used
}
+ if (first_argument_uses_wildcards)
+ wild= argv[--argc];
else if (argc == 3) /* We only want one field */
- wild=argv[--argc];
+ wild= argv[--argc];
if (argc > 2)
{
@@ -99,7 +116,7 @@ int main(int argc, char **argv)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (!(mysql_real_connect(&mysql,host,user,opt_password,
- argv[0],opt_mysql_port,opt_mysql_unix_port,
+ (first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port,
0)))
{
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 036130f2d80..9d724404edc 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -91,7 +91,7 @@
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
- OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
+ OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT, OPT_SKIP_SAFEMALLOC};
static int record = 0, opt_sleep=0;
static char *db = 0, *pass=0;
@@ -1850,6 +1850,9 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"silent", 's', "Suppress all normal output. Synonym for --quiet.",
(gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"skip-safemalloc", OPT_SKIP_SAFEMALLOC,
+ "Don't use the memory allocation checking", 0, 0, 0, GET_NO_ARG, NO_ARG,
+ 0, 0, 0, 0, 0, 0},
{"sleep", 'T', "Sleep always this many seconds on sleep commands",
(gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, 0, 0, 0,
0, 0, 0},
@@ -1949,6 +1952,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (read_server_arguments(argument))
die(NullS);
break;
+ case OPT_SKIP_SAFEMALLOC:
+#ifdef SAFEMALLOC
+ sf_malloc_quick=1;
+#endif
+ break;
case 'V':
print_version();
exit(0);
@@ -2323,6 +2331,7 @@ static void var_from_env(const char* name, const char* def_val)
static void init_var_hash()
{
VAR* v;
+ DBUG_ENTER("init_var_hash");
if (hash_init(&var_hash, system_charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed");
@@ -2332,6 +2341,7 @@ static void init_var_hash()
var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0);
hash_insert(&var_hash, (byte*)v);
+ DBUG_VOID_RETURN;
}