@@ -109,7 +109,8 @@ static char *opt_password=0,*current_user=0,
109109 * lines_terminated = 0 , * enclosed = 0 , * opt_enclosed = 0 , * escaped = 0 ,
110110 * where = 0 , * order_by = 0 ,
111111 * opt_compatible_mode_str = 0 ,
112- * err_ptr = 0 ;
112+ * err_ptr = 0 ,
113+ * log_error_file = NULL ;
113114static char * * defaults_argv = 0 ;
114115static char compatible_mode_normal_str [255 ];
115116static ulong opt_compatible_mode = 0 ;
@@ -120,7 +121,9 @@ static my_string opt_mysql_unix_port=0;
120121static int first_error = 0 ;
121122static DYNAMIC_STRING extended_row ;
122123#include <sslopt-vars.h>
123- FILE * md_result_file = 0 ;
124+ FILE * md_result_file = 0 ;
125+ FILE * stderror_file = 0 ;
126+
124127#ifdef HAVE_SMEM
125128static char * shared_memory_base_name = 0 ;
126129#endif
@@ -320,6 +323,9 @@ static struct my_option my_long_options[] =
320323 0 , 0 , 0 , 0 , 0 , 0 },
321324 {"lock-tables" , 'l' , "Lock all tables for read." , (gptr * ) & lock_tables ,
322325 (gptr * ) & lock_tables , 0 , GET_BOOL , NO_ARG , 1 , 0 , 0 , 0 , 0 , 0 },
326+ {"log-error" , OPT_ERROR_LOG_FILE , "Append warnings and errors to given file." ,
327+ (gptr * ) & log_error_file , (gptr * ) & log_error_file , 0 , GET_STR ,
328+ REQUIRED_ARG , 0 , 0 , 0 , 0 , 0 , 0 },
323329 {"master-data" , OPT_MASTER_DATA ,
324330 "This causes the binary log position and filename to be appended to the "
325331 "output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
@@ -801,14 +807,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
801807 break ;
802808 }
803809 case (int ) OPT_MYSQL_PROTOCOL :
804- {
805- if ((opt_protocol = find_type (argument , & sql_protocol_typelib ,0 )) <= 0 )
806- {
807- fprintf (stderr , "Unknown option to protocol: %s\n" , argument );
808- exit (1 );
809- }
810- break ;
811- }
810+ opt_protocol = find_type_or_exit (argument , & sql_protocol_typelib ,
811+ opt -> name );
812+ break ;
812813 }
813814 return 0 ;
814815}
@@ -4210,6 +4211,16 @@ int main(int argc, char **argv)
42104211 free_resources (0 );
42114212 exit (exit_code );
42124213 }
4214+
4215+ if (log_error_file )
4216+ {
4217+ if (!(stderror_file = freopen (log_error_file , "a+" , stderr )))
4218+ {
4219+ free_resources (0 );
4220+ exit (EX_MYSQLERR );
4221+ }
4222+ }
4223+
42134224 if (connect_to_db (current_host , current_user , opt_password ))
42144225 {
42154226 free_resources (0 );
@@ -4273,5 +4284,9 @@ int main(int argc, char **argv)
42734284 if (!path )
42744285 write_footer (md_result_file );
42754286 free_resources ();
4287+
4288+ if (stderror_file )
4289+ fclose (stderror_file );
4290+
42764291 return (first_error );
42774292} /* main */
0 commit comments