summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc2
-rw-r--r--client/mysql_plugin.c2
-rw-r--r--client/mysql_upgrade.c92
-rw-r--r--client/mysqladmin.cc98
-rw-r--r--client/mysqlbinlog.cc4
-rw-r--r--client/mysqldump.c5
-rw-r--r--client/mysqltest.cc19
-rw-r--r--client/sql_string.cc.dontuse2
8 files changed, 193 insertions, 31 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index bcc86af8941..69924010a15 100644
--- a/client/mysql.cc
+++ b/client/mysql.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 02111-1301 USA */
/* mysql command tool
* Commands compatible with mSQL by David J. Hughes
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 72fa9485c6c..9cf4cd957fd 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -1003,7 +1003,7 @@ found:
static int find_plugin(char *tp_path)
{
- /* Check for existance of plugin */
+ /* Check for existence of plugin */
fn_format(tp_path, plugin_data.so_name, opt_plugin_dir, "", MYF(0));
if (!file_exists(tp_path))
{
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index e400087a2e8..ee63fda2e39 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -37,7 +37,7 @@
#endif
static int phase = 0;
-static int phases_total = 6;
+static const int phases_total = 7;
static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN];
@@ -69,6 +69,8 @@ static char **defaults_argv;
static my_bool not_used; /* Can't use GET_BOOL without a value pointer */
+char upgrade_from_version[sizeof("10.20.456-MariaDB")+1];
+
static my_bool opt_write_binlog;
#define OPT_SILENT OPT_MAX_CLIENT_OPTION
@@ -545,7 +547,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res,
But mysql_upgrade is tightly bound to a specific server version
anyway - it was mysql_fix_privilege_tables_sql script embedded
into its binary - so even if it won't assume anything about server
- wsrep-ness, it won't be any less server-dependend.
+ wsrep-ness, it won't be any less server-dependent.
*/
const uchar sql_log_bin[]= "SET SQL_LOG_BIN=0, WSREP_ON=OFF;";
#else
@@ -675,7 +677,6 @@ static int upgrade_already_done(void)
{
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
- char buf[sizeof(MYSQL_SERVER_VERSION)+1];
if (get_upgrade_info_file_name(upgrade_info_file))
return 0; /* Could not get filename => not sure */
@@ -683,15 +684,15 @@ static int upgrade_already_done(void)
if (!(in= my_fopen(upgrade_info_file, O_RDONLY, MYF(0))))
return 0; /* Could not open file => not sure */
- bzero(buf, sizeof(buf));
- if (!fgets(buf, sizeof(buf), in))
+ bzero(upgrade_from_version, sizeof(upgrade_from_version));
+ if (!fgets(upgrade_from_version, sizeof(upgrade_from_version), in))
{
/* Ignore, will be detected by strncmp() below */
}
my_fclose(in, MYF(0));
- return (strncmp(buf, MYSQL_SERVER_VERSION,
+ return (strncmp(upgrade_from_version, MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION)-1)==0);
}
@@ -756,9 +757,8 @@ static void print_conn_args(const char *tool_name)
verbose("Running '%s with default connection arguments", tool_name);
}
-
/*
- Check and upgrade(if neccessary) all tables
+ Check and upgrade(if necessary) all tables
in the server using "mysqlcheck --check-upgrade .."
*/
@@ -925,6 +925,80 @@ static void print_line(char* line)
fputc('\n', stderr);
}
+static my_bool from_before_10_1()
+{
+ my_bool ret= TRUE;
+ DYNAMIC_STRING ds_events_struct;
+
+ if (upgrade_from_version[0])
+ {
+ return upgrade_from_version[1] == '.' ||
+ strncmp(upgrade_from_version, "10.1.", 5) < 0;
+ }
+
+ if (init_dynamic_string(&ds_events_struct, NULL, 2048, 2048))
+ die("Out of memory");
+
+ if (run_query("show create table mysql.user", &ds_events_struct, FALSE) ||
+ strstr(ds_events_struct.str, "default_role") != NULL)
+ ret= FALSE;
+ else
+ verbose("Upgrading from a version before MariaDB-10.1");
+
+ dynstr_free(&ds_events_struct);
+ return ret;
+}
+
+
+/*
+ Check for entries with "Unknown storage engine" in I_S.TABLES,
+ try to load plugins for these tables if available (MDEV-11942)
+*/
+static int install_used_engines(void)
+{
+ char buf[512];
+ DYNAMIC_STRING ds_result;
+ const char *query = "SELECT DISTINCT LOWER(engine) FROM information_schema.tables"
+ " WHERE table_comment LIKE 'Unknown storage engine%'";
+
+ if (opt_systables_only || !from_before_10_1())
+ {
+ verbose("Phase %d/%d: Installing used storage engines... Skipped", ++phase, phases_total);
+ return 0;
+ }
+ verbose("Phase %d/%d: Installing used storage engines", ++phase, phases_total);
+
+ if (init_dynamic_string(&ds_result, "", 512, 512))
+ die("Out of memory");
+
+ verbose("Checking for tables with unknown storage engine");
+
+ run_query(query, &ds_result, TRUE);
+
+ if (ds_result.length)
+ {
+ char *line= ds_result.str, *next=get_line(line);
+ do
+ {
+ if (next[-1] == '\n')
+ next[-1]=0;
+
+ verbose("installing plugin for '%s' storage engine", line);
+
+ // we simply assume soname=ha_enginename
+ strxnmov(buf, sizeof(buf)-1, "install soname 'ha_", line, "'", NULL);
+
+
+ if (run_query(buf, NULL, TRUE))
+ fprintf(stderr, "... can't %s\n", buf);
+ line=next;
+ next=get_line(line);
+ } while (*line);
+ }
+ dynstr_free(&ds_result);
+ return 0;
+}
+
/*
Update all system tables in MySQL Server to current
@@ -1132,6 +1206,7 @@ int main(int argc, char **argv)
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
if (run_mysqlcheck_upgrade(TRUE) ||
+ install_used_engines() ||
run_mysqlcheck_views() ||
run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() ||
@@ -1154,4 +1229,3 @@ end:
my_end(my_end_arg);
exit(0);
}
-
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index e670079c99e..7491458c161 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -39,8 +39,8 @@ char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN];
ulonglong last_values[MAX_MYSQL_VAR];
static int interval=0;
static my_bool option_force=0,interrupted=0,new_line=0,
- opt_compress=0, opt_relative=0, opt_verbose=0, opt_vertical=0,
- tty_password= 0, opt_nobeep;
+ opt_compress= 0, opt_local= 0, opt_relative= 0, opt_verbose= 0,
+ opt_vertical= 0, tty_password= 0, opt_nobeep;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations;
static uint opt_count_iterations= 0, my_end_arg;
@@ -103,9 +103,12 @@ enum commands {
ADMIN_PING, ADMIN_EXTENDED_STATUS, ADMIN_FLUSH_STATUS,
ADMIN_FLUSH_PRIVILEGES, ADMIN_START_SLAVE, ADMIN_STOP_SLAVE,
ADMIN_START_ALL_SLAVES, ADMIN_STOP_ALL_SLAVES,
- ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD, ADMIN_FLUSH_SLOW_LOG,
+ ADMIN_FLUSH_THREADS, ADMIN_OLD_PASSWORD, ADMIN_FLUSH_BINARY_LOG,
+ ADMIN_FLUSH_ENGINE_LOG, ADMIN_FLUSH_ERROR_LOG, ADMIN_FLUSH_GENERAL_LOG,
+ ADMIN_FLUSH_RELAY_LOG, ADMIN_FLUSH_SLOW_LOG,
ADMIN_FLUSH_TABLE_STATISTICS, ADMIN_FLUSH_INDEX_STATISTICS,
ADMIN_FLUSH_USER_STATISTICS, ADMIN_FLUSH_CLIENT_STATISTICS,
+ ADMIN_FLUSH_USER_RESOURCES,
ADMIN_FLUSH_ALL_STATUS, ADMIN_FLUSH_ALL_STATISTICS
};
static const char *command_names[]= {
@@ -117,9 +120,10 @@ static const char *command_names[]= {
"ping", "extended-status", "flush-status",
"flush-privileges", "start-slave", "stop-slave",
"start-all-slaves", "stop-all-slaves",
- "flush-threads", "old-password", "flush-slow-log",
+ "flush-threads", "old-password", "flush-binary-log", "flush-engine-log",
+ "flush-error-log", "flush-general-log", "flush-relay-log", "flush-slow-log",
"flush-table-statistics", "flush-index-statistics",
- "flush-user-statistics", "flush-client-statistics",
+ "flush-user-statistics", "flush-client-statistics", "flush-user-resources",
"flush-all-status", "flush-all-statistics",
NullS
};
@@ -161,6 +165,9 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", &host, &host, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"local", 'l', "Local command, don't write to binlog.",
+ &opt_local, &opt_local, 0, GET_BOOL, NO_ARG, 0, 0, 0,
+ 0, 0, 0},
{"no-beep", 'b', "Turn off beep on error.", &opt_nobeep,
&opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"password", 'p',
@@ -619,6 +626,18 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
*/
struct my_rnd_struct rand_st;
+ char buff[FN_REFLEN + 20];
+
+ if (opt_local)
+ {
+ sprintf(buff, "set local sql_log_bin=0");
+ if (mysql_query(mysql, buff))
+ {
+ my_printf_error(0, "SET LOCAL SQL_LOG_BIN=0 failed; error: '%-.200s'",
+ error_flags, mysql_error(mysql));
+ return -1;
+ }
+ }
for (; argc > 0 ; argv++,argc--)
{
@@ -626,7 +645,6 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
switch ((command= find_type(argv[0],&command_typelib,FIND_TYPE_BASIC))) {
case ADMIN_CREATE:
{
- char buff[FN_REFLEN+20];
if (argc < 2)
{
my_printf_error(0, "Too few arguments to create", error_flags);
@@ -901,6 +919,56 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
break;
}
+ case ADMIN_FLUSH_BINARY_LOG:
+ {
+ if (mysql_query(mysql, "flush binary logs"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
+ case ADMIN_FLUSH_ENGINE_LOG:
+ {
+ if (mysql_query(mysql,"flush engine logs"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
+ case ADMIN_FLUSH_ERROR_LOG:
+ {
+ if (mysql_query(mysql, "flush error logs"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
+ case ADMIN_FLUSH_GENERAL_LOG:
+ {
+ if (mysql_query(mysql, "flush general logs"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
+ case ADMIN_FLUSH_RELAY_LOG:
+ {
+ if (mysql_query(mysql, "flush relay logs"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
case ADMIN_FLUSH_SLOW_LOG:
{
if (mysql_query(mysql,"flush slow logs"))
@@ -971,6 +1039,16 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
}
break;
}
+ case ADMIN_FLUSH_USER_RESOURCES:
+ {
+ if (mysql_query(mysql, "flush user_resources"))
+ {
+ my_printf_error(0, "flush failed; error: '%s'", error_flags,
+ mysql_error(mysql));
+ return -1;
+ }
+ break;
+ }
case ADMIN_FLUSH_CLIENT_STATISTICS:
{
if (mysql_query(mysql,"flush client_statistics"))
@@ -1299,12 +1377,18 @@ static void usage(void)
flush-index-statistics Flush index statistics\n\
flush-logs Flush all logs\n\
flush-privileges Reload grant tables (same as reload)\n\
+ flush-binary-log Flush binary log\n\
+ flush-engine-log Flush engine log(s)\n\
+ flush-error-log Flush error log\n\
+ flush-general-log Flush general log\n\
+ flush-relay-log Flush relay log\n\
flush-slow-log Flush slow query log\n\
- flush-status Clear status variables\n\
+ flush-status Clear status variables\n\
flush-table-statistics Clear table statistics\n\
flush-tables Flush all tables\n\
flush-threads Flush the thread cache\n\
flush-user-statistics Flush user statistics\n\
+ flush-user-resources Flush user resources\n\
kill id,id,... Kill mysql threads");
#if MYSQL_VERSION_ID >= 32200
puts("\
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index e2b121c27a7..92534501fb1 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -118,7 +118,7 @@ static const char* sock= 0;
static char *opt_plugindir= 0, *opt_default_auth= 0;
#ifdef HAVE_SMEM
-static char *shared_memory_base_name= 0;
+static const char *shared_memory_base_name= 0;
#endif
static char* user = 0;
static char* pass = 0;
@@ -2770,7 +2770,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
/* read from stdin */
/*
Windows opens stdin in text mode by default. Certain characters
- such as CTRL-Z are interpeted as events and the read() method
+ such as CTRL-Z are interpreted as events and the read() method
will stop. CTRL-Z is the EOF marker in Windows. to get past this
you have to open stdin in binary mode. Setmode() is used to set
stdin in binary mode. Errors on setting this mode result in
diff --git a/client/mysqldump.c b/client/mysqldump.c
index a02dbdf3845..281a7a6c7f2 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -700,8 +700,9 @@ static void write_header(FILE *sql_file, char *db_name)
"-- MySQL dump %s Distrib %s, for %s (%s)\n--\n",
DUMP_VERSION, MYSQL_SERVER_VERSION, SYSTEM_TYPE,
MACHINE_TYPE);
- print_comment(sql_file, 0, "-- Host: %s Database: %s\n",
- fix_for_comment(current_host ? current_host : "localhost"),
+ print_comment(sql_file, 0, "-- Host: %s ",
+ fix_for_comment(current_host ? current_host : "localhost"));
+ print_comment(sql_file, 0, "Database: %s\n",
fix_for_comment(db_name ? db_name : ""));
print_comment(sql_file, 0,
"-- ------------------------------------------------------\n"
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 1e540bc9e46..d930369e303 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -2489,7 +2489,7 @@ VAR *var_obtain(const char *name, int len)
/*
- - if variable starts with a $ it is regarded as a local test varable
+ - if variable starts with a $ it is regarded as a local test variable
- if not it is treated as a environment variable, and the corresponding
environment variable will be updated
*/
@@ -3322,7 +3322,7 @@ static int replace(DYNAMIC_STRING *ds_str,
NOTE
Although mysqltest is executed from cygwin shell, the command will be
executed in "cmd.exe". Thus commands like "rm" etc can NOT be used, use
- mysqltest commmand(s) like "remove_file" for that
+ mysqltest command(s) like "remove_file" for that
*/
void do_exec(struct st_command *command)
@@ -3336,6 +3336,8 @@ void do_exec(struct st_command *command)
DBUG_ENTER("do_exec");
DBUG_PRINT("enter", ("cmd: '%s'", cmd));
+ var_set_int("$sys_errno",0);
+
/* Skip leading space */
while (*cmd && my_isspace(charset_info, *cmd))
cmd++;
@@ -3452,6 +3454,7 @@ void do_exec(struct st_command *command)
report_or_die("command \"%s\" failed with wrong error: %d",
command->first_argument, status);
}
+ var_set_int("$sys_errno",status);
}
else if (command->expected_errors.err[0].type == ERR_ERRNO &&
command->expected_errors.err[0].code.errnum != 0)
@@ -7908,7 +7911,7 @@ void handle_error(struct st_command *command,
{
/*
The query after a "--require" failed. This is fine as long the server
- returned a valid reponse. Don't allow 2013 or 2006 to trigger an
+ returned a valid response. Don't allow 2013 or 2006 to trigger an
abort_not_supported_test
*/
if (err_errno == CR_SERVER_LOST ||
@@ -8997,7 +9000,7 @@ int main(int argc, char **argv)
var_set_string("MYSQLTEST_FILE", cur_file->file_name);
init_re();
- /* Cursor protcol implies ps protocol */
+ /* Cursor protocol implies ps protocol */
if (cursor_protocol)
ps_protocol= 1;
@@ -9095,7 +9098,7 @@ int main(int argc, char **argv)
abort_on_error);
/*
- some commmands need to be executed or at least parsed unconditionally,
+ some commands need to be executed or at least parsed unconditionally,
because they change the grammar.
*/
ok_to_do= cur_block->ok || command->type == Q_DELIMITER
@@ -9525,7 +9528,7 @@ int main(int argc, char **argv)
die("Test ended with parsing disabled");
/*
- The whole test has been executed _sucessfully_.
+ The whole test has been executed _successfully_.
Time to compare result or save it to record file.
The entire output from test is in the log file
*/
@@ -9571,7 +9574,7 @@ int main(int argc, char **argv)
verbose_msg("Test has succeeded!");
timer_output();
- /* Yes, if we got this far the test has suceeded! Sakila smiles */
+ /* Yes, if we got this far the test has succeeded! Sakila smiles */
cleanup_and_exit(0);
return 0; /* Keep compiler happy too */
}
@@ -10064,7 +10067,7 @@ void free_replace_regex()
buf_len_p - result buffer length. Will change if the buffer is reallocated
pattern - regexp pattern to match
replace - replacement expression
- string - the string to perform substituions in
+ string - the string to perform substitutions in
icase - flag, if set to 1 the match is case insensitive
*/
int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
diff --git a/client/sql_string.cc.dontuse b/client/sql_string.cc.dontuse
index 9679197b207..65b14e36cd1 100644
--- a/client/sql_string.cc.dontuse
+++ b/client/sql_string.cc.dontuse
@@ -267,7 +267,7 @@ bool String::set_or_copy_aligned(const char *str,uint32 arg_length,
return copy_aligned(str, arg_length, offset, cs);
}
- /* Copy with charset convertion */
+ /* Copy with charset conversion */
bool String::copy(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs, uint *errors)