summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-02-11 09:26:53 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-02-11 09:26:53 +0200
commitb19ec8848c9463b86d62601dffb67c75e3dfbd70 (patch)
tree203f6bf23338813575214c23a8fee5a99f7ca2fb
parentbfb4761ca04704d68dba51f76d7c9967f880a6ee (diff)
parentc7edbe5bb1222634adb0c45ca86c62fb544ce246 (diff)
downloadmariadb-git-b19ec8848c9463b86d62601dffb67c75e3dfbd70.tar.gz
Merge 10.5 into 10.6
-rw-r--r--client/mariadb-conv.cc2
-rw-r--r--client/mysql.cc16
-rw-r--r--client/mysql_plugin.c3
-rw-r--r--client/mysql_upgrade.c11
-rw-r--r--client/mysqladmin.cc13
-rw-r--r--client/mysqlbinlog.cc94
-rw-r--r--client/mysqlcheck.c12
-rw-r--r--client/mysqldump.c16
-rw-r--r--client/mysqlimport.c11
-rw-r--r--client/mysqlshow.c11
-rw-r--r--client/mysqlslap.c11
-rw-r--r--client/mysqltest.cc12
-rw-r--r--extra/comp_err.c2
-rw-r--r--extra/innochecksum.cc2
-rw-r--r--extra/mariabackup/innobackupex.cc4
-rw-r--r--extra/mariabackup/xbstream.cc7
-rw-r--r--extra/mariabackup/xtrabackup.cc11
-rw-r--r--extra/mariabackup/xtrabackup.h2
-rw-r--r--extra/my_print_defaults.c2
-rw-r--r--extra/mysql_waitpid.c2
-rw-r--r--extra/perror.c2
-rw-r--r--extra/resolve_stack_dump.c2
-rw-r--r--extra/resolveip.c2
-rw-r--r--include/my_getopt.h2
-rw-r--r--include/mysql.h.pp3
-rw-r--r--include/mysql/plugin.h11
-rw-r--r--include/typelib.h3
-rw-r--r--mysql-test/main/grant.result1
-rw-r--r--mysql-test/main/mysqlbinlog.result18
-rw-r--r--mysql-test/main/mysqlbinlog.test28
-rw-r--r--mysql-test/suite/s3/replication.inc2
-rw-r--r--mysql-test/suite/s3/replication_mixed.result2
-rw-r--r--mysql-test/suite/s3/replication_partition.result6
-rw-r--r--mysql-test/suite/s3/replication_partition.test6
-rw-r--r--mysql-test/suite/s3/replication_stmt.result2
-rw-r--r--mysql-test/suite/s3/suite.pm4
-rw-r--r--mysys/typelib.c4
-rw-r--r--sql/mysql_install_db.cc2
-rw-r--r--sql/mysql_upgrade_service.cc2
-rw-r--r--sql/mysqld.cc111
-rw-r--r--sql/sql_partition.cc53
-rw-r--r--sql/sql_plugin.cc6
-rw-r--r--sql/sql_show.cc4
-rw-r--r--sql/sql_show.h2
-rw-r--r--sql/tztime.cc5
-rw-r--r--storage/maria/aria_chk.c7
-rw-r--r--storage/maria/aria_dump_log.c4
-rw-r--r--storage/maria/aria_ftdump.c5
-rw-r--r--storage/maria/aria_pack.c7
-rw-r--r--storage/maria/aria_read_log.c7
-rw-r--r--storage/maria/aria_s3_copy.cc2
-rw-r--r--storage/maria/ha_maria.cc3
-rw-r--r--storage/maria/ma_rt_test.c8
-rw-r--r--storage/maria/ma_static.c2
-rw-r--r--storage/maria/ma_test1.c10
-rw-r--r--storage/maria/ma_test2.c2
-rw-r--r--storage/maria/maria_def.h2
-rw-r--r--storage/maria/test_ma_backup.c2
-rw-r--r--storage/maria/unittest/ma_control_file-t.c2
-rw-r--r--storage/maria/unittest/ma_test_loghandler_multigroup-t.c2
-rw-r--r--storage/myisam/mi_test1.c2
-rw-r--r--storage/myisam/myisam_ftdump.c5
-rw-r--r--storage/myisam/myisamchk.c2
-rw-r--r--storage/myisam/myisampack.c3
-rw-r--r--tests/async_queries.c2
-rw-r--r--tests/mysql_client_fw.c11
-rw-r--r--unittest/mysys/my_getopt-t.c4
67 files changed, 399 insertions, 222 deletions
diff --git a/client/mariadb-conv.cc b/client/mariadb-conv.cc
index 03018a93dbc..835c6a2abe2 100644
--- a/client/mariadb-conv.cc
+++ b/client/mariadb-conv.cc
@@ -76,7 +76,7 @@ static struct my_option long_options[] =
my_bool
get_one_option(const struct my_option *opt,
- char *value, const char *filename)
+ const char *value, const char *filename)
{
return 0;
}
diff --git a/client/mysql.cc b/client/mysql.cc
index dcd9dfecef9..f2938d4c824 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -218,7 +218,7 @@ static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool)
/* The names of functions that actually do the manipulation. */
static int get_options(int argc,char **argv);
extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
- char *argument);
+ const char *argument);
static int com_quit(String *str,char*),
com_go(String *str,char*), com_ego(String *str,char*),
com_print(String *str,char*),
@@ -1715,7 +1715,7 @@ static void usage(int version)
my_bool
-get_one_option(const struct my_option *opt, char *argument, const char *)
+get_one_option(const struct my_option *opt, const char *argument, const char *)
{
switch(opt->id) {
case OPT_CHARSETS_DIR:
@@ -1816,7 +1816,8 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
status.add_to_history= 0;
if (!status.line_buff)
ignore_errors= 0; // do it for the first -e only
- if (!(status.line_buff= batch_readline_command(status.line_buff, argument)))
+ if (!(status.line_buff= batch_readline_command(status.line_buff,
+ (char*) argument)))
return 1;
break;
case 'o':
@@ -1830,10 +1831,15 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
argument= (char*) ""; // Don't require password
if (argument)
{
- char *start= argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; // Destroy argument
+ while (*argument)
+ *(char*)argument++= 'x'; // Destroy argument
if (*start)
start[1]=0 ;
tty_password= 0;
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index eddae6114e6..79b97eaea02 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -475,7 +475,8 @@ static void print_default_values(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
switch(opt->id) {
case 'n':
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 55afdbf9671..e49b0fd0dc0 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -270,7 +270,7 @@ static void add_one_option_cnf_file(DYNAMIC_STRING *ds,
}
static my_bool
-get_one_option(const struct my_option *opt, char *argument,
+get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
{
my_bool add_option= TRUE;
@@ -301,10 +301,17 @@ get_one_option(const struct my_option *opt, char *argument,
add_option= FALSE;
if (argument)
{
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
/* Add password to ds_args before overwriting the arg with x's */
add_one_option_cnf_file(&ds_args, opt, argument);
while (*argument)
- *argument++= 'x'; /* Destroy argument */
+ *(char*)argument++= 'x'; /* Destroy argument */
+ if (*start)
+ start[1]= 0;
tty_password= 0;
}
else
diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc
index 1a128e61533..5b59cbed30d 100644
--- a/client/mysqladmin.cc
+++ b/client/mysqladmin.cc
@@ -69,7 +69,7 @@ static uint ex_var_count, max_var_length, max_val_length;
static void print_version(void);
static void usage(void);
extern "C" my_bool get_one_option(int optid, const struct my_option *opt,
- char *argument);
+ const char *argument);
static my_bool sql_connect(MYSQL *mysql, uint wait);
static int execute_commands(MYSQL *mysql,int argc, char **argv);
static char **mask_password(int argc, char ***argv);
@@ -241,7 +241,7 @@ static const char *load_default_groups[]=
0 };
my_bool
-get_one_option(const struct my_option *opt, char *argument, const char *)
+get_one_option(const struct my_option *opt, const char *argument, const char *)
{
switch(opt->id) {
case 'c':
@@ -252,10 +252,15 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
argument= (char*) ""; // Don't require password
if (argument)
{
- char *start=argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index f3b6632cf5d..fd31ab6694e 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -95,6 +95,8 @@ static uint opt_protocol= 0;
static FILE *result_file;
static char *result_file_name= 0;
static const char *output_prefix= "";
+static char **defaults_argv= 0;
+static MEM_ROOT glob_root;
#ifndef DBUG_OFF
static const char *default_dbug_option = "d:t:o,/tmp/mariadb-binlog.trace";
@@ -1888,18 +1890,32 @@ static void cleanup()
my_free(const_cast<char*>(dirname_for_local_load));
my_free(start_datetime_str);
my_free(stop_datetime_str);
+ free_root(&glob_root, MYF(0));
delete binlog_filter;
delete glob_description_event;
if (mysql)
mysql_close(mysql);
+ free_defaults(defaults_argv);
+ free_annotate_event();
+ my_free_open_file_info();
+ load_processor.destroy();
+ mysql_server_end();
DBUG_VOID_RETURN;
}
+static void die()
+{
+ cleanup();
+ my_end(MY_DONT_FREE_DBUG);
+ exit(1);
+}
+
+
static void print_version()
{
- printf("%s Ver 3.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
+ printf("%s Ver 3.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE);
}
@@ -1930,7 +1946,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
l_time.time_type != MYSQL_TIMESTAMP_DATETIME || status.warnings)
{
error("Incorrect date and time argument: %s", str);
- exit(1);
+ die();
}
/*
Note that Feb 30th, Apr 31st cause no error messages and are mapped to
@@ -1943,7 +1959,7 @@ static my_time_t convert_str_to_timestamp(const char* str)
extern "C" my_bool
-get_one_option(const struct my_option *opt, char *argument, const char *)
+get_one_option(const struct my_option *opt, const char *argument, const char *)
{
bool tty_password=0;
switch (opt->id) {
@@ -1967,10 +1983,15 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
argument= (char*) ""; // Don't require password
if (argument)
{
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
my_free(pass);
- char *start=argument;
+ char *start= (char*) argument;
pass= my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*)argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
}
@@ -1988,7 +2009,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
- exit(1);
+ die();
}
break;
#ifdef WHEN_FLASHBACK_REVIEW_READY
@@ -2013,7 +2034,7 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
opt->name)) <= 0)
{
sf_leaking_memory= 1; /* no memory leak reports here */
- exit(1);
+ die();
}
opt_base64_output_mode= (enum_base64_output_mode) (val - 1);
}
@@ -2021,46 +2042,46 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
case OPT_REWRITE_DB: // db_from->db_to
{
/* See also handling of OPT_REPLICATE_REWRITE_DB in sql/mysqld.cc */
- char* ptr;
- char* key= argument; // db-from
- char* val; // db-to
+ const char* ptr;
+ const char* key= argument; // db-from
+ const char* val; // db-to
- // Where key begins
+ // Skipp pre-space in key
while (*key && my_isspace(&my_charset_latin1, *key))
key++;
// Where val begins
- if (!(ptr= strstr(argument, "->")))
+ if (!(ptr= strstr(key, "->")))
{
- sql_print_error("Bad syntax in rewrite-db: missing '->'!\n");
+ sql_print_error("Bad syntax in rewrite-db: missing '->'\n");
return 1;
}
val= ptr + 2;
- while (*val && my_isspace(&my_charset_latin1, *val))
- val++;
- // Write \0 and skip blanks at the end of key
- *ptr-- = 0;
- while (my_isspace(&my_charset_latin1, *ptr) && ptr > argument)
- *ptr-- = 0;
+ // Skip blanks at the end of key
+ while (ptr > key && my_isspace(&my_charset_latin1, ptr[-1]))
+ ptr--;
- if (!*key)
+ if (ptr == key)
{
- sql_print_error("Bad syntax in rewrite-db: empty db-from!\n");
+ sql_print_error("Bad syntax in rewrite-db: empty FROM db\n");
return 1;
}
+ key= strmake_root(&glob_root, key, (size_t) (ptr-key));
- // Skip blanks at the end of val
- ptr= val;
- while (*ptr && !my_isspace(&my_charset_latin1, *ptr))
- ptr++;
- *ptr= 0;
+ /* Skipp pre space in value */
+ while (*val && my_isspace(&my_charset_latin1, *val))
+ val++;
- if (!*val)
+ // Value ends with \0 or space
+ for (ptr= val; *ptr && !my_isspace(&my_charset_latin1, *ptr) ; ptr++)
+ {}
+ if (ptr == val)
{
- sql_print_error("Bad syntax in rewrite-db: empty db-to!\n");
+ sql_print_error("Bad syntax in rewrite-db: empty TO db\n");
return 1;
}
+ val= strmake_root(&glob_root, val, (size_t) (ptr-val));
binlog_filter->add_db_rewrite(key, val);
break;
@@ -2098,7 +2119,9 @@ static int parse_args(int *argc, char*** argv)
int ho_error;
if ((ho_error=handle_options(argc, argv, my_options, get_one_option)))
- exit(ho_error);
+ {
+ die();
+ }
if (debug_info_flag)
my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
else if (debug_check_flag)
@@ -3017,7 +3040,6 @@ end:
int main(int argc, char** argv)
{
- char **defaults_argv;
Exit_status retval= OK_CONTINUE;
ulonglong save_stop_position;
MY_INIT(argv[0]);
@@ -3030,6 +3052,8 @@ int main(int argc, char** argv)
load_defaults_or_exit("my", load_groups, &argc, &argv);
defaults_argv= argv;
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &glob_root, 1024, 0, MYF(0));
+
if (!(binlog_filter= new Rpl_filter))
{
error("Failed to create Rpl_filter");
@@ -3068,7 +3092,7 @@ int main(int argc, char** argv)
if (!remote_opt)
{
error("The --raw mode only works with --read-from-remote-server");
- exit(1);
+ die();
}
if (one_database)
warning("The --database option is ignored in raw mode");
@@ -3090,7 +3114,7 @@ int main(int argc, char** argv)
O_WRONLY | O_BINARY, MYF(MY_WME))))
{
error("Could not create log file '%s'", result_file_name);
- exit(1);
+ die();
}
}
else
@@ -3211,11 +3235,6 @@ int main(int argc, char** argv)
if (result_file && result_file != stdout)
my_fclose(result_file, MYF(0));
cleanup();
- free_annotate_event();
- free_defaults(defaults_argv);
- my_free_open_file_info();
- load_processor.destroy();
- mysql_server_end();
/* We cannot free DBUG, it is used in global destructors after exit(). */
my_end(my_end_arg | MY_DONT_FREE_DBUG);
@@ -3225,7 +3244,6 @@ int main(int argc, char** argv)
err:
cleanup();
- free_defaults(defaults_argv);
my_end(my_end_arg);
exit(retval == ERROR_STOP ? 1 : 0);
DBUG_RETURN(retval == ERROR_STOP ? 1 : 0);
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index d7eeec6198b..fb3103a318d 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -285,7 +285,8 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
int orig_what_to_do= what_to_do;
DBUG_ENTER("get_one_option");
@@ -324,10 +325,15 @@ get_one_option(const struct my_option *opt,
argument= (char*) ""; /* Don't require password */
if (argument)
{
- char *start = argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password = my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1] = 0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqldump.c b/client/mysqldump.c
index da4ec2756eb..7c363973da2 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -144,9 +144,9 @@ static char *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, *order_by=0,
- *opt_compatible_mode_str= 0,
*err_ptr= 0,
*log_error_file= NULL;
+static const char *opt_compatible_mode_str= 0;
static char **defaults_argv= 0;
static char compatible_mode_normal_str[255];
/* Server supports character_set_results session variable? */
@@ -279,7 +279,7 @@ static struct my_option my_long_options[] =
"no_table_options, no_field_options. One can use several modes separated "
"by commas. Note: Requires MariaDB server version 4.1.0 or higher. "
"This option is ignored with earlier server versions.",
- &opt_compatible_mode_str, &opt_compatible_mode_str, 0,
+ (char**) &opt_compatible_mode_str, (char**) &opt_compatible_mode_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"compact", OPT_COMPACT,
"Give less verbose output (useful for debugging). Disables structure "
@@ -849,7 +849,8 @@ uchar* get_table_key(const char *entry, size_t *length,
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
switch (opt->id) {
case 'p':
@@ -857,10 +858,15 @@ get_one_option(const struct my_option *opt,
argument= (char*) ""; /* Don't require password */
if (argument)
{
- char *start=argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 6cb32da2239..99b46ce3c6b 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -221,7 +221,7 @@ file. The SQL command 'LOAD DATA INFILE' is used to import the rows.\n");
static my_bool
-get_one_option(const struct my_option *opt, char *argument,
+get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
{
switch(opt->id) {
@@ -230,10 +230,15 @@ get_one_option(const struct my_option *opt, char *argument,
argument= (char*) ""; /* Don't require password */
if (argument)
{
- char *start=argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 2b0cae6dc98..a89f4eb1dd2 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -289,7 +289,7 @@ are shown.");
static my_bool
-get_one_option(const struct my_option *opt, char *argument,
+get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
{
switch(opt->id) {
@@ -301,10 +301,15 @@ get_one_option(const struct my_option *opt, char *argument,
argument= (char*) ""; /* Don't require password */
if (argument)
{
- char *start=argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password=my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqlslap.c b/client/mysqlslap.c
index 15aae234a94..1109ffbf3c8 100644
--- a/client/mysqlslap.c
+++ b/client/mysqlslap.c
@@ -726,7 +726,7 @@ static void usage(void)
static my_bool
-get_one_option(const struct my_option *opt, char *argument,
+get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
{
DBUG_ENTER("get_one_option");
@@ -739,10 +739,15 @@ get_one_option(const struct my_option *opt, char *argument,
argument= (char*) ""; /* Don't require password */
if (argument)
{
- char *start= argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument,MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]= 0; /* Cut length of argument */
tty_password= 0;
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index f8238cbb26d..73436e5165a 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -96,7 +96,8 @@ static int setenv(const char *name, const char *value, int overwrite);
C_MODE_START
static sig_handler signal_handler(int sig);
-static my_bool get_one_option(const struct my_option *, char *, const char *);
+static my_bool get_one_option(const struct my_option *, const char *,
+ const char *);
C_MODE_END
enum {
@@ -7138,7 +7139,7 @@ void read_embedded_server_arguments(const char *name)
static my_bool
-get_one_option(const struct my_option *opt, char *argument, const char *)
+get_one_option(const struct my_option *opt, const char *argument, const char *)
{
switch(opt->id) {
case '#':
@@ -7186,9 +7187,14 @@ get_one_option(const struct my_option *opt, char *argument, const char *)
argument= const_cast<char*>(""); // Don't require password
if (argument)
{
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
my_free(opt_pass);
opt_pass= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*)argument++= 'x'; /* Destroy argument */
tty_password= 0;
}
else
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 5e1e042f6ed..aab57c5ff28 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -1140,7 +1140,7 @@ static void print_version(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__ ((unused)),
+ const char *argument __attribute__ ((unused)),
const char *filename __attribute__ ((unused)))
{
DBUG_ENTER("get_one_option");
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 7805dc4283f..833e66341c7 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -1332,7 +1332,7 @@ static void usage(void)
extern "C" my_bool
innochecksum_get_one_option(
const struct my_option *opt,
- char *argument MY_ATTRIBUTE((unused)),
+ const char *argument MY_ATTRIBUTE((unused)),
const char *)
{
switch (opt->id) {
diff --git a/extra/mariabackup/innobackupex.cc b/extra/mariabackup/innobackupex.cc
index 9e95d2e6b16..e874890ad27 100644
--- a/extra/mariabackup/innobackupex.cc
+++ b/extra/mariabackup/innobackupex.cc
@@ -88,7 +88,7 @@ char *opt_ibx_incremental_history_name = NULL;
char *opt_ibx_incremental_history_uuid = NULL;
char *opt_ibx_user = NULL;
-char *opt_ibx_password = NULL;
+const char *opt_ibx_password = NULL;
char *opt_ibx_host = NULL;
char *opt_ibx_defaults_group = NULL;
char *opt_ibx_socket = NULL;
@@ -731,7 +731,7 @@ indicates an error.\n");
static
my_bool
ibx_get_one_option(const struct my_option *opt,
- char *argument, const char *)
+ const char *argument, const char *)
{
switch(opt->id) {
case '?':
diff --git a/extra/mariabackup/xbstream.cc b/extra/mariabackup/xbstream.cc
index c22c7cc8f39..3fe9d17d86e 100644
--- a/extra/mariabackup/xbstream.cc
+++ b/extra/mariabackup/xbstream.cc
@@ -90,7 +90,7 @@ static int get_options(int *argc, char ***argv);
static int mode_create(int argc, char **argv);
static int mode_extract(int n_threads, int argc, char **argv);
static my_bool get_one_option(const struct my_option *opt,
- char *argument, const char *filename);
+ const char *argument, const char *filename);
int
main(int argc, char **argv)
@@ -138,7 +138,8 @@ get_options(int *argc, char ***argv)
int ho_error;
if ((ho_error= handle_options(argc, argv, my_long_options,
- get_one_option))) {
+ get_one_option)))
+ {
exit(EXIT_FAILURE);
}
@@ -191,7 +192,7 @@ set_run_mode(run_mode_t mode)
static
my_bool
-get_one_option(const struct my_option *opt, char *, const char *)
+get_one_option(const struct my_option *opt, const char *, const char *)
{
switch (opt->id) {
case 'c':
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index fc57eed6c85..62fdace654d 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -310,7 +310,7 @@ char *opt_incremental_history_name;
char *opt_incremental_history_uuid;
char *opt_user;
-char *opt_password;
+const char *opt_password;
char *opt_host;
char *opt_defaults_group;
char *opt_socket;
@@ -1846,7 +1846,7 @@ check_if_param_set(const char *param)
my_bool
xb_get_one_option(const struct my_option *opt,
- char *argument, const char *)
+ const char *argument, const char *)
{
switch(opt->id) {
case 'h':
@@ -6323,9 +6323,10 @@ void handle_options(int argc, char **argv, char ***argv_server,
if (opt_password)
{
- char *argument= opt_password;
- char *start= argument;
- opt_password= my_strdup(PSI_NOT_INSTRUMENTED, opt_password, MYF(MY_FAE));
+ char *argument= (char*) opt_password;
+ char *start= (char*) opt_password;
+ opt_password= my_strdup(PSI_NOT_INSTRUMENTED, opt_password,
+ MYF(MY_FAE));
while (*argument)
*argument++= 'x'; // Destroy argument
if (*start)
diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h
index 6376849430c..aff7d1cb287 100644
--- a/extra/mariabackup/xtrabackup.h
+++ b/extra/mariabackup/xtrabackup.h
@@ -144,7 +144,7 @@ extern char *opt_incremental_history_name;
extern char *opt_incremental_history_uuid;
extern char *opt_user;
-extern char *opt_password;
+extern const char *opt_password;
extern char *opt_host;
extern char *opt_defaults_group;
extern char *opt_socket;
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 09bd26c59ea..a8c8050cb1d 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -105,7 +105,7 @@ static void usage()
static my_bool
get_one_option(const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename)
{
switch (opt->id) {
diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c
index 92716489bea..8f2a5c99395 100644
--- a/extra/mysql_waitpid.c
+++ b/extra/mysql_waitpid.c
@@ -45,7 +45,7 @@ static struct my_option my_long_options[] =
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/extra/perror.c b/extra/perror.c
index 131dd2676ec..ee6e362e06b 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -97,7 +97,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {
diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c
index c4ed2a9ccd7..cb4d6ed33e5 100644
--- a/extra/resolve_stack_dump.c
+++ b/extra/resolve_stack_dump.c
@@ -112,7 +112,7 @@ void local_exit(int error)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 6812bc47e8e..890912d9850 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -72,7 +72,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {
diff --git a/include/my_getopt.h b/include/my_getopt.h
index 642fb344d92..ffff706e015 100644
--- a/include/my_getopt.h
+++ b/include/my_getopt.h
@@ -89,7 +89,7 @@ struct my_option
void *app_type; /**< To be used by an application */
};
-typedef my_bool (*my_get_one_option)(const struct my_option *, char *, const char *);
+typedef my_bool (*my_get_one_option)(const struct my_option *, const char *, const char *);
/**
Used to retrieve a reference to the object (variable) that holds the value
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index e906e4e1a86..584276a7a08 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -270,7 +270,8 @@ typedef struct st_typelib {
const char **type_names;
unsigned int *type_lengths;
} TYPELIB;
-extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
+extern my_ulonglong find_typeset(const char *x, TYPELIB *typelib,
+ int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags);
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 07e7597fbd8..738ffc6c53f 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -313,6 +313,12 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
const type def_val; \
} MYSQL_SYSVAR_NAME(name)
+#define DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, type) struct { \
+ MYSQL_PLUGIN_VAR_HEADER; \
+ const type *value; \
+ const type def_val; \
+} MYSQL_SYSVAR_NAME(name)
+
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
MYSQL_PLUGIN_VAR_HEADER; \
type *value; type def_val; \
@@ -367,6 +373,11 @@ DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def}
+#define MYSQL_SYSVAR_CONST_STR(name, varname, opt, comment, check, update, def) \
+DECLARE_MYSQL_SYSVAR_CONST_BASIC(name, char *) = { \
+ PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
+ #name, comment, check, update, &varname, def}
+
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
diff --git a/include/typelib.h b/include/typelib.h
index 23df737d307..dc315dd3bb8 100644
--- a/include/typelib.h
+++ b/include/typelib.h
@@ -27,7 +27,8 @@ typedef struct st_typelib { /* Different types saved here */
unsigned int *type_lengths;
} TYPELIB;
-extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position);
+extern my_ulonglong find_typeset(const char *x, TYPELIB *typelib,
+ int *error_position);
extern int find_type_with_warning(const char *x, TYPELIB *typelib,
const char *option);
#define FIND_TYPE_BASIC 0
diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result
index 671b6dc4247..92073388b69 100644
--- a/mysql-test/main/grant.result
+++ b/mysql-test/main/grant.result
@@ -623,6 +623,7 @@ References Databases,Tables To have references on tables
Reload Server Admin To reload or refresh tables, logs and privileges
Binlog admin Server To purge binary logs
Binlog monitor Server To use SHOW BINLOG STATUS and SHOW BINARY LOG
+Binlog replay Server To use BINLOG (generated by mariadb-binlog)
Replication master admin Server To monitor connected slaves
Replication slave admin Server To start/stop slave and apply binlog events
Slave monitor Server To use SHOW SLAVE STATUS and SHOW RELAYLOG EVENTS
diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result
index e31246efef9..8e12ecdf8c1 100644
--- a/mysql-test/main/mysqlbinlog.result
+++ b/mysql-test/main/mysqlbinlog.result
@@ -1257,3 +1257,21 @@ ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
mysqlbinlog Ver VER for OS at ARCH
+#
+# Test --rewrite-db
+#
+RESET MASTER;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 values(1);
+DROP TABLE t1;
+FLUSH LOGS;
+ERROR: Bad syntax in rewrite-db: missing '->'
+
+ERROR: Bad syntax in rewrite-db: empty TO db
+
+ERROR: Bad syntax in rewrite-db: empty TO db
+
+ERROR: Bad syntax in rewrite-db: empty FROM db
+
+ERROR: Bad syntax in rewrite-db: empty FROM db
+
diff --git a/mysql-test/main/mysqlbinlog.test b/mysql-test/main/mysqlbinlog.test
index e0503402bd6..79b745e1645 100644
--- a/mysql-test/main/mysqlbinlog.test
+++ b/mysql-test/main/mysqlbinlog.test
@@ -130,6 +130,7 @@ select "--- reading stdin --" as "";
# postion is constant to correspond to an event in pre-recorded binlog
--let $binlog_start_pos=79
--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
+
drop table t1,t2;
#
@@ -595,3 +596,30 @@ eval SET GLOBAL SERVER_ID = $old_server_id;
#
replace_regex /.*mysqlbinlog(\.exe)? Ver .* for .* at [-_a-zA-Z0-9]+/mysqlbinlog Ver VER for OS at ARCH/;
exec $MYSQL_BINLOG --version;
+
+--echo #
+--echo # Test --rewrite-db
+--echo #
+
+RESET MASTER;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 values(1);
+DROP TABLE t1;
+FLUSH LOGS;
+
+--error 1
+--exec $MYSQL_BINLOG --rewrite-db=a --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
+
+--error 1
+--exec $MYSQL_BINLOG --rewrite-db="a->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
+
+--error 1
+--exec $MYSQL_BINLOG --rewrite-db="a-> " --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
+
+--error 1
+--exec $MYSQL_BINLOG --rewrite-db="->b" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
+
+--error 1
+--exec $MYSQL_BINLOG --rewrite-db=" ->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
+
+--exec $MYSQL_BINLOG --rewrite-db=" test -> foo " --short-form $MYSQLD_DATADIR/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
diff --git a/mysql-test/suite/s3/replication.inc b/mysql-test/suite/s3/replication.inc
index d30733a4396..cfa38d93f98 100644
--- a/mysql-test/suite/s3/replication.inc
+++ b/mysql-test/suite/s3/replication.inc
@@ -81,6 +81,8 @@ show create table t2;
connection master;
drop table t2;
+sync_slave_with_master;
+connection master;
--echo #
--echo # Test RENAME
diff --git a/mysql-test/suite/s3/replication_mixed.result b/mysql-test/suite/s3/replication_mixed.result
index 66ed24d2626..6b9b87a7891 100644
--- a/mysql-test/suite/s3/replication_mixed.result
+++ b/mysql-test/suite/s3/replication_mixed.result
@@ -105,6 +105,8 @@ t2 CREATE TABLE `t2` (
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
connection master;
drop table t2;
+connection slave;
+connection master;
#
# Test RENAME
#
diff --git a/mysql-test/suite/s3/replication_partition.result b/mysql-test/suite/s3/replication_partition.result
index 2b9297ea9a0..0a57a1b872d 100644
--- a/mysql-test/suite/s3/replication_partition.result
+++ b/mysql-test/suite/s3/replication_partition.result
@@ -13,10 +13,14 @@ PARTITION BY HASH (c1)
PARTITIONS 3;
INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
ALTER TABLE t1 ENGINE=S3;
+connection slave;
+connection master;
ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
select sum(c1) from t1;
sum(c1)
609
+connection slave;
+connection master;
ALTER TABLE t1 ADD COLUMN c INT;
select sum(c1) from t1;
sum(c1)
@@ -108,6 +112,8 @@ select sum(c1) from t1;
ERROR 42S02: Table 'database.t1' doesn't exist
start slave;
connection master;
+connection slave;
+connection master;
#
# Check altering partitioned table to S3 and back
# Checks also rename partitoned table and drop partition
diff --git a/mysql-test/suite/s3/replication_partition.test b/mysql-test/suite/s3/replication_partition.test
index 8a8699920bf..254924f9051 100644
--- a/mysql-test/suite/s3/replication_partition.test
+++ b/mysql-test/suite/s3/replication_partition.test
@@ -29,8 +29,12 @@ CREATE TABLE t1 (
PARTITIONS 3;
INSERT INTO t1 VALUE (1), (2), (101), (102), (201), (202);
ALTER TABLE t1 ENGINE=S3;
+sync_slave_with_master;
+connection master;
ALTER TABLE t1 ADD PARTITION PARTITIONS 6;
select sum(c1) from t1;
+sync_slave_with_master;
+connection master;
ALTER TABLE t1 ADD COLUMN c INT;
select sum(c1) from t1;
sync_slave_with_master;
@@ -85,6 +89,8 @@ select sum(c1) from t1;
--file_exists $MYSQLD_DATADIR/$database/t1.par
start slave;
connection master;
+sync_slave_with_master;
+connection master;
--echo #
--echo # Check altering partitioned table to S3 and back
diff --git a/mysql-test/suite/s3/replication_stmt.result b/mysql-test/suite/s3/replication_stmt.result
index 077029e2d7d..4b8306687db 100644
--- a/mysql-test/suite/s3/replication_stmt.result
+++ b/mysql-test/suite/s3/replication_stmt.result
@@ -105,6 +105,8 @@ t2 CREATE TABLE `t2` (
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
connection master;
drop table t2;
+connection slave;
+connection master;
#
# Test RENAME
#
diff --git a/mysql-test/suite/s3/suite.pm b/mysql-test/suite/s3/suite.pm
index 359235ecbe7..cdefbc5e323 100644
--- a/mysql-test/suite/s3/suite.pm
+++ b/mysql-test/suite/s3/suite.pm
@@ -25,12 +25,12 @@ else
{
if (!$ENV{'S3_HOST_NAME'})
{
- return "Environment variable S3_HOST_NAME need to be set";
+ $ENV{'S3_HOST_NAME'} = "s3.amazonaws.com";
}
if (!$ENV{'S3_BUCKET'})
{
- return "Environment variable S3_BUCKET need to be set";
+ $ENV{'S3_BUCKET'} = "MariaDB";
}
if (!$ENV{'S3_REGION'})
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 715e7ad42ba..03f3609b5e8 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -182,11 +182,11 @@ const char *get_type(TYPELIB *typelib, uint nr)
a integer representation of the supplied string
*/
-my_ulonglong find_typeset(char *x, TYPELIB *lib, int *err)
+my_ulonglong find_typeset(const char *x, TYPELIB *lib, int *err)
{
my_ulonglong result;
int find;
- char *i;
+ const char *i;
DBUG_ENTER("find_set");
DBUG_PRINT("enter",("x: '%s' lib: %p", x, lib));
diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc
index 04f3789bad4..f712e29b843 100644
--- a/sql/mysql_install_db.cc
+++ b/sql/mysql_install_db.cc
@@ -103,7 +103,7 @@ static struct my_option my_long_options[]=
static my_bool
-get_one_option(const struct my_option *opt, char *, const char *)
+get_one_option(const struct my_option *opt, const char *, const char *)
{
DBUG_ENTER("get_one_option");
switch (opt->id) {
diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc
index 60fd8fc7efa..dc8250ba438 100644
--- a/sql/mysql_upgrade_service.cc
+++ b/sql/mysql_upgrade_service.cc
@@ -78,7 +78,7 @@ static struct my_option my_long_options[]=
static my_bool
-get_one_option(const struct my_option *opt, char *, const char *)
+get_one_option(const struct my_option *opt, const char *, const char *)
{
DBUG_ENTER("get_one_option");
switch (opt->id) {
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d0477b0effd..0bf21e02002 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -332,7 +332,7 @@ static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0, opt_silent_startup= 0;
ulong max_used_connections;
-static char *mysqld_user, *mysqld_chroot;
+static const char *mysqld_user, *mysqld_chroot;
static char *default_character_set_name;
static char *character_set_filesystem_name;
static char *lc_messages;
@@ -375,6 +375,8 @@ uint volatile global_disable_checkpoint;
#if defined(_WIN32)
ulong slow_start_timeout;
#endif
+static MEM_ROOT startup_root;
+
/**
@brief 'grant_option' is used to indicate if privileges needs
to be checked, in which case the lock, LOCK_grant, is used
@@ -1476,7 +1478,8 @@ static int mysql_init_variables(void);
static int get_options(int *argc_ptr, char ***argv_ptr);
static bool add_terminator(DYNAMIC_ARRAY *options);
static bool add_many_options(DYNAMIC_ARRAY *, my_option *, size_t);
-extern "C" my_bool mysqld_get_one_option(const struct my_option *, char *, const char *);
+extern "C" my_bool mysqld_get_one_option(const struct my_option *, const char *,
+ const char *);
static int init_thread_environment();
static char *get_relative_path(const char *path);
static int fix_paths(void);
@@ -2028,6 +2031,7 @@ static void clean_up(bool print_message)
thread_scheduler= 0;
mysql_library_end();
finish_client_errs();
+ free_root(&startup_root, MYF(0));
cleanup_errmsgs();
free_error_messages();
/* Tell main we are ready */
@@ -3628,6 +3632,7 @@ static int init_early_variables()
set_current_thd(0);
set_malloc_size_cb(my_malloc_size_cb_func);
global_status_var.global_memory_used= 0;
+ init_alloc_root(PSI_NOT_INSTRUMENTED, &startup_root, 1024, 0, MYF(0));
return 0;
}
@@ -7674,7 +7679,7 @@ static int mysql_init_variables(void)
}
my_bool
-mysqld_get_one_option(const struct my_option *opt, char *argument,
+mysqld_get_one_option(const struct my_option *opt, const char *argument,
const char *filename)
{
if (opt->app_type)
@@ -7851,31 +7856,43 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
case (int)OPT_REPLICATE_REWRITE_DB:
{
/* See also OPT_REWRITE_DB handling in client/mysqlbinlog.cc */
- char* key = argument,*p, *val;
+ const char* key= argument, *ptr, *val;
+
+ // Skipp pre-space in key
+ while (*key && my_isspace(mysqld_charset, *key))
+ key++;
- if (!(p= strstr(argument, "->")))
+ // Where val begins
+ if (!(ptr= strstr(key, "->")))
{
- sql_print_error("Bad syntax in replicate-rewrite-db - missing '->'!");
+ sql_print_error("Bad syntax in replicate-rewrite-db: missing '->'");
return 1;
}
- val= p--;
- while (my_isspace(mysqld_charset, *p) && p > argument)
- *p-- = 0;
- /* Db name can be one char also */
- if (p == argument && my_isspace(mysqld_charset, *p))
+ val= ptr+2;
+
+ // Skip blanks at the end of key
+ while (ptr > key && my_isspace(mysqld_charset, ptr[-1]))
+ ptr--;
+ if (ptr == key)
{
- sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db!");
+ sql_print_error("Bad syntax in replicate-rewrite-db - empty FROM db");
return 1;
}
- *val= 0;
- val+= 2;
+ key= strmake_root(&startup_root, key, (size_t) (ptr-key));
+
+ /* Skipp pre space in value */
while (*val && my_isspace(mysqld_charset, *val))
val++;
- if (!*val)
+
+ // Value ends with \0 or space
+ for (ptr= val; *ptr && !my_isspace(&my_charset_latin1, *ptr) ; ptr++)
+ {}
+ if (ptr == val)
{
- sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db!");
+ sql_print_error("Bad syntax in replicate-rewrite-db - empty TO db");
return 1;
}
+ val= strmake_root(&startup_root, val, (size_t) (ptr-val));
cur_rpl_filter->add_db_rewrite(key, val);
break;
@@ -7902,7 +7919,7 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
{
if (cur_rpl_filter->add_do_table(argument))
{
- sql_print_error("Could not add do table rule '%s'!", argument);
+ sql_print_error("Could not add do table rule '%s'", argument);
return 1;
}
break;
@@ -7911,7 +7928,7 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
{
if (cur_rpl_filter->add_wild_do_table(argument))
{
- sql_print_error("Could not add do table rule '%s'!", argument);
+ sql_print_error("Could not add do table rule '%s'", argument);
return 1;
}
break;
@@ -7920,7 +7937,7 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
{
if (cur_rpl_filter->add_wild_ignore_table(argument))
{
- sql_print_error("Could not add ignore table rule '%s'!", argument);
+ sql_print_error("Could not add ignore table rule '%s'", argument);
return 1;
}
break;
@@ -7929,7 +7946,7 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
{
if (cur_rpl_filter->add_ignore_table(argument))
{
- sql_print_error("Could not add ignore table rule '%s'!", argument);
+ sql_print_error("Could not add ignore table rule '%s'", argument);
return 1;
}
break;
@@ -8040,10 +8057,14 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#ifndef EMBEDDED_LIBRARY
/* Parse instrument name and value from argument string */
- char* name = argument,*p, *val;
+ const char *name= argument, *ptr, *val;
+
+ /* Trim leading spaces from instrument name */
+ while (*name && my_isspace(mysqld_charset, *name))
+ name++;
/* Assignment required */
- if (!(p= strchr(argument, '=')))
+ if (!(ptr= strchr(name, '=')))
{
my_getopt_error_reporter(WARNING_LEVEL,
"Missing value for performance_schema_instrument "
@@ -8052,54 +8073,43 @@ mysqld_get_one_option(const struct my_option *opt, char *argument,
}
/* Option value */
- val= p + 1;
- if (!*val)
- {
- my_getopt_error_reporter(WARNING_LEVEL,
- "Missing value for performance_schema_instrument "
- "'%s'", argument);
- return 0;
- }
-
- /* Trim leading spaces from instrument name */
- while (*name && my_isspace(mysqld_charset, *name))
- name++;
+ val= ptr + 1;
/* Trim trailing spaces and slashes from instrument name */
- while (p > argument && (my_isspace(mysqld_charset, p[-1]) || p[-1] == '/'))
- p--;
- *p= 0;
-
- if (!*name)
+ while (ptr > name && (my_isspace(mysqld_charset, ptr[-1]) ||
+ ptr[-1] == '/'))
+ ptr--;
+ if (ptr == name)
{
my_getopt_error_reporter(WARNING_LEVEL,
"Invalid instrument name for "
- "performance_schema_instrument '%s'", argument);
- return 0;
+ "performance_schema_instrument '%s'", name);
+ return 0;
}
+ name= strmake_root(&startup_root, name, (size_t) (ptr - name));
/* Trim leading spaces from option value */
while (*val && my_isspace(mysqld_charset, *val))
val++;
- /* Trim trailing spaces from option value */
- if ((p= my_strchr(mysqld_charset, val, val+strlen(val), ' ')) != NULL)
- *p= 0;
-
- if (!*val)
+ /* Find end of value */
+ for (ptr= val; *ptr && !my_isspace(mysqld_charset, *ptr) ; ptr++)
+ {}
+ if (ptr == val)
{
my_getopt_error_reporter(WARNING_LEVEL,
- "Invalid value for performance_schema_instrument "
- "'%s'", argument);
+ "No value for performance_schema_instrument "
+ "'%s'", name);
return 0;
}
+ val= strmake_root(&startup_root, val, (size_t) (ptr - val));
/* Add instrument name and value to array of configuration options */
if (add_pfs_instr_to_array(name, val))
{
my_getopt_error_reporter(WARNING_LEVEL,
"Invalid value for performance_schema_instrument "
- "'%s'", argument);
+ "'%s'", name);
return 0;
}
#endif /* EMBEDDED_LIBRARY */
@@ -8266,7 +8276,8 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
/* Skip unknown options so that they may be processed later by plugins */
my_getopt_skip_unknown= TRUE;
- if ((ho_error= handle_options(argc_ptr, argv_ptr, (my_option*)(all_options.buffer),
+ if ((ho_error= handle_options(argc_ptr, argv_ptr,
+ (my_option*) (all_options.buffer),
mysqld_get_one_option)))
return ho_error;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 9051484b6b8..3d33731da5c 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -7174,23 +7174,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
4) Close the table that have already been opened but didn't stumble on
the abort locked previously. This is done as part of the
alter_close_table call.
- 5) Write the bin log
- Unfortunately the writing of the binlog is not synchronised with
- other logging activities. So no matter in which order the binlog
- is written compared to other activities there will always be cases
- where crashes make strange things occur. In this placement it can
- happen that the ALTER TABLE DROP PARTITION gets performed in the
- master but not in the slaves if we have a crash, after writing the
- ddl log but before writing the binlog. A solution to this would
- require writing the statement first in the ddl log and then
- when recovering from the crash read the binlog and insert it into
- the binlog if not written already.
+ 5) Old place for binary logging
6) Install the previously written shadow frm file
7) Prepare handlers for drop of partitions
8) Drop the partitions
9) Remove entries from ddl log
10) Reopen table if under lock tables
- 11) Complete query
+ 11) Write the bin log
+ Unfortunately the writing of the binlog is not synchronised with
+ other logging activities. So no matter in which order the binlog
+ is written compared to other activities there will always be cases
+ where crashes make strange things occur. In this placement it can
+ happen that the ALTER TABLE DROP PARTITION gets performed in the
+ master but not in the slaves if we have a crash, after writing the
+ ddl log but before writing the binlog. A solution to this would
+ require writing the statement first in the ddl log and then
+ when recovering from the crash read the binlog and insert it into
+ the binlog if not written already.
+ 12) Complete query
We insert Error injections at all places where it could be interesting
to test if recovery is properly done.
@@ -7211,9 +7212,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_5") ||
ERROR_INJECT_ERROR("fail_drop_partition_5") ||
- ((!thd->lex->no_write_to_binlog) &&
- (write_bin_log(thd, FALSE,
- thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_drop_partition_6") ||
ERROR_INJECT_ERROR("fail_drop_partition_6") ||
(frm_install= TRUE, FALSE) ||
@@ -7225,6 +7223,9 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_drop_partition_8") ||
ERROR_INJECT_ERROR("fail_drop_partition_8") ||
(write_log_completed(lpt, FALSE), FALSE) ||
+ ((!thd->lex->no_write_to_binlog) &&
+ (write_bin_log(thd, FALSE,
+ thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
ERROR_INJECT_ERROR("fail_drop_partition_9"))
{
@@ -7257,7 +7258,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
3) Write an entry to remove the new parttions if crash occurs
4) Add the new partitions.
5) Close all instances of the table and remove them from the table cache.
- 6) Write binlog
+ 6) Old place for write binlog
7) Now the change is completed except for the installation of the
new frm file. We thus write an action in the log to change to
the shadow frm file
@@ -7265,7 +7266,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
added to the table.
9) Remove entries from ddl log
10)Reopen tables if under lock tables
- 11)Complete query
+ 11)Write to binlog
+ 12)Complete query
*/
if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_1") ||
@@ -7285,9 +7287,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
alter_close_table(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_6") ||
ERROR_INJECT_ERROR("fail_add_partition_6") ||
- ((!thd->lex->no_write_to_binlog) &&
- (write_bin_log(thd, FALSE,
- thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_add_partition_7") ||
ERROR_INJECT_ERROR("fail_add_partition_7") ||
write_log_rename_frm(lpt) ||
@@ -7300,6 +7299,9 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_add_partition_9") ||
ERROR_INJECT_ERROR("fail_add_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) ||
+ ((!thd->lex->no_write_to_binlog) &&
+ (write_bin_log(thd, FALSE,
+ thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_add_partition_10") ||
ERROR_INJECT_ERROR("fail_add_partition_10"))
{
@@ -7356,13 +7358,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
5) Close the table.
6) Log that operation is completed and log all complete actions
needed to complete operation from here.
- 7) Write bin log.
+ 7) Old place for write bin log.
8) Prepare handlers for rename and delete of partitions.
9) Rename and drop the reorged partitions such that they are no
longer used and rename those added to their real new names.
10) Install the shadow frm file.
11) Reopen the table if under lock tables.
- 12) Complete query.
+ 12) Write to binlog
+ 13) Complete query.
*/
if (write_log_drop_shadow_frm(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_1") ||
@@ -7386,9 +7389,6 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
(action_completed= TRUE, FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
ERROR_INJECT_ERROR("fail_change_partition_7") ||
- ((!thd->lex->no_write_to_binlog) &&
- (write_bin_log(thd, FALSE,
- thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_8") ||
ERROR_INJECT_ERROR("fail_change_partition_8") ||
((frm_install= TRUE), FALSE) ||
@@ -7403,6 +7403,9 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_change_partition_11") ||
ERROR_INJECT_ERROR("fail_change_partition_11") ||
(write_log_completed(lpt, FALSE), FALSE) ||
+ ((!thd->lex->no_write_to_binlog) &&
+ (write_bin_log(thd, FALSE,
+ thd->query(), thd->query_length()), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_12") ||
ERROR_INJECT_ERROR("fail_change_partition_12"))
{
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 633d969b3de..02ae08c910c 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -4043,8 +4043,10 @@ static my_option *construct_help_options(MEM_ROOT *mem_root,
DBUG_RETURN(opts);
}
-extern "C" my_bool mark_changed(const struct my_option *, char *, const char *);
-my_bool mark_changed(const struct my_option *opt, char *, const char *filename)
+extern "C" my_bool mark_changed(const struct my_option *, const char *,
+ const char *);
+my_bool mark_changed(const struct my_option *opt, const char *,
+ const char *filename)
{
if (opt->app_type)
{
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b07a1cdf392..4c5e877cce8 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -483,6 +483,7 @@ static struct show_privileges_st sys_privileges[]=
{"Reload", "Server Admin", "To reload or refresh tables, logs and privileges"},
{"Binlog admin", "Server", "To purge binary logs"},
{"Binlog monitor", "Server", "To use SHOW BINLOG STATUS and SHOW BINARY LOG"},
+ {"Binlog replay", "Server", "To use BINLOG (generated by mariadb-binlog)"},
{"Replication master admin", "Server", "To monitor connected slaves"},
{"Replication slave admin", "Server", "To start/stop slave and apply binlog events"},
{"Slave monitor", "Server", "To use SHOW SLAVE STATUS and SHOW RELAYLOG EVENTS"},
@@ -618,8 +619,7 @@ db_dirs_hash_get_key(const uchar *data, size_t *len_ret,
@retval FALSE success
*/
-bool
-push_ignored_db_dir(char *path)
+bool push_ignored_db_dir(const char *path)
{
LEX_CSTRING *new_elt;
char *new_elt_buffer;
diff --git a/sql/sql_show.h b/sql/sql_show.h
index 79a6e9fb354..3d7a4d1146c 100644
--- a/sql/sql_show.h
+++ b/sql/sql_show.h
@@ -253,7 +253,7 @@ bool ignore_db_dirs_init();
void ignore_db_dirs_free();
void ignore_db_dirs_reset();
bool ignore_db_dirs_process_additions();
-bool push_ignored_db_dir(char *path);
+bool push_ignored_db_dir(const char *path);
extern char *opt_ignore_db_dirs;
#endif /* SQL_SHOW_H */
diff --git a/sql/tztime.cc b/sql/tztime.cc
index 8e08a201e88..5a8d6915cec 100644
--- a/sql/tztime.cc
+++ b/sql/tztime.cc
@@ -2656,7 +2656,8 @@ static struct my_option my_long_options[] =
C_MODE_START
-static my_bool get_one_option(const struct my_option *, char *, const char *);
+static my_bool get_one_option(const struct my_option *, const char *,
+ const char *);
C_MODE_END
static void print_version(void)
@@ -2678,7 +2679,7 @@ static void print_usage(void)
static my_bool
-get_one_option(const struct my_option *opt, char *argument, const char *)
+get_one_option(const struct my_option *opt, const char *argument, const char *)
{
switch(opt->id) {
case '#':
diff --git a/storage/maria/aria_chk.c b/storage/maria/aria_chk.c
index 4f8438fb9d0..8f7f1b11b6f 100644
--- a/storage/maria/aria_chk.c
+++ b/storage/maria/aria_chk.c
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
MY_INIT(argv[0]);
my_setup_stacktrace();
- default_log_dir= opt_log_dir= maria_data_root= (char *)".";
+ default_log_dir= opt_log_dir= maria_data_root= ".";
maria_chk_init(&check_param);
check_param.opt_lock_memory= 1; /* Lock memory if possible */
check_param.using_global_keycache = 0;
@@ -322,7 +322,7 @@ static struct my_option my_long_options[] =
0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0},
{"datadir", 'h',
"Path for control file (and logs if --logdir not used).",
- &maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
+ (char**) &maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"logdir", OPT_LOG_DIR,
"Path for log files.",
@@ -639,7 +639,8 @@ TYPELIB maria_stats_method_typelib= {
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
switch (opt->id) {
#ifdef __NETWARE__
diff --git a/storage/maria/aria_dump_log.c b/storage/maria/aria_dump_log.c
index 2e69c56a470..8e065e9ff9d 100644
--- a/storage/maria/aria_dump_log.c
+++ b/storage/maria/aria_dump_log.c
@@ -88,7 +88,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {
@@ -143,7 +143,7 @@ int main(int argc, char **argv)
translog_table_init();
translog_fill_overhead_table();
- maria_data_root= (char *)".";
+ maria_data_root= ".";
if ((handler= my_open(opt_file, O_RDONLY, MYF(MY_WME))) < 0)
{
diff --git a/storage/maria/aria_ftdump.c b/storage/maria/aria_ftdump.c
index d0c98086ad2..8526f5fa74a 100644
--- a/storage/maria/aria_ftdump.c
+++ b/storage/maria/aria_ftdump.c
@@ -21,7 +21,8 @@
static void usage();
static void complain(int val);
-static my_bool get_one_option(const struct my_option *, char *, const char*);
+static my_bool get_one_option(const struct my_option *, const char *,
+ const char*);
static int count=0, stats=0, dump=0, lstats=0;
static my_bool verbose;
@@ -233,7 +234,7 @@ err:
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/maria/aria_pack.c b/storage/maria/aria_pack.c
index 0c2767d780e..40e7e399613 100644
--- a/storage/maria/aria_pack.c
+++ b/storage/maria/aria_pack.c
@@ -229,7 +229,7 @@ int main(int argc, char **argv)
my_bool no_control_file= 0;
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
load_defaults_or_exit("my", load_default_groups, &argc, &argv);
default_argv= argv;
get_options(&argc,&argv);
@@ -316,7 +316,7 @@ static struct my_option my_long_options[] =
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"datadir", 'h',
"Path for control file (and logs if --logdir not used).",
- &maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
+ (char**) &maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
@@ -381,7 +381,8 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
uint length;
diff --git a/storage/maria/aria_read_log.c b/storage/maria/aria_read_log.c
index a3a6d4375c1..a96fd254e0e 100644
--- a/storage/maria/aria_read_log.c
+++ b/storage/maria/aria_read_log.c
@@ -83,7 +83,7 @@ int main(int argc, char **argv)
uint warnings_count;
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
sf_leaking_memory=1; /* don't report memory leaks on early exits */
load_defaults_or_exit("my", load_default_groups, &argc, &argv);
default_argv= argv;
@@ -248,7 +248,7 @@ static struct my_option my_long_options[] =
0, 0, 0, 0 },
{"aria-log-dir-path", 'h',
"Path to the directory where to store transactional log",
- (uchar **) &maria_data_root, (uchar **) &maria_data_root, 0,
+ (char **) &maria_data_root, (char **) &maria_data_root, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{ "page-buffer-size", 'P',
"The size of the buffer used for index blocks for Aria tables",
@@ -343,7 +343,8 @@ static uchar* my_hash_get_string(const uchar *record, size_t *length,
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
switch (opt->id) {
case '?':
diff --git a/storage/maria/aria_s3_copy.cc b/storage/maria/aria_s3_copy.cc
index 734c99eac3b..f324c0896e5 100644
--- a/storage/maria/aria_s3_copy.cc
+++ b/storage/maria/aria_s3_copy.cc
@@ -138,7 +138,7 @@ ATTRIBUTE_NORETURN static void my_exit(int exit_code)
extern "C" my_bool get_one_option(const struct my_option *opt
__attribute__((unused)),
- char *argument, const char *filename)
+ const char *argument, const char *filename)
{
switch (opt->id) {
case 'V':
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 5faba898ba9..ea42763871e 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -187,12 +187,11 @@ static MYSQL_SYSVAR_BOOL(page_checksum, maria_page_checksums, 0,
"with PAGE_CHECKSUM clause in CREATE TABLE)", 0, 0, 1);
/* It is only command line argument */
-static MYSQL_SYSVAR_STR(log_dir_path, maria_data_root,
+static MYSQL_SYSVAR_CONST_STR(log_dir_path, maria_data_root,
PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to the directory where to store transactional log",
NULL, NULL, mysql_real_data_home);
-
static MYSQL_SYSVAR_ULONG(log_file_size, log_file_size,
PLUGIN_VAR_RQCMDARG,
"Limit for transaction log size",
diff --git a/storage/maria/ma_rt_test.c b/storage/maria/ma_rt_test.c
index 12f35af7cc1..8d9fafc24aa 100644
--- a/storage/maria/ma_rt_test.c
+++ b/storage/maria/ma_rt_test.c
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
{
char buff[FN_REFLEN];
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
get_options(argc, argv);
/* Maria requires that we always have a page cache */
if (maria_init() ||
@@ -616,8 +616,8 @@ static struct my_option my_long_options[] =
#endif
{"help", '?', "Display help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
- {"datadir", 'h', "Path to the database root.", &maria_data_root,
- &maria_data_root, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"datadir", 'h', "Path to the database root.", (char**) &maria_data_root,
+ (char**) &maria_data_root, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"row-fixed-size", 'S', "Fixed size records",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"rows-in-block", 'M', "Store rows in block format",
@@ -645,7 +645,7 @@ static struct my_option my_long_options[] =
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/maria/ma_static.c b/storage/maria/ma_static.c
index de5b852a78d..309069e2feb 100644
--- a/storage/maria/ma_static.c
+++ b/storage/maria/ma_static.c
@@ -62,7 +62,7 @@ PAGECACHE *maria_pagecache= &maria_pagecache_var;
PAGECACHE maria_log_pagecache_var;
PAGECACHE *maria_log_pagecache= &maria_log_pagecache_var;
MY_TMPDIR *maria_tmpdir; /* Tempdir for redo */
-char *maria_data_root;
+const char *maria_data_root;
HASH maria_stored_state;
int (*maria_create_trn_hook)(MARIA_HA *);
diff --git a/storage/maria/ma_test1.c b/storage/maria/ma_test1.c
index bbdb08257e1..22f80ca2d9e 100644
--- a/storage/maria/ma_test1.c
+++ b/storage/maria/ma_test1.c
@@ -25,7 +25,7 @@
#include "trnman.h"
extern PAGECACHE *maria_log_pagecache;
-extern char *maria_data_root;
+extern const char *maria_data_root;
#define MAX_REC_LENGTH 1024
@@ -75,7 +75,7 @@ int main(int argc,char *argv[])
safe_mutex_deadlock_detector= 1;
#endif
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
get_options(argc,argv);
/* Maria requires that we always have a page cache */
if (maria_init() ||
@@ -739,8 +739,8 @@ static struct my_option my_long_options[] =
{"debug", '#', "Undocumented",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
- {"datadir", 'h', "Path to the database root.", &maria_data_root,
- &maria_data_root, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+ {"datadir", 'h', "Path to the database root.", (char**) &maria_data_root,
+ (char**) &maria_data_root, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delete-rows", 'd', "Abort after this many rows has been deleted",
(uchar**) &remove_count, (uchar**) &remove_count, 0, GET_UINT, REQUIRED_ARG,
1000, 0, 0, 0, 0, 0},
@@ -813,7 +813,7 @@ static struct my_option my_long_options[] =
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/maria/ma_test2.c b/storage/maria/ma_test2.c
index 18ab2543bb0..6628465365f 100644
--- a/storage/maria/ma_test2.c
+++ b/storage/maria/ma_test2.c
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
#endif
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
get_options(argc,argv);
fn_format(filename, "test2", maria_data_root, "", MYF(0));
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index bf2cd5c6a92..e22b841dcaf 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -1238,7 +1238,7 @@ extern uchar maria_file_magic[], maria_pack_file_magic[];
extern uchar maria_uuid[MY_UUID_SIZE];
extern uint32 maria_read_vec[], maria_readnext_vec[];
extern uint maria_quick_table_bits;
-extern char *maria_data_root;
+extern const char *maria_data_root;
extern uchar maria_zero_string[];
extern my_bool maria_inited, maria_in_ha_maria, maria_recovery_changed_data;
extern my_bool maria_recovery_verbose, maria_checkpoint_disabled;
diff --git a/storage/maria/test_ma_backup.c b/storage/maria/test_ma_backup.c
index 3ffcd78b9af..b15b9ade06b 100644
--- a/storage/maria/test_ma_backup.c
+++ b/storage/maria/test_ma_backup.c
@@ -41,7 +41,7 @@ int main(int argc __attribute__((unused)), char *argv[])
safe_mutex_deadlock_detector= 1;
#endif
MY_INIT(argv[0]);
- maria_data_root= (char *)".";
+ maria_data_root= ".";
/* Maria requires that we always have a page cache */
if (maria_init() ||
diff --git a/storage/maria/unittest/ma_control_file-t.c b/storage/maria/unittest/ma_control_file-t.c
index 695181c9a6a..859d5514ffa 100644
--- a/storage/maria/unittest/ma_control_file-t.c
+++ b/storage/maria/unittest/ma_control_file-t.c
@@ -580,7 +580,7 @@ static void version(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
index d2fba562727..e8e114dd155 100644
--- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
+++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c
@@ -190,7 +190,7 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch (opt->id) {
diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c
index 92a9c65b232..5a614edb563 100644
--- a/storage/myisam/mi_test1.c
+++ b/storage/myisam/mi_test1.c
@@ -589,7 +589,7 @@ static struct my_option my_long_options[] =
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c
index 63f40daad5c..cc28d4a59e5 100644
--- a/storage/myisam/myisam_ftdump.c
+++ b/storage/myisam/myisam_ftdump.c
@@ -22,7 +22,8 @@
static void usage();
static void complain(int val);
-static my_bool get_one_option(const struct my_option *, char *, const char *);
+static my_bool get_one_option(const struct my_option *, const char *,
+ const char *);
static int count=0, stats=0, dump=0, lstats=0;
static my_bool verbose;
@@ -229,7 +230,7 @@ err:
static my_bool
get_one_option(const struct my_option *opt,
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
switch(opt->id) {
diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c
index 10d4987e1cb..b18f23dacb8 100644
--- a/storage/myisam/myisamchk.c
+++ b/storage/myisam/myisamchk.c
@@ -471,7 +471,7 @@ TYPELIB myisam_stats_method_typelib= {
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument, const char *filename __attribute__((unused)))
{
switch (opt->id) {
case 'a':
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index 1267ddc724d..f7626f93acf 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -317,7 +317,8 @@ static void usage(void)
static my_bool
get_one_option(const struct my_option *opt,
- char *argument, const char *filename __attribute__((unused)))
+ const char *argument,
+ const char *filename __attribute__((unused)))
{
uint length;
diff --git a/tests/async_queries.c b/tests/async_queries.c
index e1b7061eaa9..3f4a16da1e6 100644
--- a/tests/async_queries.c
+++ b/tests/async_queries.c
@@ -335,7 +335,7 @@ add_query(const char *q)
static my_bool
-handle_option(const struct my_option *opt, char *arg,
+handle_option(const struct my_option *opt, const char *arg,
const char *filename __attribute__((unused)))
{
switch (opt->id)
diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c
index bcf62eb0e18..d66ab814f4d 100644
--- a/tests/mysql_client_fw.c
+++ b/tests/mysql_client_fw.c
@@ -1272,7 +1272,7 @@ static struct my_tests_st *get_my_tests(); /* To be defined in main .c file */
static struct my_tests_st *my_testlist= 0;
static my_bool
-get_one_option(const struct my_option *opt, char *argument,
+get_one_option(const struct my_option *opt, const char *argument,
const char *filename __attribute__((unused)))
{
switch (opt->id) {
@@ -1285,10 +1285,15 @@ get_one_option(const struct my_option *opt, char *argument,
case 'p':
if (argument)
{
- char *start=argument;
+ /*
+ One should not really change the argument, but we make an
+ exception for passwords
+ */
+ char *start= (char*) argument;
my_free(opt_password);
opt_password= my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE));
- while (*argument) *argument++= 'x'; /* Destroy argument */
+ while (*argument)
+ *(char*) argument++= 'x'; /* Destroy argument */
if (*start)
start[1]=0;
}
diff --git a/unittest/mysys/my_getopt-t.c b/unittest/mysys/my_getopt-t.c
index fb0922b88f8..4b50468ac3f 100644
--- a/unittest/mysys/my_getopt-t.c
+++ b/unittest/mysys/my_getopt-t.c
@@ -61,7 +61,7 @@ static struct my_option mopts_options[]=
};
my_bool dummy_get_one_option(const struct my_option *opt __attribute__((unused)),
- char *argument __attribute__((unused)),
+ const char *argument __attribute__((unused)),
const char *filename __attribute__((unused)))
{
return FALSE;
@@ -235,7 +235,7 @@ static struct my_option auto_options[]=
my_bool auto_get_one_option(const struct my_option *opt,
- char *argument,
+ const char *argument,
const char *filename __attribute__((unused)))
{
if (argument == autoset_my_option)