diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-07-16 19:09:54 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-07-16 19:09:54 +0200 |
commit | 005c7e54214546584c8dc67a746e215f8dbe4b58 (patch) | |
tree | dea50cd7b32808413e058d43d20cf230d1cc7477 /client | |
parent | b9f220b45afaae9b61af29129a8c8ec5f9a7759b (diff) | |
parent | 4f5c10e6b565bc2761b9d083e25c6a36141552a0 (diff) | |
download | mariadb-git-005c7e54214546584c8dc67a746e215f8dbe4b58.tar.gz |
mysql-5.5.32 merge
Diffstat (limited to 'client')
-rw-r--r-- | client/completion_hash.h | 4 | ||||
-rw-r--r-- | client/echo.c | 2 | ||||
-rw-r--r-- | client/get_password.c | 2 | ||||
-rw-r--r-- | client/mysql.cc | 20 | ||||
-rw-r--r-- | client/mysql_plugin.c | 2 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 71 | ||||
-rw-r--r-- | client/mysqladmin.cc | 2 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 16 | ||||
-rw-r--r-- | client/mysqldump.c | 2 | ||||
-rw-r--r-- | client/mysqltest.cc | 4 | ||||
-rw-r--r-- | client/sql_string.h.dontuse | 3 |
11 files changed, 109 insertions, 19 deletions
diff --git a/client/completion_hash.h b/client/completion_hash.h index 50098e436b9..70c2cf1b371 100644 --- a/client/completion_hash.h +++ b/client/completion_hash.h @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA */ + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA */ #ifndef _HASH_ #define _HASH_ diff --git a/client/echo.c b/client/echo.c index cd61b23a826..2a3cb915d23 100644 --- a/client/echo.c +++ b/client/echo.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* echo is a replacement for the "echo" command builtin to cmd.exe diff --git a/client/get_password.c b/client/get_password.c index a73771b00d4..8a507d94e9b 100644 --- a/client/get_password.c +++ b/client/get_password.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* ** Ask for a password from tty diff --git a/client/mysql.cc b/client/mysql.cc index 2c8f7347840..e9e21c0289d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. Copyright (c) 2009, 2013, Monty Program Ab. This program is free software; you can redistribute it and/or modify @@ -1923,7 +1923,7 @@ static int read_and_execute(bool interactive) String buffer; #endif - char *line= 0; + char *line= NULL; char in_string=0; ulong line_number=0; bool ml_comment= 0; @@ -2022,6 +2022,13 @@ static int read_and_execute(bool interactive) #else if (opt_outfile) fputs(prompt, OUTFILE); + /* + free the previous entered line. + Note: my_free() cannot be used here as the memory was allocated under + the readline/libedit library. + */ + if (line) + free(line); line= readline(prompt); #endif /* defined(__WIN__) */ @@ -2081,6 +2088,14 @@ static int read_and_execute(bool interactive) #if defined(__WIN__) buffer.free(); tmpbuf.free(); +#else + if (interactive) + /* + free the last entered line. + Note: my_free() cannot be used here as the memory was allocated under + the readline/libedit library. + */ + free(line); #endif /* @@ -2089,6 +2104,7 @@ static int read_and_execute(bool interactive) program, it is safe to set real_binary_mode to FALSE. */ real_binary_mode= FALSE; + return status.exit_status; } diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index f4e3111b7b7..b6fa350b54a 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <m_string.h> diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 7aaad96e985..c6aaf38179f 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1,6 +1,6 @@ /* - Copyright (c) 2006, 2012, Oracle and/or its affiliates. - Copyright (C) 2010, 2012, Monty Program Ab. + Copyright (c) 2006, 2013, Oracle and/or its affiliates. + Copyright (c) 2010, 2013, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,7 +40,7 @@ static char mysql_path[FN_REFLEN]; static char mysqlcheck_path[FN_REFLEN]; static my_bool opt_force, opt_verbose, debug_info_flag, debug_check_flag, - opt_systables_only; + opt_systables_only, opt_version_check; static my_bool opt_not_used, opt_silent; static uint my_end_arg= 0; static char *opt_user= (char*)"root"; @@ -150,6 +150,12 @@ static struct my_option my_long_options[]= &opt_not_used, &opt_not_used, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"version-check", 'k', "Run this program only if its \'server version\' " + "matches the version of the server to which it's connecting, (enabled by " + "default); use --skip-version-check to avoid this check. Note: the \'server " + "version\' of the program is the version of the MySQL server with which it " + "was built/distributed.", &opt_version_check, &opt_version_check, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"write-binlog", OPT_WRITE_BINLOG, "All commands including mysqlcheck are binlogged. Enabled by default;" "use --skip-write-binlog when commands should not be sent to replication slaves.", @@ -291,6 +297,7 @@ get_one_option(int optid, const struct my_option *opt, my_progname, optid == 'b' ? "basedir" : "datadir"); /* FALLTHROUGH */ + case 'k': /* --version-check */ case 'v': /* --verbose */ opt_verbose++; if (argument == disabled_my_option) @@ -564,6 +571,8 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, static int extract_variable_from_show(DYNAMIC_STRING* ds, char* value) { char *value_start, *value_end; + size_t len; + /* The query returns "datadir\t<datadir>\n", skip past the tab @@ -576,7 +585,9 @@ static int extract_variable_from_show(DYNAMIC_STRING* ds, char* value) if ((value_end= strchr(value_start, '\n')) == NULL) return 1; /* Unexpected result */ - strncpy(value, value_start, min(FN_REFLEN, value_end-value_start)); + len= (size_t) min(FN_REFLEN, value_end-value_start); + strncpy(value, value_start, len); + value[len]= '\0'; return 0; } @@ -855,6 +866,55 @@ static const char *load_default_groups[]= }; +/* Convert the specified version string into the numeric format. */ +static ulong STDCALL calc_server_version(char *some_version) +{ + uint major, minor, version; + char *point= some_version, *end_point; + major= (uint) strtoul(point, &end_point, 10); point=end_point+1; + minor= (uint) strtoul(point, &end_point, 10); point=end_point+1; + version= (uint) strtoul(point, &end_point, 10); + return (ulong) major * 10000L + (ulong)(minor * 100 + version); +} + +/** + Check if the server version matches with the server version mysql_upgrade + was compiled with. + + @return 0 match successful + 1 failed +*/ +static int check_version_match(void) +{ + DYNAMIC_STRING ds_version; + char version_str[NAME_CHAR_LEN + 1]; + + if (init_dynamic_string(&ds_version, NULL, NAME_CHAR_LEN, NAME_CHAR_LEN)) + die("Out of memory"); + + if (run_query("show variables like 'version'", + &ds_version, FALSE) || + extract_variable_from_show(&ds_version, version_str)) + { + dynstr_free(&ds_version); + return 1; /* Query failed */ + } + + dynstr_free(&ds_version); + + if (calc_server_version((char *) version_str) != MYSQL_VERSION_ID) + { + fprintf(stderr, "Error: Server version (%s) does not match with the " + "version of\nthe server (%s) with which this program was built/" + "distributed. You can\nuse --skip-version-check to skip this " + "check.\n", version_str, MYSQL_SERVER_VERSION); + return 1; + } + else + return 0; +} + + int main(int argc, char **argv) { char self_name[FN_REFLEN]; @@ -919,6 +979,9 @@ int main(int argc, char **argv) die(NULL); } + if (opt_version_check && check_version_match()) + die("Upgrade failed"); + /* Run "mysqlcheck" and "mysql_fix_privilege_tables.sql" */ diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index e2ebb883f77..e4a45d52f83 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* maintaince of mysql databases */ diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d68b2a557e1..2f586ce0840 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2012, Monty Program Ab + Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2013, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -856,7 +856,11 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, /* end of statement check: i) destroy/free ignored maps - ii) if skip event, flush cache now + ii) if skip event + a) since we are skipping the last event, + append END-MARKER(') to body cache (if required) + + b) flush cache now */ if (is_stmt_end) { @@ -884,6 +888,12 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, */ if (skip_event) { + // append END-MARKER(') with delimiter + IO_CACHE *const body_cache= &print_event_info->body_cache; + if (my_b_tell(body_cache)) + my_b_printf(body_cache, "'%s\n", print_event_info->delimiter); + + // flush cache 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))) return 1; diff --git a/client/mysqldump.c b/client/mysqldump.c index 63e0dc04096..86f2be78abe 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /* mysqldump.c - Dump a tables contents and format to an ASCII file diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 845c9429ddf..3602ae96937 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2012, Monty Program Ab. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2013, Monty Program Ab. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/client/sql_string.h.dontuse b/client/sql_string.h.dontuse index 67155ebcee7..94f844dc689 100644 --- a/client/sql_string.h.dontuse +++ b/client/sql_string.h.dontuse @@ -1,7 +1,7 @@ #ifndef SQL_STRING_INCLUDED #define SQL_STRING_INCLUDED -/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -226,6 +226,7 @@ public: DBUG_ASSERT(!s.uses_buffer_owned_by(this)); free(); Ptr=s.Ptr ; str_length=s.str_length ; Alloced_length=s.Alloced_length; + str_charset=s.str_charset; alloced=0; } return *this; |