summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h2
-rw-r--r--client/mysqlcheck.c3
-rw-r--r--client/mysqldump.c63
3 files changed, 40 insertions, 28 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index aa1de85f489..854d205e585 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -43,5 +43,5 @@ enum options_client
OPT_PROMPT, OPT_IGN_LINES,OPT_TRANSACTION,OPT_MYSQL_PROTOCOL,
OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
OPT_COMPATIBLE, OPT_RECONNECT, OPT_DELIMITER, OPT_SECURE_AUTH,
- OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET
+ OPT_OPEN_FILES_LIMIT, OPT_SET_CHARSET, OPT_CREATE_OPTIONS
};
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 03ab45957d4..aa4c1282cc1 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -576,7 +576,8 @@ static void print_result()
else if (!status && changed)
{
printf("%s\n%-9s: %s", row[0], row[2], row[3]);
- found_error=1;
+ if (strcmp(row[2],"note"))
+ found_error=1;
}
else
printf("%-9s: %s", row[2], row[3]);
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 0951fdbcbae..1a0ef713ec7 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -37,7 +37,7 @@
** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov
*/
-#define DUMP_VERSION "10.6"
+#define DUMP_VERSION "10.7"
#include <my_global.h>
#include <my_sys.h>
@@ -91,7 +91,6 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*opt_compatible_mode_str= 0,
*err_ptr= 0;
static char compatible_mode_normal_str[255];
-static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET;
static ulong opt_compatible_mode= 0;
static uint opt_mysql_port= 0, err_len= 0;
static my_string opt_mysql_unix_port=0;
@@ -104,7 +103,9 @@ FILE *md_result_file;
static char *shared_memory_base_name=0;
#endif
static uint opt_protocol= 0;
+static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET;
static CHARSET_INFO *charset_info= &my_charset_latin1;
+const char *default_dbug_option="d:t:o,/tmp/mysqldump.trace";
const char *compatible_mode_names[]=
{
@@ -132,9 +133,6 @@ static struct my_option my_long_options[] =
"Dump all the databases. This will be same as --databases with all databases selected.",
(gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
- {"all", 'a', "Include all MySQL specific create options.",
- (gptr*) &create_options, (gptr*) &create_options, 0, GET_BOOL, NO_ARG, 1,
- 0, 0, 0, 0, 0},
{"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.",
(gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
@@ -148,7 +146,7 @@ static struct my_option my_long_options[] =
"Directory where character sets are.", (gptr*) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compatible", OPT_COMPATIBLE,
- "Change the dump to be compatible with a given mode. By default tables are dumped without any restrictions. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option does a no operation on earlier server versions.",
+ "Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option is ignored with earlier server versions.",
(gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compact", OPT_COMPACT,
@@ -160,12 +158,21 @@ static struct my_option my_long_options[] =
{"compress", 'C', "Use compression in server/client protocol.",
(gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
0, 0, 0},
+ {"create-options", OPT_CREATE_OPTIONS,
+ "Include all MySQL specific create options.",
+ (gptr*) &create_options, (gptr*) &create_options, 0, GET_BOOL, NO_ARG, 1,
+ 0, 0, 0, 0, 0},
{"databases", 'B',
"To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. 'USE db_name;' will be included in the output.",
(gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0,
0, 0, 0, 0},
- {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
- 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef DBUG_OFF
+ {"debug", '#', "This is a non-debug version. Catch this and exit",
+ 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#else
+ {"debug", '#', "Output debug log", (gptr*) &default_dbug_option,
+ (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
+#endif
{"default-character-set", OPT_DEFAULT_CHARSET,
"Set the default character set.", (gptr*) &default_charset,
(gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -244,7 +251,7 @@ static struct my_option my_long_options[] =
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"opt", OPT_OPTIMIZE,
- "Same as --add-drop-table --add-locks --all --quick --extended-insert --lock-tables --disable-keys. Enabled by default, disable with --skip-opt.",
+ "Same as --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys. Enabled by default, disable with --skip-opt.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
@@ -272,7 +279,7 @@ static struct my_option my_long_options[] =
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"skip-opt", OPT_SKIP_OPTIMIZATION,
- "Disable --opt. Disables --add-locks, --all, --quick, --extended-insert, --lock-tables and --disable-keys.",
+ "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
@@ -463,7 +470,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
opt_disable_keys=0;
break;
case '#':
- DBUG_PUSH(argument ? argument : "d:t:o");
+ DBUG_PUSH(argument ? argument : default_dbug_option);
break;
#include <sslopt-case.h>
case 'V': print_version(); exit(0);
@@ -483,7 +490,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case (int) OPT_SKIP_OPTIMIZATION:
extended_insert= opt_drop= opt_lock= quick= create_options=
- opt_disable_keys= lock_tables= 0;
+ opt_disable_keys= lock_tables= opt_set_charset= 0;
break;
case (int) OPT_COMPACT:
if (opt_compact)
@@ -655,8 +662,7 @@ static int dbConnect(char *host, char *user,char *passwd)
if (shared_memory_base_name)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
- if (opt_set_charset)
- mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
+ mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd,
NULL,opt_mysql_port,opt_mysql_unix_port,
0)))
@@ -859,11 +865,11 @@ static void print_xml_row(FILE *xml_file, const char *row_name,
{
if ((*row)[i])
{
- fputs(" ", xml_file);
+ fputc(' ', xml_file);
print_quoted_xml(xml_file, field->name, field->name_length);
fputs("=\"", xml_file);
print_quoted_xml(xml_file, (*row)[i], lengths[i]);
- fputs("\"", xml_file);
+ fputc('"', xml_file);
}
}
fputs(" />\n", xml_file);
@@ -897,6 +903,9 @@ static uint getTableStructure(char *table, char* db)
sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords));
+ if (!create_options)
+ strmov(strend(insert_pat), "/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */");
+
result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
if (!opt_xml && !mysql_query(sock,insert_pat))
@@ -978,8 +987,10 @@ static uint getTableStructure(char *table, char* db)
}
else
{
- /* fprintf(stderr, "%s: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
- my_progname, mysql_error(sock)); */
+ if (verbose)
+ fprintf(stderr,
+ "%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
+ my_progname, mysql_error(sock));
sprintf(insert_pat,"show fields from %s", result_table);
if (mysql_query(sock,insert_pat) || !(tableRes=mysql_store_result(sock)))
@@ -1172,7 +1183,7 @@ static uint getTableStructure(char *table, char* db)
else
{
fputs("/*!",sql_file);
- print_value(sql_file,tableRes,row,"type=","Type",0);
+ print_value(sql_file,tableRes,row,"engine=","Engine",0);
print_value(sql_file,tableRes,row,"","Create_options",0);
print_value(sql_file,tableRes,row,"comment=","Comment",1);
fputs(" */",sql_file);
@@ -1413,12 +1424,12 @@ static void dumpTable(uint numFields, char *table)
fputs("Aborting dump (out of memory)",stderr);
safe_exit(EX_EOM);
}
- dynstr_append(&extended_row,"\'");
+ dynstr_append(&extended_row,"'");
extended_row.length +=
mysql_real_escape_string(&mysql_connection,
&extended_row.str[extended_row.length],row[i],length);
extended_row.str[extended_row.length]='\0';
- dynstr_append(&extended_row,"\'");
+ dynstr_append(&extended_row,"'");
}
else
{
@@ -1432,9 +1443,9 @@ static void dumpTable(uint numFields, char *table)
if (field->type == FIELD_TYPE_DECIMAL)
{
/* add " signs around */
- dynstr_append(&extended_row, "\"");
+ dynstr_append(&extended_row, "'");
dynstr_append(&extended_row, ptr);
- dynstr_append(&extended_row, "\"");
+ dynstr_append(&extended_row, "'");
}
else
dynstr_append(&extended_row, ptr);
@@ -1442,7 +1453,7 @@ static void dumpTable(uint numFields, char *table)
}
}
else
- dynstr_append(&extended_row,"\'\'");
+ dynstr_append(&extended_row,"''");
}
else if (dynstr_append(&extended_row,"NULL"))
{
@@ -1486,9 +1497,9 @@ static void dumpTable(uint numFields, char *table)
else if (field->type == FIELD_TYPE_DECIMAL)
{
/* add " signs around */
- fputs("\"", md_result_file);
+ fputc('\'', md_result_file);
fputs(ptr, md_result_file);
- fputs("\"", md_result_file);
+ fputc('\'', md_result_file);
}
else
fputs(ptr, md_result_file);