From e3fa685917a2c448522d46e938bff1b12a46ab89 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 12 May 2009 10:38:14 -0700 Subject: mysqldump would not dump the INFORMATION_SCHEMA even when it was explicitly requested. (Bug #33762) --- client/mysqldump.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index 323376dd8bf..efcb1820be4 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3813,6 +3813,10 @@ static int dump_all_databases() return 1; while ((row= mysql_fetch_row(tableres))) { + if (mysql_get_server_version(mysql) >= 50003 && + !my_strcasecmp(&my_charset_latin1, row[0], "information_schema")) + continue; + if (dump_all_tables_in_db(row[0])) result=1; } @@ -3827,6 +3831,10 @@ static int dump_all_databases() } while ((row= mysql_fetch_row(tableres))) { + if (mysql_get_server_version(mysql) >= 50003 && + !my_strcasecmp(&my_charset_latin1, row[0], "information_schema")) + continue; + if (dump_all_views_in_db(row[0])) result=1; } @@ -3933,10 +3941,6 @@ int init_dumping_tables(char *qdatabase) static int init_dumping(char *database, int init_func(char*)) { - if (mysql_get_server_version(mysql) >= 50003 && - !my_strcasecmp(&my_charset_latin1, database, "information_schema")) - return 1; - if (mysql_select_db(mysql, database)) { DB_error(mysql, "when selecting the database"); @@ -3995,6 +3999,7 @@ static int dump_all_tables_in_db(char *database) DBUG_RETURN(1); if (opt_xml) print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS); + if (lock_tables) { DYNAMIC_STRING query; @@ -4228,7 +4233,10 @@ static int dump_selected_tables(char *db, char **table_names, int tables) } end= pos; - if (lock_tables) + /* Can't LOCK TABLES in INFORMATION_SCHEMA, so don't try. */ + if (lock_tables && + !(mysql_get_server_version(mysql) >= 50003 && + !my_strcasecmp(&my_charset_latin1, db, "information_schema"))) { if (mysql_real_query(mysql, lock_tables_query.str, lock_tables_query.length-1)) -- cgit v1.2.1 From 883ddef98a48badfec3d7be6092839d893be817a Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 12 May 2009 10:45:40 -0700 Subject: mysqlimport was not always compiled correctly to allow thread support, required for the --use-threads option. (Bug #32991) --- client/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/Makefile.am b/client/Makefile.am index 94db565ba37..ab5bc8d601a 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -71,7 +71,7 @@ mysqldump_SOURCES= mysqldump.c \ $(top_srcdir)/mysys/mf_getdate.c mysqlimport_SOURCES= mysqlimport.c - +mysqlimport_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ -- cgit v1.2.1 From 2c77ef3ca3dfe19576ba3e4ea67e97d20864655f Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Fri, 15 May 2009 13:12:20 -0700 Subject: Remove out-of-date and unnecessary comment in source code about what versions are supported. (Bug #42021) --- client/mysqlbinlog.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 2c2023ae129..2c74d745f01 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -17,10 +17,8 @@ TODO: print the catalog (some USE catalog.db ????). - Standalone program to read a MySQL binary log (or relay log); - can read files produced by 3.23, 4.x, 5.0 servers. + Standalone program to read a MySQL binary log (or relay log). - Can read binlogs from 3.23/4.x/5.0 and relay logs from 4.x/5.0. Should be able to read any file of these categories, even with --start-position. An important fact: the Format_desc event of the log is at most the 3rd event -- cgit v1.2.1 From b6ff6952317e55a69ec7b0c73c867d5bd031bb44 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Fri, 15 May 2009 13:25:22 -0700 Subject: Add usage for --base64-output=DECODE-ROWS and note that UNSPEC is intentionally unmentioned (it is just a placeholder). (Bug #41403) --- client/mysqlbinlog.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 2c74d745f01..aeaf49b5a15 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -932,10 +932,13 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"base64-output", OPT_BASE64_OUTPUT_MODE, + /* 'unspec' is not mentioned because it is just a placeholder. */ "Determine when the output statements should be base64-encoded BINLOG " "statements: 'never' disables it and works only for binlogs without " "row-based events; 'auto' is the default and prints base64 only when " "necessary (i.e., for row-based events and format description events); " + "'decode-rows' suppresses BINLOG statements for row events, but does " + "not exit as an error if a row event is found, unlike 'never'; " "'always' prints base64 whenever possible. 'always' is for debugging " "only and should not be used in a production system. The default is " "'auto'. --base64-output is a short form for --base64-output=always." -- cgit v1.2.1 From caba34a1b4c2021ff99f4869f43587ea73fe3061 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 12:52:51 -0700 Subject: The output of mysqldump --tab for views included a DROP TABLE statement without the IF EXISTS qualifier even though no temporary table is created as for all-in-one dumps including views. (Bug #37377) --- client/mysqldump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index efcb1820be4..87b78cb41e1 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4802,7 +4802,8 @@ static my_bool get_view_structure(char *table, char* db) result_table); check_io(sql_file); } - fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table); + /* Table might not exist if this view was dumped with --tab. */ + fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n", opt_quoted_table); if (opt_drop) { fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n", -- cgit v1.2.1 From c2fcd6b26dea5fe1bbcd860a5c3d508cb19f71b7 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 14:19:18 -0700 Subject: mysqladmin did not have enough space allocated for tracking all variables when using --vertical or --relative with extended-status. (Bug #40395) This patch simply increases the buffer size and adds an assert to check that it is big enough -- a more comprehensive fix would dynamically allocate the appropriate buffers. --- client/mysqladmin.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 9865b67bb3b..09821d6a995 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -24,7 +24,7 @@ #include #define ADMIN_VERSION "8.42" -#define MAX_MYSQL_VAR 256 +#define MAX_MYSQL_VAR 512 #define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ #define MAX_TRUNC_LENGTH 3 @@ -743,6 +743,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) mysql_error(mysql)); return -1; } + + DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR); + if (!opt_vertical) print_header(res); else -- cgit v1.2.1 From 8b218c54d40f97e132f592a05473ec93ff8d52b9 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Mon, 18 May 2009 18:23:43 -0700 Subject: mysqlslap didn't correctly handle --csv with no argument. (Bug #44412) --- client/mysqlslap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 4cf8c7204ed..3c6a38228af 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -565,8 +565,7 @@ static struct my_option my_long_options[] = REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"csv", OPT_SLAP_CSV, "Generate CSV output to named file or to stdout if no file is named.", - (uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR, - OPT_ARG, 0, 0, 0, 0, 0, 0}, + NULL, NULL, 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}, @@ -740,6 +739,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), DBUG_PUSH(argument ? argument : default_dbug_option); debug_check_flag= 1; break; + case OPT_SLAP_CSV: + if (!argument) + argument= (char *)"-"; /* use stdout */ + opt_csv_str= argument; + break; #include case 'V': print_version(); -- cgit v1.2.1 From 00920ce29b42c7cf6c5e25cd17ec36b0c1a9f15b Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 10:17:05 -0700 Subject: The mysql command-line client didn't implement the readline magic-space command, which bash does, which could result in a user accidentally disabling the use of the space key in the mysql command-line client. (Bug #27439) --- client/mysql.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 8de3cfee041..5752017bbff 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2296,8 +2296,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end); */ #if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int); extern "C" char *no_completion(const char*,int) #elif defined(USE_LIBEDIT_INTERFACE) +static int fake_magic_space(const char *, int); extern "C" int no_completion(const char*,int) #else extern "C" char *no_completion() @@ -2374,6 +2376,18 @@ static int not_in_history(const char *line) return 1; } + +#if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int) +#else +static int fake_magic_space(const char *, int) +#endif +{ + rl_insert(1, ' '); + return 0; +} + + static void initialize_readline (char *name) { /* Allow conditional parsing of the ~/.inputrc file. */ @@ -2383,12 +2397,15 @@ static void initialize_readline (char *name) #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; + + rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1); #elif defined(USE_LIBEDIT_INTERFACE) #ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); /* so as libedit use isprint */ #endif rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion; + rl_add_defun("magic-space", (Function*)&fake_magic_space, -1); #else rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion; -- cgit v1.2.1 From eb1261502c361df2ae60713785068d45c1689cb2 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 10:39:03 -0700 Subject: mysql_upgrade ignored the --basedir and --datadir arguments as it has no use for them, but it did so silently. (Bug #36558) --- client/mysql_upgrade.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cbc60d8acad..82bbf440bb4 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -251,8 +251,12 @@ get_one_option(int optid, const struct my_option *opt, break; case 'b': /* --basedir */ - case 'v': /* --verbose */ case 'd': /* --datadir */ + fprintf(stderr, "%s: the '--%s' option is always ignored\n", + my_progname, optid == 'b' ? "basedir" : "datadir"); + /* FALLTHROUGH */ + + case 'v': /* --verbose */ case 'f': /* --force */ add_option= FALSE; break; -- cgit v1.2.1 From 16aeb5ad3df92d4459e5c3e83b401e17a926d6b5 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 15:26:57 -0700 Subject: Table identifiers and file names were not quoted and escaped correctly by mysqlimport. (Bug #28071) --- client/mysqlimport.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ec418244f3d..5a8fabd4da7 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -303,7 +303,8 @@ static int get_options(int *argc, char ***argv) static int write_to_table(char *filename, MYSQL *mysql) { char tablename[FN_REFLEN], hard_path[FN_REFLEN], - sql_statement[FN_REFLEN*16+256], *end; + escaped_name[FN_REFLEN * 2 + 1], + sql_statement[FN_REFLEN*16+256], *end, *pos; DBUG_ENTER("write_to_table"); DBUG_PRINT("enter",("filename: %s",filename)); @@ -338,15 +339,24 @@ static int write_to_table(char *filename, MYSQL *mysql) fprintf(stdout, "Loading data from SERVER file: %s into %s\n", hard_path, tablename); } + mysql_real_escape_string(mysql, escaped_name, hard_path, strlen(hard_path)); sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'", opt_low_priority ? "LOW_PRIORITY" : "", - opt_local_file ? "LOCAL" : "", hard_path); + opt_local_file ? "LOCAL" : "", escaped_name); end= strend(sql_statement); if (replace) end= strmov(end, " REPLACE"); if (ignore) end= strmov(end, " IGNORE"); - end= strmov(strmov(end, " INTO TABLE "), tablename); + end= strmov(end, " INTO TABLE `"); + /* Turn any ` into `` in table name. */ + for (pos= tablename; *pos; pos++) + { + if (*pos == '`') + *end++= '`'; + *end++= *pos; + } + end= strmov(end, "`"); if (fields_terminated || enclosed || opt_enclosed || escaped) end= strmov(end, " FIELDS"); -- cgit v1.2.1 From 8533206280e9423a91d51ee40e5b4569620a2837 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 12:58:01 -0700 Subject: Fix warning in use of strlen(). --- client/mysqlimport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 5a8fabd4da7..38a6e5fa3e6 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -339,7 +339,8 @@ static int write_to_table(char *filename, MYSQL *mysql) fprintf(stdout, "Loading data from SERVER file: %s into %s\n", hard_path, tablename); } - mysql_real_escape_string(mysql, escaped_name, hard_path, strlen(hard_path)); + mysql_real_escape_string(mysql, escaped_name, hard_path, + (unsigned long) strlen(hard_path)); sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'", opt_low_priority ? "LOW_PRIORITY" : "", opt_local_file ? "LOCAL" : "", escaped_name); -- cgit v1.2.1 From 66f12372c1fbd915a83f4de2dc39081d5a556c06 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 17:04:44 -0700 Subject: The mysql command-line client would include superfluous spaces at the end of some result set lines. (Bug #29622) --- client/mysql.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 5752017bbff..5dbcc5eabba 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3319,6 +3319,9 @@ print_table_data(MYSQL_RES *result) uint visible_length; uint extra_padding; + if (off) + (void) tee_fputs(" ", PAGER); + if (cur[off] == NULL) { buffer= "NULL"; @@ -3353,7 +3356,7 @@ print_table_data(MYSQL_RES *result) else tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE); } - tee_fputs(" | ", PAGER); + tee_fputs(" |", PAGER); } (void) tee_fputs("\n", PAGER); } -- cgit v1.2.1 From 89a6be64380a7ea480c566474c6a103a799d7071 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 17:25:10 -0700 Subject: mysqladmin --count=X --sleep=Y would always delay Y seconds after the last iteration before exiting. (Bug #42639) --- client/mysqladmin.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 09821d6a995..a4e7c5ad0c9 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -371,7 +371,7 @@ int main(int argc,char *argv[]) } else { - while (!interrupted && (!opt_count_iterations || nr_iterations)) + while (!interrupted) { new_line = 0; if ((error=execute_commands(&mysql,argc,commands))) @@ -395,11 +395,11 @@ int main(int argc,char *argv[]) } if (interval) { + if (opt_count_iterations && --nr_iterations == 0) + break; sleep(interval); if (new_line) puts(""); - if (opt_count_iterations) - nr_iterations--; } else break; -- cgit v1.2.1 From f8e24020847fe98660c15b03258d3a4f6453d819 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Wed, 20 May 2009 18:31:10 -0700 Subject: mysqlcheck failed to fix table names when using the --fix-table-names and --all-in-1 options together. (Bug #31821) --- client/mysqlcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1bdb28f5a11..83d2006b597 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -442,7 +442,7 @@ static int process_selected_tables(char *db, char **table_names, int tables) { if (use_db(db)) return 1; - if (opt_all_in_1) + if (opt_all_in_1 && what_to_do != DO_UPGRADE) { /* We need table list in form `a`, `b`, `c` @@ -536,7 +536,7 @@ static int process_all_tables_in_db(char *database) num_columns= mysql_num_fields(res); - if (opt_all_in_1) + if (opt_all_in_1 && what_to_do != DO_UPGRADE) { /* We need table list in form `a`, `b`, `c` -- cgit v1.2.1 From 23c0cf38bf65d84a934f4a2755377241d50c1fb5 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 27 May 2009 12:24:25 +0400 Subject: Bug #44638: mysql_upgrade, mysqlcheck output instance unclear Dump all connection-related arguments when running mysqlcheck from mysql_upgrade. No test case, since the output depends on the test suite configuration and platform. --- client/mysql_upgrade.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index cbc60d8acad..bbc0e0f57ec 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -39,6 +39,7 @@ static uint my_end_arg= 0; static char *opt_user= (char*)"root"; static DYNAMIC_STRING ds_args; +static DYNAMIC_STRING conn_args; static char *opt_password= 0; static my_bool tty_password= 0; @@ -135,6 +136,7 @@ static void free_used_memory(void) free_defaults(defaults_argv); dynstr_free(&ds_args); + dynstr_free(&conn_args); } @@ -204,7 +206,7 @@ static void add_one_option(DYNAMIC_STRING* ds, } } dynstr_append_os_quoted(ds, "--", opt->name, eq, arg, NullS); - dynstr_append(&ds_args, " "); + dynstr_append(ds, " "); } @@ -256,6 +258,15 @@ get_one_option(int optid, const struct my_option *opt, case 'f': /* --force */ add_option= FALSE; break; + + case 'h': /* --host */ + case 'W': /* --pipe */ + case 'P': /* --port */ + case 'S': /* --socket */ + case OPT_MYSQL_PROTOCOL: /* --protocol */ + case OPT_SHARED_MEMORY_BASE_NAME: /* --shared-memory-base-name */ + add_one_option(&conn_args, opt, argument); + break; } if (add_option) @@ -603,6 +614,20 @@ static void create_mysql_upgrade_info_file(void) } +/* + Print connection-related arguments. +*/ + +static void print_conn_args(const char *tool_name) +{ + if (conn_args.str[0]) + verbose("Running '%s' with connection arguments: %s", tool_name, + conn_args.str); + else + verbose("Running '%s with default connection arguments", tool_name); +} + + /* Check and upgrade(if neccessary) all tables in the server using "mysqlcheck --check-upgrade .." @@ -610,7 +635,7 @@ static void create_mysql_upgrade_info_file(void) static int run_mysqlcheck_upgrade(void) { - verbose("Running 'mysqlcheck'..."); + print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", @@ -624,7 +649,7 @@ static int run_mysqlcheck_upgrade(void) static int run_mysqlcheck_fixnames(void) { - verbose("Running 'mysqlcheck'..."); + print_conn_args("mysqlcheck"); return run_tool(mysqlcheck_path, NULL, /* Send output from mysqlcheck directly to screen */ "--no-defaults", @@ -753,7 +778,8 @@ int main(int argc, char **argv) strncpy(self_name, argv[0], FN_REFLEN); } - if (init_dynamic_string(&ds_args, "", 512, 256)) + if (init_dynamic_string(&ds_args, "", 512, 256) || + init_dynamic_string(&conn_args, "", 512, 256)) die("Out of memory"); load_defaults("my", load_default_groups, &argc, &argv); -- cgit v1.2.1 From 7eeff66cba2c517c74533b5a4b0a9c794c4586da Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Wed, 27 May 2009 15:16:21 +0200 Subject: Bug#34861: mysqldump with --tab gives weird output for triggers. mysqldump --tab still dumped triggers to stdout rather than to individual tables. We now append triggers to the .sql file for the corresponding table. --events and --routines correspond to a database rather than a table and will still go to stdout with --tab unless redirected with --result-file (-r). --- client/mysqldump.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index 323376dd8bf..38e37aecba6 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1397,18 +1397,19 @@ static char *cover_definer_clause_in_sp(const char *def_str, SYNOPSIS open_sql_file_for_table name name of the table or view + flags flags (as per "man 2 open") RETURN VALUES 0 Failed to open file > 0 Handle of the open file */ -static FILE* open_sql_file_for_table(const char* table) +static FILE* open_sql_file_for_table(const char* table, int flags) { FILE* res; char filename[FN_REFLEN], tmp_path[FN_REFLEN]; convert_dirname(tmp_path,path,NullS); res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4), - O_WRONLY, MYF(MY_WME)); + flags, MYF(MY_WME)); return res; } @@ -2290,7 +2291,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(0); write_header(sql_file, db); @@ -2501,7 +2502,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, { if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(0); write_header(sql_file, db); } @@ -2725,12 +2726,10 @@ continue_xml: DBUG_RETURN((uint) num_fields); } /* get_table_structure */ -static void dump_trigger_old(MYSQL_RES *show_triggers_rs, +static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs, MYSQL_ROW *show_trigger_row, const char *table_name) { - FILE *sql_file= md_result_file; - char quoted_table_name_buf[NAME_LEN * 2 + 3]; char *quoted_table_name= quote_name(table_name, quoted_table_name_buf, 1); @@ -2796,11 +2795,10 @@ static void dump_trigger_old(MYSQL_RES *show_triggers_rs, DBUG_VOID_RETURN; } -static int dump_trigger(MYSQL_RES *show_create_trigger_rs, +static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs, const char *db_name, const char *db_cl_name) { - FILE *sql_file= md_result_file; MYSQL_ROW row; int db_cl_altered= FALSE; @@ -2864,22 +2862,28 @@ static int dump_triggers_for_table(char *table_name, char *db_name) uint old_opt_compatible_mode= opt_compatible_mode; MYSQL_RES *show_triggers_rs; MYSQL_ROW row; + FILE *sql_file= md_result_file; char db_cl_name[MY_CS_NAME_SIZE]; + int ret= TRUE; DBUG_ENTER("dump_triggers_for_table"); DBUG_PRINT("enter", ("db: %s, table_name: %s", db_name, table_name)); + if (path && !(sql_file= open_sql_file_for_table(table_name, + O_WRONLY | O_APPEND))) + DBUG_RETURN(1); + /* Do not use ANSI_QUOTES on triggers in dump */ opt_compatible_mode&= ~MASK_ANSI_QUOTES; /* Get database collation. */ if (switch_character_set_results(mysql, "binary")) - DBUG_RETURN(TRUE); + goto done; if (fetch_db_collation(db_name, db_cl_name, sizeof (db_cl_name))) - DBUG_RETURN(TRUE); + goto done; /* Get list of triggers. */ @@ -2888,7 +2892,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name) quote_for_like(table_name, name_buff)); if (mysql_query_with_error_report(mysql, &show_triggers_rs, query_buff)) - DBUG_RETURN(TRUE); + goto done; /* Dump triggers. */ @@ -2909,17 +2913,15 @@ static int dump_triggers_for_table(char *table_name, char *db_name) provide all the necessary information to restore trigger properly. */ - dump_trigger_old(show_triggers_rs, &row, table_name); + dump_trigger_old(sql_file, show_triggers_rs, &row, table_name); } else { MYSQL_RES *show_create_trigger_rs= mysql_store_result(mysql); if (!show_create_trigger_rs || - dump_trigger(show_create_trigger_rs, db_name, db_cl_name)) - { - DBUG_RETURN(TRUE); - } + dump_trigger(sql_file, show_create_trigger_rs, db_name, db_cl_name)) + goto done; mysql_free_result(show_create_trigger_rs); } @@ -2929,7 +2931,7 @@ static int dump_triggers_for_table(char *table_name, char *db_name) mysql_free_result(show_triggers_rs); if (switch_character_set_results(mysql, default_charset)) - DBUG_RETURN(TRUE); + goto done; /* make sure to set back opt_compatible mode to @@ -2937,7 +2939,13 @@ static int dump_triggers_for_table(char *table_name, char *db_name) */ opt_compatible_mode=old_opt_compatible_mode; - DBUG_RETURN(FALSE); + ret= FALSE; + +done: + if (path) + my_fclose(sql_file, MYF(0)); + + DBUG_RETURN(ret); } static void add_load_option(DYNAMIC_STRING *str, const char *option, @@ -4782,7 +4790,7 @@ static my_bool get_view_structure(char *table, char* db) /* If requested, open separate .sql file for this view */ if (path) { - if (!(sql_file= open_sql_file_for_table(table))) + if (!(sql_file= open_sql_file_for_table(table, O_WRONLY))) DBUG_RETURN(1); write_header(sql_file, db); -- cgit v1.2.1 From 394f6ba478e394bcdbfb04c56ee6daa007ef554d Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Thu, 28 May 2009 13:34:30 +0500 Subject: Bug#37268 'binary' character set makes CLI-internal commands case sensitive The fix is to use case insensitive collation for mysql client command search. --- client/mysql.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 89f1f28bb1b..b7d66071ca5 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1949,7 +1949,7 @@ static COMMANDS *find_command(char *name,char cmd_char) */ if (strstr(name, "\\g") || (strstr(name, delimiter) && !(strlen(name) >= 9 && - !my_strnncoll(charset_info, + !my_strnncoll(&my_charset_latin1, (uchar*) name, 9, (const uchar*) "delimiter", 9)))) @@ -1970,7 +1970,7 @@ static COMMANDS *find_command(char *name,char cmd_char) { if (commands[i].func && ((name && - !my_strnncoll(charset_info,(uchar*)name,len, + !my_strnncoll(&my_charset_latin1, (uchar*)name, len, (uchar*)commands[i].name,len) && !commands[i].name[len] && (!end || (end && commands[i].takes_params))) || -- cgit v1.2.1 From 0f742616ce1e4f6fbcabe9a78ae8a4b8007a3f72 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Wed, 3 Jun 2009 15:18:12 +0400 Subject: Fix compilation failures: get rid of C++ specifics in C-code. --- client/mysql_upgrade.c | 2 +- client/mysqlcheck.c | 2 +- client/mysqldump.c | 2 +- client/mysqlimport.c | 2 +- client/mysqlshow.c | 2 +- client/mysqlslap.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'client') diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index bbc0e0f57ec..641d4a38d16 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -234,7 +234,7 @@ get_one_option(int optid, const struct my_option *opt, case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ tty_password= 1; add_option= FALSE; if (argument) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 1bdb28f5a11..c59049d8b72 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -287,7 +287,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start = argument; diff --git a/client/mysqldump.c b/client/mysqldump.c index 38e37aecba6..6b2c2a06834 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -703,7 +703,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index ec418244f3d..57aee7379f2 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -222,7 +222,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index e401d6cad8f..15f791ca8fb 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -282,7 +282,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start=argument; diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 4cf8c7204ed..316fb6a9da3 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -713,7 +713,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'p': if (argument == disabled_my_option) - argument= (char*) ""; // Don't require password + argument= (char*) ""; /* Don't require password */ if (argument) { char *start= argument; -- cgit v1.2.1 From 5ec61b304c1c7ed03e5df9257f0bc5cb01f6bc36 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 5 Jun 2009 15:05:26 +0300 Subject: Bug #45286: compilation warnings on mysql-5.0-bugteam on MacOSX Fixed the 5.0-bugteam MacOSX warnings. --- client/mysqldump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index a9d2788de05..2fd69a3d8c6 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3122,7 +3122,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table((uchar*) hash_key,end - hash_key)) + if (include_table((byte*) hash_key,end - hash_key)) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -3143,7 +3143,7 @@ static my_bool dump_all_views_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table((uchar*) hash_key, end - hash_key)) + if (include_table((byte*) hash_key, end - hash_key)) get_view_structure(table, database); } if (opt_xml) -- cgit v1.2.1 From a66fd239803a0c04bfd26703e5b035d237094d08 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 5 Jun 2009 16:44:38 +0300 Subject: Bug #45286: compilation warnings on mysql-5.0-bugteam on MacOSX Merged the 5.0 fix to 5.1 and fixed the 5.1 specific warnings. --- client/mysqldump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index f7b894803bd..6b2c2a06834 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4110,7 +4110,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table((byte*) hash_key,end - hash_key)) + if (include_table((uchar*) hash_key,end - hash_key)) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -4131,7 +4131,7 @@ static my_bool dump_all_views_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table((byte*) hash_key, end - hash_key)) + if (include_table((uchar*) hash_key, end - hash_key)) get_view_structure(table, database); } if (opt_xml) -- cgit v1.2.1 From 7787dee76a2ca28f8a1752f3aebb3760c419a3fc Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 5 Jun 2009 17:59:23 +0300 Subject: Bug #43532 : backport of the 5.1 code to 5.0 mysqltest --- client/mysqltest.c | 103 ++++++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 48 deletions(-) (limited to 'client') diff --git a/client/mysqltest.c b/client/mysqltest.c index 2f19fad9ea9..0bde230cfe2 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1340,23 +1340,25 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) not present. */ -int diff_check() +int diff_check(const char *diff_name) { - char buf[512]= {0}; - FILE *res_file; - const char *cmd = "diff -v"; - int have_diff = 0; + char buf[512]= {0}; + FILE *res_file; + char cmd[128]; + my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name); + int have_diff = 0; if (!(res_file= popen(cmd, "r"))) die("popen(\"%s\", \"r\") failed", cmd); -/* if diff is not present, nothing will be in stdout to increment have_diff */ + /* if diff is not present, nothing will be in + * stdout to increment have_diff */ if (fgets(buf, sizeof(buf), res_file)) { have_diff += 1; } - pclose(res_file); - return have_diff; + pclose(res_file); + return have_diff; } /* @@ -1377,28 +1379,33 @@ void show_diff(DYNAMIC_STRING* ds, { DYNAMIC_STRING ds_tmp; - int have_diff = 0; + const char *diff_name = 0; if (init_dynamic_string(&ds_tmp, "", 256, 256)) die("Out of memory"); - + /* determine if we have diff on Windows - needs special processing due to return values - on that OS - This test is only done on Windows since it's only needed there - in order to correctly detect non-availibility of 'diff', and - the way it's implemented does not work with default 'diff' on Solaris. - */ + needs special processing due to return values + on that OS + This test is only done on Windows since it's only needed there + in order to correctly detect non-availibility of 'diff', and + the way it's implemented does not work with default 'diff' on Solaris. + */ #ifdef __WIN__ - have_diff = diff_check(); + if (diff_check("diff")) + diff_name = "diff"; + else if (diff_check("mtrdiff")) + diff_name = "mtrdiff"; + else + diff_name = 0; #else - have_diff = 1; + diff_name = "diff"; // Otherwise always assume it's called diff #endif - if (have_diff) + if (diff_name) { /* First try with unified diff */ - if (run_tool("diff", + if (run_tool(diff_name, &ds_tmp, /* Get output from diff in ds_tmp */ "-u", filename1, @@ -1409,7 +1416,7 @@ void show_diff(DYNAMIC_STRING* ds, dynstr_set(&ds_tmp, ""); /* Fallback to context diff with "diff -c" */ - if (run_tool("diff", + if (run_tool(diff_name, &ds_tmp, /* Get output from diff in ds_tmp */ "-c", filename1, @@ -1417,42 +1424,42 @@ void show_diff(DYNAMIC_STRING* ds, "2>&1", NULL) > 1) /* Most "diff" tools return >1 if error */ { - have_diff= 0; - } + diff_name= 0; + } } } -if (!(have_diff)) + if (!(diff_name)) { /* Fallback to dump both files to result file and inform about installing "diff" - */ - - dynstr_set(&ds_tmp, ""); + */ + + dynstr_set(&ds_tmp, ""); - dynstr_append(&ds_tmp, -"\n" -"The two files differ but it was not possible to execute 'diff' in\n" -"order to show only the difference, tried both 'diff -u' or 'diff -c'.\n" -"Instead the whole content of the two files was shown for you to diff manually. ;)\n\n" -"To get a better report you should install 'diff' on your system, which you\n" -"for example can get from http://www.gnu.org/software/diffutils/diffutils.html\n" + dynstr_append(&ds_tmp, + "\n" + "The two files differ but it was not possible to execute 'diff' in\n" + "order to show only the difference, tried both 'diff -u' or 'diff -c'.\n" + "Instead the whole content of the two files was shown for you to diff manually. ;)\n\n" + "To get a better report you should install 'diff' on your system, which you\n" + "for example can get from http://www.gnu.org/software/diffutils/diffutils.html\n" #ifdef __WIN__ -"or http://gnuwin32.sourceforge.net/packages/diffutils.htm\n" + "or http://gnuwin32.sourceforge.net/packages/diffutils.htm\n" #endif -"\n"); - - dynstr_append(&ds_tmp, " --- "); - dynstr_append(&ds_tmp, filename1); - dynstr_append(&ds_tmp, " >>>\n"); - cat_file(&ds_tmp, filename1); - dynstr_append(&ds_tmp, "<<<\n --- "); - dynstr_append(&ds_tmp, filename1); - dynstr_append(&ds_tmp, " >>>\n"); - cat_file(&ds_tmp, filename2); - dynstr_append(&ds_tmp, "<<<<\n"); - } + "\n"); + + dynstr_append(&ds_tmp, " --- "); + dynstr_append(&ds_tmp, filename1); + dynstr_append(&ds_tmp, " >>>\n"); + cat_file(&ds_tmp, filename1); + dynstr_append(&ds_tmp, "<<<\n --- "); + dynstr_append(&ds_tmp, filename1); + dynstr_append(&ds_tmp, " >>>\n"); + cat_file(&ds_tmp, filename2); + dynstr_append(&ds_tmp, "<<<<\n"); + } if (ds) { @@ -1464,7 +1471,7 @@ if (!(have_diff)) /* Print diff directly to stdout */ fprintf(stderr, "%s\n", ds_tmp.str); } - + dynstr_free(&ds_tmp); } -- cgit v1.2.1 From c6fdeff0c70eb875680de64a066770159c3d7fb1 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 5 Jun 2009 19:23:44 +0300 Subject: Addendum to Bug #45286 : implement reviewer's remarks. --- client/mysqldump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index 2fd69a3d8c6..fa6c21ed273 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3122,7 +3122,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table((byte*) hash_key,end - hash_key)) + if (include_table(hash_key,end - hash_key)) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -3143,7 +3143,7 @@ static my_bool dump_all_views_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table((byte*) hash_key, end - hash_key)) + if (include_table(hash_key, end - hash_key)) get_view_structure(table, database); } if (opt_xml) -- cgit v1.2.1 From 82d2797d0af39e50060b724281ae959659d8b5b2 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Sat, 6 Jun 2009 12:26:39 -0300 Subject: Don't mix declarations and code (not widely portable). --- client/mysqltest.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'client') diff --git a/client/mysqltest.c b/client/mysqltest.c index 0bde230cfe2..f81968ee5a2 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1329,38 +1329,43 @@ static int run_tool(const char *tool_path, DYNAMIC_STRING *ds_res, ...) DBUG_RETURN(ret); } + /* Test if diff is present. This is needed on Windows systems as the OS returns 1 whether diff is successful or if it is not present. - + We run diff -v and look for output in stdout. We don't redirect stderr to stdout to make for a simplified check Windows will output '"diff"' is not recognized... to stderr if it is not present. */ -int diff_check(const char *diff_name) +#ifdef __WIN__ + +static int diff_check(const char *diff_name) { - char buf[512]= {0}; FILE *res_file; - char cmd[128]; - my_snprintf (cmd, sizeof(cmd), "%s -v", diff_name); - int have_diff = 0; + char buf[128]; + int have_diff= 0; - if (!(res_file= popen(cmd, "r"))) - die("popen(\"%s\", \"r\") failed", cmd); + my_snprintf(buf, sizeof(buf), "%s -v", diff_name); - /* if diff is not present, nothing will be in - * stdout to increment have_diff */ + if (!(res_file= popen(buf, "r"))) + die("popen(\"%s\", \"r\") failed", buf); + + /* if diff is not present, nothing will be in stdout to increment have_diff */ if (fgets(buf, sizeof(buf), res_file)) - { - have_diff += 1; - } + have_diff= 1; + pclose(res_file); + return have_diff; } +#endif + + /* Show the diff of two files using the systems builtin diff command. If no such diff command exist, just dump the content -- cgit v1.2.1 From 1d3daee4503e8f4a6c0806d85de60646ce2845f9 Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Sun, 7 Jun 2009 23:28:08 +0100 Subject: BUG#42941: --database paramater to mysqlbinlog fails with RBR mysqlbinlog --database parameter was being ignored when processing row events. As such no event filtering would take place. This patch addresses this by deploying a call to shall_skip_database when table_map_events are handled (as these contain also the name of the database). All other rows events referencing the table id for the filtered map event, will also be skipped. --- client/mysqlbinlog.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 1864786e3c6..042a7957956 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -681,6 +681,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, { char ll_buff[21]; Log_event_type ev_type= ev->get_type_code(); + my_bool destroy_evt= TRUE; DBUG_ENTER("process_event"); print_event_info->short_form= short_form; Exit_status retval= OK_CONTINUE; @@ -871,12 +872,63 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, break; } case TABLE_MAP_EVENT: + { + Table_map_log_event *map= ((Table_map_log_event *)ev); + if (shall_skip_database(map->get_db_name())) + { + print_event_info->m_table_map_ignored.set_table(map->get_table_id(), map); + destroy_evt= FALSE; + goto end; + } + } case WRITE_ROWS_EVENT: case DELETE_ROWS_EVENT: case UPDATE_ROWS_EVENT: case PRE_GA_WRITE_ROWS_EVENT: case PRE_GA_DELETE_ROWS_EVENT: case PRE_GA_UPDATE_ROWS_EVENT: + { + if (ev_type != TABLE_MAP_EVENT) + { + Rows_log_event *e= (Rows_log_event*) ev; + Table_map_log_event *ignored_map= + print_event_info->m_table_map_ignored.get_table(e->get_table_id()); + bool skip_event= (ignored_map != NULL); + + /* + end of statement check: + i) destroy/free ignored maps + ii) if skip event, flush cache now + */ + if (e->get_flags(Rows_log_event::STMT_END_F)) + { + /* + Now is safe to clear ignored map (clear_tables will also + delete original table map events stored in the map). + */ + if (print_event_info->m_table_map_ignored.count() > 0) + print_event_info->m_table_map_ignored.clear_tables(); + + /* + One needs to take into account an event that gets + filtered but was last event in the statement. If this is + the case, previous rows events that were written into + IO_CACHEs still need to be copied from cache to + result_file (as it would happen in ev->print(...) if + event was not skipped). + */ + if (skip_event) + { + if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) || + copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file))) + goto err; + } + } + + /* skip the event check */ + if (skip_event) + goto end; + } /* These events must be printed in base64 format, if printed. base64 format requires a FD event to be safe, so if no FD @@ -900,6 +952,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, goto err; } /* FALL THROUGH */ + } default: ev->print(result_file, print_event_info); } @@ -919,7 +972,8 @@ end: { if (remote_opt) ev->temp_buf= 0; - delete ev; + if (destroy_evt) /* destroy it later if not set (ignored table map) */ + delete ev; } DBUG_RETURN(retval); } -- cgit v1.2.1 From 08410f34dd40835a00357529ea196dbabd0d6381 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 10 Jun 2009 11:24:47 +0400 Subject: Bug #45236: large blob inserts from mysqldump fail, possible memory issue ? The mysql command line client could misinterpret some character sequences as commands under some circumstances. The upper limit for internal readline buffer was raised to 1 GB (the same as for server's max_allowed_packet) so that any input line is processed by add_line() as a whole rather than in chunks. --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index b7d66071ca5..216a8f87c27 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -112,7 +112,7 @@ extern "C" { #define PROMPT_CHAR '\\' #define DEFAULT_DELIMITER ";" -#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L) +#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L) typedef struct st_status { -- cgit v1.2.1 From c92abdc2a0d8a33aef47ca9f3114a0bceb5650a7 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Fri, 19 Jun 2009 13:24:43 +0500 Subject: Bug#44834 strxnmov is expected to behave as you'd expect The problem: described in the bug report. The fix: --increase buffers where it's necessary (buffers which are used in stxnmov) --decrease buffer lengths which are used --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 732e38cd74d..4ab46ed1e7d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2732,7 +2732,7 @@ static int com_server_help(String *buffer __attribute__((unused)), { MYSQL_ROW cur; const char *server_cmd= buffer->ptr(); - char cmd_buf[100]; + char cmd_buf[100 + 1]; MYSQL_RES *result; int error; -- cgit v1.2.1 From 19dfaa5824ef47de51a568be4e7a30ff028bcbe8 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Mon, 29 Jun 2009 15:17:01 +0200 Subject: Merge from 5.0-bt --- client/mysql.cc | 6 +++--- client/mysqlbinlog.cc | 4 ++-- client/mysqltest.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 216a8f87c27..0d61ed4ec88 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1974,7 +1974,7 @@ static COMMANDS *find_command(char *name,char cmd_char) (uchar*)commands[i].name,len) && !commands[i].name[len] && (!end || (end && commands[i].takes_params))) || - !name && commands[i].cmd_char == cmd_char)) + (!name && commands[i].cmd_char == cmd_char))) { DBUG_PRINT("exit",("found command: %s", commands[i].name)); DBUG_RETURN(&commands[i]); @@ -2132,7 +2132,7 @@ static bool add_line(String &buffer,char *line,char *in_string, buffer.length(0); } else if (!*ml_comment && (!*in_string && (inchar == '#' || - inchar == '-' && pos[1] == '-' && + (inchar == '-' && pos[1] == '-' && /* The third byte is either whitespace or is the end of the line -- which would occur only @@ -2140,7 +2140,7 @@ static bool add_line(String &buffer,char *line,char *in_string, itself whitespace and should also match. */ (my_isspace(charset_info,pos[2]) || - !pos[2])))) + !pos[2]))))) { // Flush previously accepted characters if (out != line) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 36b86ae7a96..ab78bbea944 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -527,8 +527,8 @@ int process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, Format events are not concerned by --offset and such, we always need to read them to be able to process the wanted events. */ - if ((rec_count >= offset) && - ((my_time_t)(ev->when) >= start_datetime) || + if (((rec_count >= offset) && + ((my_time_t)(ev->when) >= start_datetime)) || (ev_type == FORMAT_DESCRIPTION_EVENT)) { if (ev_type != FORMAT_DESCRIPTION_EVENT) diff --git a/client/mysqltest.c b/client/mysqltest.c index f81968ee5a2..24d021b7239 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1682,7 +1682,7 @@ void check_result(DYNAMIC_STRING* ds) dynstr_set(ds, NULL); /* Don't create a .log file */ show_diff(NULL, result_file_name, reject_file); - die(mess); + die("%s", mess); break; } default: /* impossible */ -- cgit v1.2.1 From 6455c5689dd61022ca3c21c88a0699fff77b53bb Mon Sep 17 00:00:00 2001 From: Kristofer Pettersson Date: Fri, 3 Jul 2009 13:55:45 +0200 Subject: Bug#37274 client 'status' command doesn't print all info after losing connection to server If the server connection was lost during repeated status commands, the client would fail to detect this and the client output would be inconsistent. This patch fixes this issue by making sure that the server is online before the client attempts to execute the status command. --- client/mysql.cc | 63 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 40c446299be..5afbc2e960b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -4264,41 +4264,36 @@ com_status(String *buffer __attribute__((unused)), MYSQL_RES *result; LINT_INIT(result); + if (mysql_real_query_for_lazy( + C_STRING_WITH_LEN("select DATABASE(), USER() limit 1"))) + return 0; + tee_puts("--------------", stdout); usage(1); /* Print version */ - if (connected) + tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); + /* + Don't remove "limit 1", + it is protection againts SQL_SELECT_LIMIT=0 + */ + if (mysql_store_result_for_lazy(&result)) { - tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",mysql_thread_id(&mysql)); - /* - Don't remove "limit 1", - it is protection againts SQL_SELECT_LIMIT=0 - */ - if (!mysql_query(&mysql,"select DATABASE(), USER() limit 1") && - (result=mysql_use_result(&mysql))) + MYSQL_ROW cur=mysql_fetch_row(result); + if (cur) { - MYSQL_ROW cur=mysql_fetch_row(result); - if (cur) - { - tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); - tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); - } - mysql_free_result(result); - } -#ifdef HAVE_OPENSSL - if ((status_str= mysql_get_ssl_cipher(&mysql))) - tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - status_str); - else -#endif /* HAVE_OPENSSL */ - tee_puts("SSL:\t\t\tNot in use", stdout); + tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : ""); + tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]); + } + mysql_free_result(result); } + +#ifdef HAVE_OPENSSL + if ((status_str= mysql_get_ssl_cipher(&mysql))) + tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", + status_str); else - { - vidattr(A_BOLD); - tee_fprintf(stdout, "\nNo connection\n"); - vidattr(A_NORMAL); - return 0; - } +#endif /* HAVE_OPENSSL */ + tee_puts("SSL:\t\t\tNot in use", stdout); + if (skip_updates) { vidattr(A_BOLD); @@ -4317,8 +4312,14 @@ com_status(String *buffer __attribute__((unused)), tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff)); /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */ - if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") && - (result=mysql_use_result(&mysql))) + if (mysql_real_query_for_lazy(C_STRING_WITH_LEN( + "select @@character_set_client, @@character_set_connection, " + "@@character_set_server, @@character_set_database limit 1"))) + { + if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) + return 0; + } + if (mysql_store_result_for_lazy(&result)) { MYSQL_ROW cur=mysql_fetch_row(result); if (cur) -- cgit v1.2.1 From 9161d0f815f793f67a0b0ffe166339560721b97f Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 7 Jul 2009 16:11:46 +0300 Subject: fixed compilation warnings on macosx --- client/mysqldump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index d755a17b815..6b2c2a06834 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4110,7 +4110,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table(hash_key,end - hash_key)) + if (include_table((uchar*) hash_key,end - hash_key)) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -4131,7 +4131,7 @@ static my_bool dump_all_views_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table(hash_key, end - hash_key)) + if (include_table((uchar*) hash_key, end - hash_key)) get_view_structure(table, database); } if (opt_xml) -- cgit v1.2.1 From bf6e255d8c71de9a5536756682d60a5e7c4ff3b0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 16 Jul 2009 15:37:38 +0300 Subject: Bug #45287: phase 2 : 5.0 64 bit compilation warnings Fixed various compilation warnings when compiling on a 64 bit windows. --- client/mysql_upgrade.c | 2 +- client/mysqldump.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index e3500c81fb9..ff414fff592 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -387,7 +387,7 @@ static void find_tool(char *tool_executable_name, const char *tool_name, last_fn_libchar -= 6; } - len= last_fn_libchar - self_name; + len= (int) (last_fn_libchar - self_name); my_snprintf(tool_executable_name, FN_REFLEN, "%.*s%c%s", len, self_name, FN_LIBCHAR, tool_name); diff --git a/client/mysqldump.c b/client/mysqldump.c index fa6c21ed273..1918a657316 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3122,7 +3122,7 @@ static my_bool dump_all_views_in_db(char *database) for (numrows= 0 ; (table= getTableName(1)); ) { char *end= strmov(afterdot, table); - if (include_table(hash_key,end - hash_key)) + if (include_table(hash_key,(uint) (end - hash_key))) { numrows++; dynstr_append_checked(&query, quote_name(table, table_buff, 1)); @@ -3143,7 +3143,7 @@ static my_bool dump_all_views_in_db(char *database) while ((table= getTableName(0))) { char *end= strmov(afterdot, table); - if (include_table(hash_key, end - hash_key)) + if (include_table(hash_key, (uint) (end - hash_key))) get_view_structure(table, database); } if (opt_xml) -- cgit v1.2.1 From f46dba5a5fcc6e389700b1b8278c5a5f6f5e2e10 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Wed, 8 Jul 2009 16:49:45 +0200 Subject: Bug #43397 mysql headers redefine pthread_mutex_init unnecessarily The problem is that libmysqlclient.so is built with THREAD undefined, while a client compiling against the same header files will see THREAD as defined and definitions in my_pthread.h will be included, possibly resulting in undefined symbols that cannot be resolved with libmysqlclient.so. The suggested solution is to require that clients wanting to link with libmysqlclient.so should be built with MYSQL_CLIENT_NO_THREADS defined. This requires a documentation change, and more details for this will be supplied if this patch is approved. The MYSQL_CLIENT_NO_THREADS define was renamed from UNDEF_THREADS_HACK, to get a more suitable (less suspicious) name for the define. (The UNDEF_THREADS_HACK is retained for backwards compatibility, though.) This patch is also in anticipation of WL#4958, which will remove this problem altogether by dropping the building of libmysqlclient. --- client/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/Makefile.am b/client/Makefile.am index 94db565ba37..5fadbc171ae 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -80,14 +80,14 @@ mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ mysqlshow_SOURCES= mysqlshow.c mysqlslap_SOURCES= mysqlslap.c -mysqlslap_CFLAGS= -DTHREAD -UUNDEF_THREADS_HACK +mysqlslap_CFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ $(top_builddir)/mysys/libmysys.a mysqltest_SOURCES= mysqltest.cc -mysqltest_CXXFLAGS= -DTHREAD -UUNDEF_THREADS_HACK +mysqltest_CXXFLAGS= -DTHREAD -UMYSQL_CLIENT_NO_THREADS mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ @@ -99,7 +99,7 @@ mysql_upgrade_SOURCES= mysql_upgrade.c \ $(top_srcdir)/mysys/my_getpagesize.c # Fix for mit-threads -DEFS = -DUNDEF_THREADS_HACK \ +DEFS = -DMYSQL_CLIENT_NO_THREADS \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ -DDATADIR="\"$(localstatedir)\"" -- cgit v1.2.1 From 49404d101b11f9fdf7e1110b394236c663836189 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 14 Jul 2009 17:03:51 -0700 Subject: The handling of NUL bytes in column data in the various output formats supported by the mysql client was inconsistent. (Bug #28203) --- client/mysql.cc | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/mysql.cc b/client/mysql.cc index 5dbcc5eabba..b92056b7617 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -169,6 +169,8 @@ static const char *xmlmeta[] = { "<", "<", ">", ">", "\"", """, + /* Turn \0 into a space. Why not �? That's not valid XML or HTML. */ + "\0", " ", 0, 0 }; static const char *day_names[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; @@ -3496,11 +3498,29 @@ print_table_data_vertically(MYSQL_RES *result) mysql_field_seek(result,0); tee_fprintf(PAGER, "*************************** %d. row ***************************\n", row_count); + + ulong *lengths= mysql_fetch_lengths(result); + for (uint off=0; off < mysql_num_fields(result); off++) { field= mysql_fetch_field(result); tee_fprintf(PAGER, "%*s: ",(int) max_length,field->name); - tee_fprintf(PAGER, "%s\n",cur[off] ? (char*) cur[off] : "NULL"); + if (cur[off]) + { + unsigned int i; + const char *p; + + for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1) + { + if (*p == '\0') + tee_putc((int)' ', PAGER); + else + tee_putc((int)*p, PAGER); + } + tee_putc('\n', PAGER); + } + else + tee_fprintf(PAGER, "NULL\n"); } } } @@ -3567,7 +3587,7 @@ xmlencode_print(const char *src, uint length) tee_fputs("NULL", PAGER); else { - for (const char *p = src; *p && length; *p++, length--) + for (const char *p = src; length; *p++, length--) { const char *t; if ((t = array_value(xmlmeta, *p))) @@ -3587,7 +3607,12 @@ safe_put_field(const char *pos,ulong length) else { if (opt_raw_data) - tee_fputs(pos, PAGER); + { + unsigned long i; + /* Can't use tee_fputs(), it stops with NUL characters. */ + for (i= 0; i < length; i++, pos++) + tee_putc(*pos, PAGER); + } else for (const char *end=pos+length ; pos != end ; pos++) { #ifdef USE_MB -- cgit v1.2.1 From e642140b182e4ba0688b91c0870dfb5500b149f0 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Fri, 31 Jul 2009 22:14:52 +0500 Subject: Bug# 30946: mysqldump silently ignores --default-character-set when used with --tab 1) New syntax: added CHARACTER SET clause to the SELECT ... INTO OUTFILE (to complement the same clause in LOAD DATA INFILE). mysqldump is updated to use this in --tab mode. 2) ESCAPED BY/ENCLOSED BY field parameters are documented as accepting CHAR argument, however SELECT .. INTO OUTFILE silently ignored rests of multisymbol arguments. For the symmetrical behavior with LOAD DATA INFILE the server has been modified to fail with the same error: ERROR 42000: Field separator argument is not what is expected; check the manual 3) Current LOAD DATA INFILE recognizes field/line separators "as is" without converting from client charset to data file charset. So, it is supposed, that input file of LOAD DATA INFILE consists of data in one charset and separators in other charset. For the compatibility with that [buggy] behaviour SELECT INTO OUTFILE implementation has been saved "as is" too, but the new warning message has been added: Non-ASCII separator arguments are not fully supported This message warns on field/line separators that contain non-ASCII symbols. --- client/mysqldump.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index 193652b88ff..a4f7cabb385 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3137,6 +3137,12 @@ static void dump_table(char *table, char *db) dynstr_append_checked(&query_string, filename); dynstr_append_checked(&query_string, "'"); + dynstr_append_checked(&query_string, " /*!50137 CHARACTER SET "); + dynstr_append_checked(&query_string, default_charset == mysql_universal_client_charset ? + my_charset_bin.name : /* backward compatibility */ + default_charset); + dynstr_append_checked(&query_string, " */"); + if (fields_terminated || enclosed || opt_enclosed || escaped) dynstr_append_checked(&query_string, " FIELDS"); -- cgit v1.2.1 From 6df2af22ceda4a59fc43a661f6ecfac362e9783a Mon Sep 17 00:00:00 2001 From: Ignacio Galarza Date: Fri, 31 Jul 2009 15:22:02 -0400 Subject: Bug#17270 - mysql client tool could not find ../share/charsets folder and fails. - Define and pass compile time path variables as pre-processor definitions to mimic the makefile build. - Set new CMake version and policy requirements explicitly. - Changed DATADIR to MYSQL_DATADIR to avoid conflicting definition in Platform SDK header ObjIdl.h which also defines DATADIR. --- client/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/Makefile.am b/client/Makefile.am index 672bb2e0c47..e77d294b0ac 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -57,7 +57,7 @@ strings_src=decimal.c # Fix for mit-threads DEFS = -DUNDEF_THREADS_HACK \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ - -DDATADIR="\"$(localstatedir)\"" + -DMYSQL_DATADIR="\"$(localstatedir)\"" EXTRA_DIST = get_password.c CMakeLists.txt echo.c -- cgit v1.2.1 From b42ce44fbf8aff8486218d0a6fe4c380f3cae5c2 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Tue, 4 Aug 2009 00:22:28 +0500 Subject: Additional post-commit fix (bug #30946): server version in a conditional commentary at the new SELECT ... INTO OUTFILE ... CHARACTER SET syntax has been updated to 5.1.38. --- client/mysqldump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/mysqldump.c b/client/mysqldump.c index a4f7cabb385..cac27424d6e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3137,7 +3137,7 @@ static void dump_table(char *table, char *db) dynstr_append_checked(&query_string, filename); dynstr_append_checked(&query_string, "'"); - dynstr_append_checked(&query_string, " /*!50137 CHARACTER SET "); + dynstr_append_checked(&query_string, " /*!50138 CHARACTER SET "); dynstr_append_checked(&query_string, default_charset == mysql_universal_client_charset ? my_charset_bin.name : /* backward compatibility */ default_charset); -- cgit v1.2.1