Commit 92e2b80c authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-186 Client programs throw warnings about memory loss when executed with --help or alike

suppress these harmless but confusing warnings.
fix the program name (MY_INIT) in mysqldump

client/mysqldump.c:
  for backward compatibility, prefix mysqldump error messages with "mysqldump", not with the full path of the executable
parent 02d982a9
...@@ -100,6 +100,7 @@ int main(int argc,char *argv[]) ...@@ -100,6 +100,7 @@ int main(int argc,char *argv[])
char operation[16]; char operation[16];
MY_INIT(argv[0]); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
plugin_data.name= 0; // initialize name plugin_data.name= 0; // initialize name
/* /*
......
...@@ -255,7 +255,7 @@ get_one_option(int optid, const struct my_option *opt, ...@@ -255,7 +255,7 @@ get_one_option(int optid, const struct my_option *opt,
puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010")); puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000, 2010"));
puts("MariaDB utility for upgrading databases to new MariaDB versions.\n"); puts("MariaDB utility for upgrading databases to new MariaDB versions.\n");
my_print_help(my_long_options); my_print_help(my_long_options);
exit(0); die(0);
break; break;
case '#': case '#':
......
...@@ -307,6 +307,7 @@ int main(int argc,char *argv[]) ...@@ -307,6 +307,7 @@ int main(int argc,char *argv[])
MY_INIT(argv[0]); MY_INIT(argv[0]);
mysql_init(&mysql); mysql_init(&mysql);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
if ((error= load_defaults("my",load_default_groups,&argc,&argv))) if ((error= load_defaults("my",load_default_groups,&argc,&argv)))
goto err1; goto err1;
save_argv = argv; /* Save for free_defaults */ save_argv = argv; /* Save for free_defaults */
...@@ -329,6 +330,8 @@ int main(int argc,char *argv[]) ...@@ -329,6 +330,8 @@ int main(int argc,char *argv[])
(void) signal(SIGINT,endprog); /* Here if abort */ (void) signal(SIGINT,endprog); /* Here if abort */
(void) signal(SIGTERM,endprog); /* Here if abort */ (void) signal(SIGTERM,endprog); /* Here if abort */
sf_leaking_memory=0; /* from now on we cleanup properly */
if (opt_compress) if (opt_compress)
mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&mysql,MYSQL_OPT_COMPRESS,NullS);
if (opt_connect_timeout) if (opt_connect_timeout)
......
...@@ -975,6 +975,7 @@ int main(int argc, char **argv) ...@@ -975,6 +975,7 @@ int main(int argc, char **argv)
char **defaults_argv; char **defaults_argv;
MY_INIT(argv[0]); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
/* /*
** Check out the args ** Check out the args
*/ */
...@@ -984,6 +985,7 @@ int main(int argc, char **argv) ...@@ -984,6 +985,7 @@ int main(int argc, char **argv)
defaults_argv= argv; defaults_argv= argv;
if (get_options(&argc, &argv)) if (get_options(&argc, &argv))
goto end1; goto end1;
sf_leaking_memory=0; /* from now on we cleanup properly */
ret= EX_MYSQLERR; ret= EX_MYSQLERR;
if (dbConnect(current_host, current_user, opt_password)) if (dbConnect(current_host, current_user, opt_password))
......
...@@ -590,17 +590,17 @@ void check_io(FILE *file) ...@@ -590,17 +590,17 @@ void check_io(FILE *file)
static void print_version(void) static void print_version(void)
{ {
printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname,DUMP_VERSION, printf("%s Ver %s Distrib %s, for %s (%s)\n",my_progname_short,DUMP_VERSION,
MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
} /* print_version */ } /* print_version */
static void short_usage_sub(void) static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS] database [tables]\n", my_progname); printf("Usage: %s [OPTIONS] database [tables]\n", my_progname_short);
printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n", printf("OR %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n",
my_progname); my_progname_short);
printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname); printf("OR %s [OPTIONS] --all-databases [OPTIONS]\n", my_progname_short);
} }
...@@ -620,7 +620,7 @@ static void usage(void) ...@@ -620,7 +620,7 @@ static void usage(void)
static void short_usage(void) static void short_usage(void)
{ {
short_usage_sub(); short_usage_sub();
printf("For more options, use %s --help\n", my_progname); printf("For more options, use %s --help\n", my_progname_short);
} }
...@@ -947,7 +947,7 @@ static int get_options(int *argc, char ***argv) ...@@ -947,7 +947,7 @@ static int get_options(int *argc, char ***argv)
fields_terminated)) fields_terminated))
{ {
fprintf(stderr, fprintf(stderr,
"%s: You must use option --tab with --fields-...\n", my_progname); "%s: You must use option --tab with --fields-...\n", my_progname_short);
return(EX_USAGE); return(EX_USAGE);
} }
...@@ -965,7 +965,7 @@ static int get_options(int *argc, char ***argv) ...@@ -965,7 +965,7 @@ static int get_options(int *argc, char ***argv)
if (opt_single_transaction && opt_lock_all_tables) if (opt_single_transaction && opt_lock_all_tables)
{ {
fprintf(stderr, "%s: You can't use --single-transaction and " fprintf(stderr, "%s: You can't use --single-transaction and "
"--lock-all-tables at the same time.\n", my_progname); "--lock-all-tables at the same time.\n", my_progname_short);
return(EX_USAGE); return(EX_USAGE);
} }
if (opt_master_data) if (opt_master_data)
...@@ -977,14 +977,14 @@ static int get_options(int *argc, char ***argv) ...@@ -977,14 +977,14 @@ static int get_options(int *argc, char ***argv)
lock_tables= 0; lock_tables= 0;
if (enclosed && opt_enclosed) if (enclosed && opt_enclosed)
{ {
fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname); fprintf(stderr, "%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n", my_progname_short);
return(EX_USAGE); return(EX_USAGE);
} }
if ((opt_databases || opt_alldbs) && path) if ((opt_databases || opt_alldbs) && path)
{ {
fprintf(stderr, fprintf(stderr,
"%s: --databases or --all-databases can't be used with --tab.\n", "%s: --databases or --all-databases can't be used with --tab.\n",
my_progname); my_progname_short);
return(EX_USAGE); return(EX_USAGE);
} }
if (strcmp(default_charset, charset_info->csname) && if (strcmp(default_charset, charset_info->csname) &&
...@@ -1036,7 +1036,7 @@ static void die(int error_num, const char* fmt_reason, ...) ...@@ -1036,7 +1036,7 @@ static void die(int error_num, const char* fmt_reason, ...)
my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args); my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
va_end(args); va_end(args);
fprintf(stderr, "%s: %s\n", my_progname, buffer); fprintf(stderr, "%s: %s\n", my_progname_short, buffer);
fflush(stderr); fflush(stderr);
ignore_errors= 0; /* force the exit */ ignore_errors= 0; /* force the exit */
...@@ -1070,7 +1070,7 @@ static void maybe_die(int error_num, const char* fmt_reason, ...) ...@@ -1070,7 +1070,7 @@ static void maybe_die(int error_num, const char* fmt_reason, ...)
my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args); my_vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
va_end(args); va_end(args);
fprintf(stderr, "%s: %s\n", my_progname, buffer); fprintf(stderr, "%s: %s\n", my_progname_short, buffer);
fflush(stderr); fflush(stderr);
maybe_exit(error_num); maybe_exit(error_num);
...@@ -2152,7 +2152,7 @@ static uint dump_events_for_db(char *db) ...@@ -2152,7 +2152,7 @@ static uint dump_events_for_db(char *db)
if (create_delimiter(row[3], delimiter, sizeof(delimiter)) == NULL) if (create_delimiter(row[3], delimiter, sizeof(delimiter)) == NULL)
{ {
fprintf(stderr, "%s: Warning: Can't create delimiter for event '%s'\n", fprintf(stderr, "%s: Warning: Can't create delimiter for event '%s'\n",
my_progname, event_name); my_progname_short, event_name);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -2766,7 +2766,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2766,7 +2766,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
else else
{ {
verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname, mysql_error(mysql)); my_progname_short, mysql_error(mysql));
my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table); my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
...@@ -2877,7 +2877,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ...@@ -2877,7 +2877,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
goto continue_xml; goto continue_xml;
} }
fprintf(stderr, "%s: Can't get keys for table %s (%s)\n", fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, result_table, mysql_error(mysql)); my_progname_short, result_table, mysql_error(mysql));
if (path) if (path)
my_fclose(sql_file, MYF(MY_WME)); my_fclose(sql_file, MYF(MY_WME));
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -3533,7 +3533,7 @@ static void dump_table(char *table, char *db) ...@@ -3533,7 +3533,7 @@ static void dump_table(char *table, char *db)
if (mysql_num_fields(res) != num_fields) if (mysql_num_fields(res) != num_fields)
{ {
fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n", fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n",
my_progname, result_table); my_progname_short, result_table);
error= EX_CONSCHECK; error= EX_CONSCHECK;
goto err; goto err;
} }
...@@ -3798,7 +3798,7 @@ static void dump_table(char *table, char *db) ...@@ -3798,7 +3798,7 @@ static void dump_table(char *table, char *db)
{ {
my_snprintf(buf, sizeof(buf), my_snprintf(buf, sizeof(buf),
"%s: Error %d: %s when dumping table %s at row: %ld\n", "%s: Error %d: %s when dumping table %s at row: %ld\n",
my_progname, my_progname_short,
mysql_errno(mysql), mysql_errno(mysql),
mysql_error(mysql), mysql_error(mysql),
result_table, result_table,
...@@ -3992,8 +3992,8 @@ static int dump_tablespaces(char* ts_where) ...@@ -3992,8 +3992,8 @@ static int dump_tablespaces(char* ts_where)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
my_printf_error(0, "Error: '%s' when trying to dump tablespaces", fprintf(stderr, "%s: Error: '%s' when trying to dump tablespaces\n",
MYF(0), mysql_error(mysql)); my_progname_short, mysql_error(mysql));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
...@@ -4138,8 +4138,8 @@ static int dump_all_databases() ...@@ -4138,8 +4138,8 @@ static int dump_all_databases()
if (mysql_query(mysql, "SHOW DATABASES") || if (mysql_query(mysql, "SHOW DATABASES") ||
!(tableres= mysql_store_result(mysql))) !(tableres= mysql_store_result(mysql)))
{ {
my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s", fprintf(stderr, "%s: Error: Couldn't execute 'SHOW DATABASES': %s\n",
MYF(0), mysql_error(mysql)); my_progname_short, mysql_error(mysql));
return 1; return 1;
} }
while ((row= mysql_fetch_row(tableres))) while ((row= mysql_fetch_row(tableres)))
...@@ -4666,8 +4666,8 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos) ...@@ -4666,8 +4666,8 @@ static int do_show_master_status(MYSQL *mysql_con, int consistent_binlog_pos)
if (!ignore_errors) if (!ignore_errors)
{ {
/* SHOW MASTER STATUS reports nothing and --force is not enabled */ /* SHOW MASTER STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Binlogging on server not active", fprintf(stderr, "%s: Error: Binlogging on server not active\n",
MYF(0)); my_progname_short);
maybe_exit(EX_MYSQLERR); maybe_exit(EX_MYSQLERR);
return 1; return 1;
} }
...@@ -4750,7 +4750,7 @@ static int do_show_slave_status(MYSQL *mysql_con) ...@@ -4750,7 +4750,7 @@ static int do_show_slave_status(MYSQL *mysql_con)
if (!ignore_errors) if (!ignore_errors)
{ {
/* SHOW SLAVE STATUS reports nothing and --force is not enabled */ /* SHOW SLAVE STATUS reports nothing and --force is not enabled */
my_printf_error(0, "Error: Slave not set up", MYF(0)); fprintf(stderr, "%s: Error: Slave not set up\n", my_progname_short);
} }
mysql_free_result(slave); mysql_free_result(slave);
return 1; return 1;
...@@ -4810,7 +4810,7 @@ static int do_start_slave_sql(MYSQL *mysql_con) ...@@ -4810,7 +4810,7 @@ static int do_start_slave_sql(MYSQL *mysql_con)
/* now, start slave if stopped */ /* now, start slave if stopped */
if (mysql_query_with_error_report(mysql_con, 0, "START SLAVE")) if (mysql_query_with_error_report(mysql_con, 0, "START SLAVE"))
{ {
my_printf_error(0, "Error: Unable to start slave", MYF(0)); fprintf(stderr, "%s: Error: Unable to start slave\n", my_progname_short);
return 1; return 1;
} }
return(0); return(0);
...@@ -5452,8 +5452,9 @@ int main(int argc, char **argv) ...@@ -5452,8 +5452,9 @@ int main(int argc, char **argv)
char bin_log_name[FN_REFLEN]; char bin_log_name[FN_REFLEN];
int exit_code; int exit_code;
int consistent_binlog_pos= 0; int consistent_binlog_pos= 0;
MY_INIT("mysqldump"); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
compatible_mode_normal_str[0]= 0; compatible_mode_normal_str[0]= 0;
default_charset= (char *)mysql_universal_client_charset; default_charset= (char *)mysql_universal_client_charset;
bzero((char*) &ignore_table, sizeof(ignore_table)); bzero((char*) &ignore_table, sizeof(ignore_table));
...@@ -5464,6 +5465,7 @@ int main(int argc, char **argv) ...@@ -5464,6 +5465,7 @@ int main(int argc, char **argv)
free_resources(); free_resources();
exit(exit_code); exit(exit_code);
} }
sf_leaking_memory=0; /* from now on we cleanup properly */
/* /*
Disable comments in xml mode if 'comments' option is not explicitly used. Disable comments in xml mode if 'comments' option is not explicitly used.
......
...@@ -613,6 +613,7 @@ int main(int argc, char **argv) ...@@ -613,6 +613,7 @@ int main(int argc, char **argv)
{ {
int error=0; int error=0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
if (load_defaults("my",load_default_groups,&argc,&argv)) if (load_defaults("my",load_default_groups,&argc,&argv))
return 1; return 1;
...@@ -623,6 +624,7 @@ int main(int argc, char **argv) ...@@ -623,6 +624,7 @@ int main(int argc, char **argv)
free_defaults(argv_to_free); free_defaults(argv_to_free);
return(1); return(1);
} }
sf_leaking_memory=0; /* from now on we cleanup properly */
#ifdef HAVE_LIBPTHREAD #ifdef HAVE_LIBPTHREAD
if (opt_use_threads && !lock_tables) if (opt_use_threads && !lock_tables)
......
...@@ -67,11 +67,13 @@ int main(int argc, char **argv) ...@@ -67,11 +67,13 @@ int main(int argc, char **argv)
char *wild; char *wild;
MYSQL mysql; MYSQL mysql;
MY_INIT(argv[0]); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
if (load_defaults("my",load_default_groups,&argc,&argv)) if (load_defaults("my",load_default_groups,&argc,&argv))
exit(1); exit(1);
get_options(&argc,&argv); get_options(&argc,&argv);
sf_leaking_memory=0; /* from now on we cleanup properly */
wild=0; wild=0;
if (argc) if (argc)
{ {
......
...@@ -317,6 +317,7 @@ int main(int argc, char **argv) ...@@ -317,6 +317,7 @@ int main(int argc, char **argv)
option_string *eptr; option_string *eptr;
MY_INIT(argv[0]); MY_INIT(argv[0]);
sf_leaking_memory=1; /* don't report memory leaks on early exits */
if (load_defaults("my",load_default_groups,&argc,&argv)) if (load_defaults("my",load_default_groups,&argc,&argv))
{ {
...@@ -330,6 +331,7 @@ int main(int argc, char **argv) ...@@ -330,6 +331,7 @@ int main(int argc, char **argv)
my_end(0); my_end(0);
exit(1); exit(1);
} }
sf_leaking_memory=0; /* from now on we cleanup properly */
/* Seed the random number generator if we will be using it. */ /* Seed the random number generator if we will be using it. */
if (auto_generate_sql) if (auto_generate_sql)
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
--source include/not_embedded.inc --source include/not_embedded.inc
--replace_regex /MASTER_LOG_POS=[0-9]+/XX/ --replace_regex /MASTER_LOG_POS=[0-9]+/XX/
--replace_result mysqldump.exe mysqldump
--error 2 --error 2
--exec $MYSQL_DUMP --compact --master-data=2 test 2>&1 --exec $MYSQL_DUMP --compact --master-data=2 test 2>&1
This diff is collapsed.
...@@ -197,7 +197,7 @@ INSERT INTO t1 VALUES (1), (2); ...@@ -197,7 +197,7 @@ INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test --exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test
# With wrong parameters # With wrong parameters
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR mysqldump.exe mysqldump
--error 2 --error 2
--exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1 --exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment