summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorhf@deer.mysql.r18.ru <>2003-01-20 18:59:45 +0400
committerhf@deer.mysql.r18.ru <>2003-01-20 18:59:45 +0400
commit389680e04e059cf78d3d7c929cb35c20064381fa (patch)
tree26bff9a8e2da794ce9796009e2fbd0d050252445 /client
parent1f6b6156773ae42f45cb2552cecbf52ef6964e23 (diff)
parentd14db3961d7f6839dd211ed3c136ddd8c709778c (diff)
downloadmariadb-git-389680e04e059cf78d3d7c929cb35c20064381fa.tar.gz
Conflicts resolving
Diffstat (limited to 'client')
-rw-r--r--client/client_priv.h3
-rw-r--r--client/insert_test.c1
-rw-r--r--client/mysql.cc44
-rw-r--r--client/mysqlbinlog.cc176
-rw-r--r--client/mysqldump.c178
-rw-r--r--client/mysqltest.c6
6 files changed, 344 insertions, 64 deletions
diff --git a/client/client_priv.h b/client/client_priv.h
index eb4473cb10f..b6bfc253854 100644
--- a/client/client_priv.h
+++ b/client/client_priv.h
@@ -38,4 +38,5 @@ 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_FRM };
+ OPT_SHARED_MEMORY_BASE_NAME, OPT_FRM, OPT_SKIP_OPTIMIZATION,
+ OPT_COMPATIBLE };
diff --git a/client/insert_test.c b/client/insert_test.c
index d8ca71bffce..e4eb852af52 100644
--- a/client/insert_test.c
+++ b/client/insert_test.c
@@ -34,6 +34,7 @@ int main(int argc, char **argv)
exit(1);
}
+ mysql_init(&mysql);
if (!(sock = mysql_real_connect(&mysql,NULL,NULL,NULL,argv[1],0,NULL,0)))
{
fprintf(stderr,"Couldn't connect to engine!\n%s\n",mysql_error(&mysql));
diff --git a/client/mysql.cc b/client/mysql.cc
index f13d601ee42..b7bda97a8f8 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -80,6 +80,8 @@ extern "C" {
#if defined( __WIN__) || defined(OS2)
#include <conio.h>
#else
+// readline 4.2 has own __P
+#undef __P
#include <readline/readline.h>
#define HAVE_READLINE
#endif
@@ -273,9 +275,9 @@ static const char *server_default_groups[]=
{ "server", "embedded", "mysql_SERVER", 0 };
#ifdef HAVE_READLINE
-extern "C" void add_history(char *command); /* From readline directory */
-extern "C" int read_history(char *command);
-extern "C" int write_history(char *command);
+extern "C" int add_history(const char *command); /* From readline directory */
+extern "C" int read_history(const char *command);
+extern "C" int write_history(const char *command);
static void initialize_readline (char *name);
#endif
@@ -1081,8 +1083,11 @@ static char **new_mysql_completion (const char *text, int start, int end);
if not.
*/
-char *no_completion (const char *text __attribute__ ((unused)),
- int )
+#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
+char *no_completion(const char*,int)
+#else
+int no_completion()
+#endif
{
return 0; /* No filename completion */
}
@@ -1093,12 +1098,15 @@ static void initialize_readline (char *name)
rl_readline_name = name;
/* Tell the completer that we want a crack first. */
-#if RL_READLINE_VERSION > 0x0400
- rl_attempted_completion_function = &new_mysql_completion;
- rl_completion_entry_function= &no_completion;
+#if defined(USE_NEW_READLINE_INTERFACE)
+ rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
+ rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
+#elif defined(USE_LIBEDIT_INTERFACE)
+ rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
+ rl_completion_entry_function= (CPFunction*)&no_completion;
#else
- rl_attempted_completion_function =(CPPFunction *)new_mysql_completion;
- rl_completion_entry_function= (Function *)no_completion;
+ rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
+ rl_completion_entry_function= (Function*)&no_completion;
#endif
}
@@ -1114,7 +1122,7 @@ static char **new_mysql_completion (const char *text,
int end __attribute__((unused)))
{
if (!status.batch && !quick)
-#if RL_READLINE_VERSION > 0x0400
+#if defined(USE_NEW_READLINE_INTERFACE)
return rl_completion_matches(text, new_command_generator);
#else
return completion_matches((char *)text, (CPFunction *)new_command_generator);
@@ -2387,14 +2395,12 @@ com_use(String *buffer __attribute__((unused)), char *line)
items in the array to zero first.
*/
-enum quote_type { NO_QUOTE, SQUOTE, DQUOTE, BTICK };
-
char *get_arg(char *line, my_bool get_next_arg)
{
char *ptr;
my_bool quoted= 0, valid_arg= 0;
uint count= 0;
- enum quote_type qtype= NO_QUOTE;
+ char qtype= 0;
ptr= line;
if (get_next_arg)
@@ -2415,10 +2421,9 @@ char *get_arg(char *line, my_bool get_next_arg)
}
while (my_isspace(system_charset_info, *ptr))
ptr++;
- if ((*ptr == '\'' && (qtype= SQUOTE)) ||
- (*ptr == '\"' && (qtype= DQUOTE)) ||
- (*ptr == '`' && (qtype= BTICK)))
+ if (*ptr == '\'' || *ptr == '\"' || *ptr == '`')
{
+ qtype= *ptr;
quoted= 1;
ptr++;
}
@@ -2435,10 +2440,7 @@ char *get_arg(char *line, my_bool get_next_arg)
ptr= line;
ptr+= count;
}
- else if ((!quoted && *ptr == ' ') ||
- (*ptr == '\'' && qtype == SQUOTE) ||
- (*ptr == '\"' && qtype == DQUOTE) ||
- (*ptr == '`' && qtype == BTICK))
+ else if ((!quoted && *ptr == ' ') || (quoted && *ptr == qtype))
{
*ptr= 0;
break;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 4cf86eb31c7..6dbd79e9053 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -56,6 +56,9 @@ static short binlog_flags = 0;
static MYSQL* mysql = NULL;
static const char* table = 0;
+static bool use_local_load= 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);
@@ -64,6 +67,129 @@ static void dump_remote_table(NET* net, const char* db, const char* table);
static void die(const char* fmt, ...);
static MYSQL* safe_connect();
+class Load_log_processor {
+ char target_dir_name[MY_NFILE];
+ int target_dir_name_len;
+ DYNAMIC_ARRAY file_names;
+
+ const char* create_file(Create_file_log_event *ce)
+ {
+ const char *bname= ce->fname + ce->fname_len -1;
+ while (bname>ce->fname && bname[-1]!=FN_LIBCHAR)
+ bname--;
+
+ uint blen= ce->fname_len - (bname-ce->fname);
+ uint full_len= target_dir_name_len + blen;
+ char *tmp;
+ if (!(tmp= my_malloc(full_len + 9 + 1,MYF(MY_WME))) ||
+ set_dynamic(&file_names,(gptr)&ce,ce->file_id))
+ {
+ die("Could not construct local filename %s%s",target_dir_name,bname);
+ return 0;
+ }
+
+ char *ptr= tmp;
+ memcpy(ptr,target_dir_name,target_dir_name_len);
+ ptr+= target_dir_name_len;
+ memcpy(ptr,bname,blen);
+ ptr+= blen;
+ sprintf(ptr,"-%08x",ce->file_id);
+
+ ce->set_fname_outside_temp_buf(tmp,full_len);
+
+ return tmp;
+ }
+
+ void append_to_file(const char* fname, int flags,
+ gptr data, uint size)
+ {
+ FILE *file;
+ if(!(file= my_fopen(fname,flags,MYF(MY_WME))))
+ exit(1);
+ if (my_fwrite(file,data,size,MYF(MY_WME|MY_NABP)))
+ exit(1);
+ if (my_fclose(file,MYF(MY_WME)))
+ exit(1);
+ }
+
+public:
+
+ Load_log_processor()
+ {
+ init_dynamic_array(&file_names,sizeof(Create_file_log_event*),
+ 100,100 CALLER_INFO);
+ }
+
+ ~Load_log_processor()
+ {
+ destroy();
+ delete_dynamic(&file_names);
+ }
+
+ void init_by_dir_name(const char *atarget_dir_name)
+ {
+ char *end= strmov(target_dir_name,atarget_dir_name);
+ if (end[-1]!=FN_LIBCHAR)
+ *end++= FN_LIBCHAR;
+ target_dir_name_len= end-target_dir_name;
+ }
+ void init_by_file_name(const char *file_name)
+ {
+ int len= strlen(file_name);
+ const char *end= file_name + len - 1;
+ while (end>file_name && *end!=FN_LIBCHAR)
+ end--;
+ if (*end!=FN_LIBCHAR)
+ target_dir_name_len= 0;
+ else
+ {
+ target_dir_name_len= end - file_name + 1;
+ memmove(target_dir_name,file_name,target_dir_name_len);
+ }
+ }
+ void init_by_cur_dir()
+ {
+ target_dir_name_len= 0;
+ }
+ void destroy()
+ {
+ Create_file_log_event **ptr= (Create_file_log_event**)file_names.buffer;
+ Create_file_log_event **end= ptr + file_names.elements;
+ for (; ptr<end; ptr++)
+ {
+ if (*ptr)
+ {
+ my_free((char*)(*ptr)->fname,MYF(MY_WME));
+ delete *ptr;
+ *ptr= 0;
+ }
+ }
+ }
+ Create_file_log_event *grab_event(uint file_id)
+ {
+ Create_file_log_event **ptr=
+ (Create_file_log_event**)file_names.buffer + file_id;
+ Create_file_log_event *res= *ptr;
+ *ptr= 0;
+ return res;
+ }
+ void process(Create_file_log_event *ce)
+ {
+ const char *fname= create_file(ce);
+ append_to_file (fname,O_CREAT|O_BINARY,ce->block,ce->block_len);
+ }
+ void process(Append_block_log_event *ae)
+ {
+ if (ae->file_id >= file_names.elements)
+ die("Skiped CreateFile event for file_id: %u",ae->file_id);
+ Create_file_log_event* ce=
+ *((Create_file_log_event**)file_names.buffer + ae->file_id);
+ append_to_file(ce->fname,O_APPEND|O_BINARY,ae->block,ae->block_len);
+ }
+};
+
+Load_log_processor load_processor;
+
static struct my_option my_long_options[] =
{
#ifndef DBUG_OFF
@@ -97,6 +223,9 @@ static struct my_option my_long_options[] =
{"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},
+ {"local-load", 'l', "Prepare files for local load in directory",
+ (gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0,
+ GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Print version 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}
@@ -209,6 +338,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'V':
print_version();
exit(0);
+ case 'l':
+ use_local_load= 1;
+ break;
case '?':
usage();
exit(0);
@@ -420,6 +552,8 @@ static void dump_local_log_entries(const char* logname)
MYF(MY_WME | MY_NABP)))
exit(1);
old_format = check_header(file);
+ if (use_local_load && !dirname_for_local_load)
+ load_processor.init_by_file_name(logname);
}
else
{
@@ -441,6 +575,8 @@ static void dump_local_log_entries(const char* logname)
}
file->pos_in_file=position;
file->seek_not_done=0;
+ if (use_local_load && !dirname_for_local_load)
+ load_processor.init_by_cur_dir();
}
if (!position)
@@ -495,11 +631,43 @@ Could not read entry at offset %s : Error in log format or read error",
}
if (!short_form)
fprintf(result_file, "# at %s\n",llstr(old_off,llbuff));
-
- ev->print(result_file, short_form, last_db);
+
+ if (!use_local_load)
+ ev->print(result_file, short_form, last_db);
+ else
+ {
+ switch(ev->get_type_code())
+ {
+ case CREATE_FILE_EVENT:
+ {
+ Create_file_log_event* ce= (Create_file_log_event*)ev;
+ ce->print(result_file, short_form, last_db,true);
+ load_processor.process(ce);
+ ev= 0;
+ break;
+ }
+ case APPEND_BLOCK_EVENT:
+ ev->print(result_file, short_form, last_db);
+ load_processor.process((Append_block_log_event*)ev);
+ break;
+ case EXEC_LOAD_EVENT:
+ {
+ ev->print(result_file, short_form, last_db);
+ Execute_load_log_event *exv= (Execute_load_log_event*)ev;
+ Create_file_log_event *ce= load_processor.grab_event(exv->file_id);
+ ce->print(result_file, short_form, last_db,true);
+ my_free((char*)ce->fname,MYF(MY_WME));
+ delete ce;
+ break;
+ }
+ default:
+ ev->print(result_file, short_form, last_db);
+ }
+ }
}
rec_count++;
- delete ev;
+ if (ev)
+ delete ev;
}
if (fd >= 0)
my_close(fd, MYF(MY_WME));
@@ -520,6 +688,8 @@ int main(int argc, char** argv)
if (use_remote)
mysql = safe_connect();
+ if (dirname_for_local_load)
+ load_processor.init_by_dir_name(dirname_for_local_load);
if (table)
{
diff --git a/client/mysqldump.c b/client/mysqldump.c
index 9534cc68ed4..5eabce9b038 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -36,7 +36,7 @@
** Added --single-transaction option 06/06/2002 by Peter Zaitsev
*/
-#define DUMP_VERSION "9.07"
+#define DUMP_VERSION "10.0"
#include <my_global.h>
#include <my_sys.h>
@@ -69,21 +69,25 @@
static char *add_load_option(char *ptr, const char *object,
const char *statement);
+static ulong find_set(TYPELIB *lib, const char *x, uint length,
+ char **err_pos, uint *err_len);
static char *field_escape(char *to,const char *from,uint length);
-static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick=0, extended_insert = 0,
- lock_tables=0,ignore_errors=0,flush_logs=0,replace=0,
- ignore=0,opt_drop=0,opt_keywords=0,opt_lock=0,opt_compress=0,
- opt_delayed=0,create_options=0,opt_quoted=0,opt_databases=0,
+static my_bool verbose=0,tFlag=0,cFlag=0,dFlag=0,quick= 1, extended_insert= 1,
+ lock_tables=1,ignore_errors=0,flush_logs=0,replace=0,
+ ignore=0,opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
+ opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
opt_alldbs=0,opt_create_db=0,opt_first_slave=0,
- opt_autocommit=0,opt_master_data,opt_disable_keys=0,opt_xml=0,
+ opt_autocommit=0,opt_master_data,opt_disable_keys=1,opt_xml=0,
tty_password=0,opt_single_transaction=0;
static MYSQL mysql_connection,*sock=0;
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*current_host=0,*path=0,*fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
- *where=0, *default_charset;
-static uint opt_mysql_port=0;
+ *where=0, *default_charset, *opt_compatible_mode_str= 0,
+ *err_ptr= 0;
+static ulong opt_compatible_mode= 0;
+static uint opt_mysql_port= 0, err_len= 0;
static my_string opt_mysql_unix_port=0;
static int first_error=0;
extern ulong net_buffer_length;
@@ -93,7 +97,17 @@ FILE *md_result_file;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
#endif
-static uint opt_protocol=0;
+static uint opt_protocol= 0;
+
+const char *compatible_mode_names[]=
+{
+ "MYSQL323", "MYSQL40", "POSTGRESQL", "ORACLE", "MSSQL", "DB2",
+ "SAPDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS",
+ NullS
+};
+TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
+ "", compatible_mode_names};
+
static struct my_option my_long_options[] =
{
@@ -102,13 +116,13 @@ static struct my_option my_long_options[] =
(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, 0,
+ (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, 0, 0, 0, 0, 0,
+ (gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
{"add-locks", OPT_LOCKS, "Add locks around insert statements.",
- (gptr*) &opt_lock, (gptr*) &opt_lock, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+ (gptr*) &opt_lock, (gptr*) &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
0},
{"allow-keywords", OPT_KEYWORDS,
"Allow creation of column names that are keywords.", (gptr*) &opt_keywords,
@@ -116,6 +130,10 @@ static struct my_option my_long_options[] =
{"character-sets-dir", OPT_CHARSETS_DIR,
"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: mysql323, mysql40, postgresql, oracle, mssql, db2, sapdb, 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.",
+ (gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"complete-insert", 'c', "Use complete insert statements.", (gptr*) &cFlag,
(gptr*) &cFlag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'C', "Use compression in server/client protocol.",
@@ -135,11 +153,11 @@ static struct my_option my_long_options[] =
0, 0},
{"disable-keys", 'K',
"'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (gptr*) &opt_disable_keys,
- (gptr*) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (gptr*) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"extended-insert", 'e',
"Allows utilization of the new, much faster INSERT syntax.",
(gptr*) &extended_insert, (gptr*) &extended_insert, 0, GET_BOOL, NO_ARG,
- 0, 0, 0, 0, 0, 0},
+ 1, 0, 0, 0, 0, 0},
{"fields-terminated-by", OPT_FTB,
"Fields in the textfile are terminated by ...", (gptr*) &fields_terminated,
(gptr*) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -168,7 +186,7 @@ static struct my_option my_long_options[] =
(gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
- (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"master-data", OPT_MASTER_DATA,
"This will cause the master position and filename to be appended to your output. This will automagically enable --first-slave.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
@@ -178,8 +196,8 @@ static struct my_option my_long_options[] =
0, 0, 0, 0, 0, 0},
{"single-transaction", OPT_TRANSACTION,
"Dump all tables in single transaction to get consistent snapshot. Mutually exclusive with --lock-tables.",
- (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0, GET_BOOL, NO_ARG,
- 0, 0, 0, 0, 0, 0},
+ (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"no-create-db", 'n',
"'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given.}",
(gptr*) &opt_create_db, (gptr*) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0,
@@ -192,7 +210,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",
+ "Same as --add-drop-table --add-locks --all --quick --extended-insert --lock-tables --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.",
@@ -207,7 +225,7 @@ static struct my_option my_long_options[] =
{"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory)",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"quick", 'q', "Don't buffer query, dump directly to stdout.",
- (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"quote-names",'Q', "Quote table and column names with a `",
(gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
@@ -219,6 +237,9 @@ static struct my_option my_long_options[] =
"Base name of shared memory", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name,
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.",
+ 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,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -322,6 +343,7 @@ static void write_header(FILE *sql_file, char *db_name)
return;
} /* write_header */
+
static void write_footer(FILE *sql_file)
{
if (opt_xml)
@@ -329,6 +351,7 @@ static void write_footer(FILE *sql_file)
fputs("\n", sql_file);
} /* write_footer */
+
static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument)
@@ -378,27 +401,48 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
usage();
exit(0);
case (int) OPT_OPTIMIZE:
- extended_insert=opt_drop=opt_lock=quick=create_options=opt_disable_keys=
- lock_tables=1;
+ extended_insert= opt_drop= opt_lock= quick= create_options=
+ opt_disable_keys= lock_tables= 1;
if (opt_single_transaction) lock_tables=0;
break;
+ case (int) OPT_SKIP_OPTIMIZATION:
+ extended_insert= opt_drop= opt_lock= quick= create_options=
+ opt_disable_keys= lock_tables= 0;
+ break;
case (int) OPT_TABLES:
opt_databases=0;
break;
- case OPT_MYSQL_PROTOCOL:
- {
- if ((opt_protocol = find_type(argument, &sql_protocol_typelib,0)) == ~(ulong) 0)
+ case (int) OPT_COMPATIBLE:
+ {
+ char buff[255];
+
+ opt_quoted= 1;
+ opt_compatible_mode_str= argument;
+ opt_compatible_mode= find_set(&compatible_mode_typelib,
+ argument, strlen(argument),
+ &err_ptr, &err_len);
+ if (err_len)
+ {
+ strmake(buff, err_ptr, min(sizeof(buff), err_len));
+ fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
+ exit(1);
+ }
+ break;
+ }
+ case (int) OPT_MYSQL_PROTOCOL:
{
- fprintf(stderr, "Unknown option to protocol: %s\n", argument);
- exit(1);
+ if ((opt_protocol= find_type(argument, &sql_protocol_typelib, 0))
+ == ~(ulong) 0)
+ {
+ fprintf(stderr, "Unknown option to protocol: %s\n", argument);
+ exit(1);
+ }
+ break;
}
- break;
- }
}
return 0;
}
-
static int get_options(int *argc, char ***argv)
{
int ho_error;
@@ -418,13 +462,8 @@ static int get_options(int *argc, char ***argv)
"%s: You must use option --tab with --fields-...\n", my_progname);
return(1);
}
-
- if (opt_single_transaction && lock_tables)
- {
- fprintf(stderr, "%s: You can't use --lock-tables and --single-transaction at the same time.\n", my_progname);
- return(1);
- }
-
+ if (opt_single_transaction)
+ lock_tables= 0;
if (enclosed && opt_enclosed)
{
fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname);
@@ -604,6 +643,31 @@ static uint getTableStructure(char *table, char* db)
/* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN];
+ if (opt_compatible_mode)
+ {
+ char *end;
+ uint i;
+
+ sprintf(buff, "/*!41000 SET @@sql_mode=\"");
+ end= strend(buff);
+ for (i= 0; opt_compatible_mode; opt_compatible_mode>>= 1, i++)
+ {
+ if (opt_compatible_mode & 1)
+ {
+ end= strmov(end, compatible_mode_names[i]);
+ end= strmov(end, ",");
+ }
+ }
+ end= strmov(--end, "\" */");
+ if (mysql_query(sock, buff))
+ {
+ fprintf(stderr, "%s: Can't set the compatible mode '%s' (%s)\n",
+ my_progname, table, mysql_error(sock));
+ safe_exit(EX_MYSQLERR);
+ DBUG_RETURN(0);
+ }
+ }
+
sprintf(buff,"show create table `%s`",table);
if (mysql_query(sock, buff))
{
@@ -1399,6 +1463,48 @@ static int dump_selected_tables(char *db, char **table_names, int tables)
} /* dump_selected_tables */
+
+static ulong find_set(TYPELIB *lib, const char *x, uint length,
+ char **err_pos, uint *err_len)
+{
+ const char *end= x + length;
+ ulong found= 0;
+ uint find;
+ char buff[255];
+
+ *err_pos= 0; // No error yet
+ while (end > x && my_isspace(system_charset_info, end[-1]))
+ end--;
+
+ *err_len= 0;
+ if (x != end)
+ {
+ const char *start= x;
+ for (;;)
+ {
+ const char *pos= start;
+ uint var_len;
+
+ for (; pos != end && *pos != ','; pos++) ;
+ var_len= (uint) (pos - start);
+ strmake(buff, start, min(sizeof(buff), var_len));
+ find= find_type(buff, lib, var_len);
+ if (!find)
+ {
+ *err_pos= (char*) start;
+ *err_len= var_len;
+ }
+ else
+ found|= ((longlong) 1 << (find - 1));
+ if (pos == end)
+ break;
+ start= pos + 1;
+ }
+ }
+ return found;
+}
+
+
/* Print a value with a prefix on file */
static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
const char *prefix, const char *name,
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 4fd7ad9759d..c938ec5eec0 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -42,7 +42,7 @@
**********************************************************************/
-#define MTEST_VERSION "1.26"
+#define MTEST_VERSION "1.27"
#include <my_global.h>
#include <mysql_embed.h>
@@ -684,7 +684,7 @@ int open_file(const char* name)
if (*cur_file && cur_file == file_stack_end)
die("Source directives are nesting too deep");
- if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
+ if (!(*(cur_file+1) = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
die(NullS);
cur_file++;
*++lineno=1;
@@ -1925,7 +1925,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= buff;
}
fn_format(buff, argument, "", "", 4);
- if (!(*++cur_file = my_fopen(buff, O_RDONLY, MYF(MY_WME))))
+ if (!(*++cur_file = my_fopen(buff, O_RDONLY | O_BINARY, MYF(MY_WME))))
die("Could not open %s: errno = %d", argument, errno);
break;
}