Commit 8d524243 authored by 's avatar

Bug #34739 unexpected binlog file name when --log-bin is set to a directory name

If --log-bin is set to a directory name with the trailing 'FN_LIBCHAR', 
which will be '/' on Unix like systems, and '\\' on Windows like systems. 
the basename of the binlog is empty so that the created files named 
'.000001' and '.index'. It is not expected. 
The same thing happened to --log-bin-index, --relay-log and 
--relay-log-index options.

To resolve the problem, in these cases the program should report an error 
and abort.
parent 2b87e80a
...@@ -3888,6 +3888,27 @@ server."); ...@@ -3888,6 +3888,27 @@ server.");
if (opt_bin_log) if (opt_bin_log)
{ {
/* Reports an error and aborts, if the --log-bin's path
is a directory.*/
if (opt_bin_logname &&
opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR)
{
sql_print_error("Path '%s' is a directory name, please specify \
a file name for --log-bin option", opt_bin_logname);
unireg_abort(1);
}
/* Reports an error and aborts, if the --log-bin-index's path
is a directory.*/
if (opt_binlog_index_name &&
opt_binlog_index_name[strlen(opt_binlog_index_name) - 1]
== FN_LIBCHAR)
{
sql_print_error("Path '%s' is a directory name, please specify \
a file name for --log-bin-index option", opt_binlog_index_name);
unireg_abort(1);
}
char buf[FN_REFLEN]; char buf[FN_REFLEN];
const char *ln; const char *ln;
ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf); ln= mysql_bin_log.generate_name(opt_bin_logname, "-bin", 1, buf);
......
...@@ -132,6 +132,29 @@ int init_relay_log_info(Relay_log_info* rli, ...@@ -132,6 +132,29 @@ int init_relay_log_info(Relay_log_info* rli,
rli->relay_log.max_size (and mysql_bin_log.max_size). rli->relay_log.max_size (and mysql_bin_log.max_size).
*/ */
{ {
/* Reports an error and returns, if the --relay-log's path
is a directory.*/
if (opt_relay_logname &&
opt_relay_logname[strlen(opt_relay_logname) - 1] == FN_LIBCHAR)
{
pthread_mutex_unlock(&rli->data_lock);
sql_print_error("Path '%s' is a directory name, please specify \
a file name for --relay-log option", opt_relay_logname);
DBUG_RETURN(1);
}
/* Reports an error and returns, if the --relay-log-index's path
is a directory.*/
if (opt_relaylog_index_name &&
opt_relaylog_index_name[strlen(opt_relaylog_index_name) - 1]
== FN_LIBCHAR)
{
pthread_mutex_unlock(&rli->data_lock);
sql_print_error("Path '%s' is a directory name, please specify \
a file name for --relay-log-index option", opt_relaylog_index_name);
DBUG_RETURN(1);
}
char buf[FN_REFLEN]; char buf[FN_REFLEN];
const char *ln; const char *ln;
static bool name_warning_sent= 0; static bool name_warning_sent= 0;
......
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