summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-02-05 14:57:46 +0200
committerMonty <monty@mariadb.org>2021-02-08 12:16:29 +0200
commit5d6ad2ad66a677b67f2377d7665d6c140dd93323 (patch)
tree85a54b1a982beb401f04d5bcb621a1166b33b653
parente30a3048dacca5180e8d7b2934d0b1fe44b4f383 (diff)
downloadmariadb-git-5d6ad2ad66a677b67f2377d7665d6c140dd93323.tar.gz
Added 'const' to arguments in get_one_option and find_typeset()
One should not change the program arguments! This change also reduces warnings from the icc compiler. Almost all changes are just syntax changes (adding const to 'get_one_option function' declarations). Other changes: - Added a few cast of 'argument' from 'const char*' to 'char *'. This was mainly in calls to 'external' functions we don't have control of. - Ensure that all reset of 'password command line argument' are similar. (In almost all cases it was just adding a comment and a cast) - In mysqlbinlog.cc and mysqld.cc there was a few cases that changed the command line argument. These places where changed to instead allocate the option in a MEM_ROOT to avoid changing the argument. Some of this code was changed to ensure that different programs did parsing the same way. Added a test case for the changes in mysqlbinlog.cc - Changed a few variables that took their value from command line options from 'char *' to 'const char *'.
-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.cc57
-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/typelib.h3
-rw-r--r--mysql-test/main/mysqlbinlog.result18
-rw-r--r--mysql-test/main/mysqlbinlog.test28
-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_plugin.cc6
-rw-r--r--sql/sql_show.cc3
-rw-r--r--sql/sql_show.h2
-rw-r--r--sql/tztime.cc5
-rw-r--r--storage/maria/aria_chk.c3
-rw-r--r--storage/maria/aria_dump_log.c2
-rw-r--r--storage/maria/aria_ftdump.c5
-rw-r--r--storage/maria/aria_pack.c3
-rw-r--r--storage/maria/aria_read_log.c3
-rw-r--r--storage/maria/aria_s3_copy.cc2
-rw-r--r--storage/maria/ma_rt_test.c2
-rw-r--r--storage/maria/ma_test1.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
53 files changed, 296 insertions, 161 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 02bff7c294c..fd31ab6694e 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -96,6 +96,7 @@ 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";
@@ -1889,6 +1890,7 @@ 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;
@@ -1957,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) {
@@ -1981,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 */
}
@@ -2035,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;
@@ -3045,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");
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 417d3615995..13282153cfb 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -97,7 +97,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 {
@@ -7141,7 +7142,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 '#':
@@ -7189,9 +7190,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 b8cdf4cd9db..495c7d7e2fe 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -311,7 +311,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;
@@ -1861,7 +1861,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':
@@ -6348,9 +6348,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 4e6240a19ac..d3ee7c3996f 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/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/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/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 651eea33304..35e24a521e4 100644
--- a/sql/mysql_install_db.cc
+++ b/sql/mysql_install_db.cc
@@ -96,7 +96,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 c59fd970dff..b751d15a907 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -329,7 +329,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;
@@ -372,6 +372,8 @@ uint volatile global_disable_checkpoint;
#if defined(_WIN32) && !defined(EMBEDDED_LIBRARY)
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
@@ -1484,7 +1486,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 */
@@ -3591,6 +3595,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;
}
@@ -7890,7 +7895,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)
@@ -8067,31 +8072,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;
@@ -8118,7 +8135,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;
@@ -8127,7 +8144,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;
@@ -8136,7 +8153,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;
@@ -8145,7 +8162,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;
@@ -8239,10 +8256,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 "
@@ -8251,54 +8272,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 */
@@ -8465,7 +8475,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_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..ae65cceb1fb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -618,8 +618,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..3335daa5daf 100644
--- a/storage/maria/aria_chk.c
+++ b/storage/maria/aria_chk.c
@@ -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..2e42fd82352 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) {
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..ae067354abc 100644
--- a/storage/maria/aria_pack.c
+++ b/storage/maria/aria_pack.c
@@ -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..62b0ac6aacd 100644
--- a/storage/maria/aria_read_log.c
+++ b/storage/maria/aria_read_log.c
@@ -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/ma_rt_test.c b/storage/maria/ma_rt_test.c
index 12f35af7cc1..7fe0ac5cd13 100644
--- a/storage/maria/ma_rt_test.c
+++ b/storage/maria/ma_rt_test.c
@@ -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_test1.c b/storage/maria/ma_test1.c
index bbdb08257e1..8820e473123 100644
--- a/storage/maria/ma_test1.c
+++ b/storage/maria/ma_test1.c
@@ -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/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 aea0562672c..1e60956c297 100644
--- a/tests/mysql_client_fw.c
+++ b/tests/mysql_client_fw.c
@@ -1273,7 +1273,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) {
@@ -1286,10 +1286,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)