diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-11 09:26:53 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-02-11 09:26:53 +0200 |
commit | b19ec8848c9463b86d62601dffb67c75e3dfbd70 (patch) | |
tree | 203f6bf23338813575214c23a8fee5a99f7ca2fb /client | |
parent | bfb4761ca04704d68dba51f76d7c9967f880a6ee (diff) | |
parent | c7edbe5bb1222634adb0c45ca86c62fb544ce246 (diff) | |
download | mariadb-git-b19ec8848c9463b86d62601dffb67c75e3dfbd70.tar.gz |
Merge 10.5 into 10.6
Diffstat (limited to 'client')
-rw-r--r-- | client/mariadb-conv.cc | 2 | ||||
-rw-r--r-- | client/mysql.cc | 16 | ||||
-rw-r--r-- | client/mysql_plugin.c | 3 | ||||
-rw-r--r-- | client/mysql_upgrade.c | 11 | ||||
-rw-r--r-- | client/mysqladmin.cc | 13 | ||||
-rw-r--r-- | client/mysqlbinlog.cc | 94 | ||||
-rw-r--r-- | client/mysqlcheck.c | 12 | ||||
-rw-r--r-- | client/mysqldump.c | 16 | ||||
-rw-r--r-- | client/mysqlimport.c | 11 | ||||
-rw-r--r-- | client/mysqlshow.c | 11 | ||||
-rw-r--r-- | client/mysqlslap.c | 11 | ||||
-rw-r--r-- | client/mysqltest.cc | 12 |
12 files changed, 141 insertions, 71 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 |