Skip to content

Commit 19ee77e

Browse files
committed
Bug #22107047: "MYSQLD --HELP --VERBOSE" CREATES A FILE IN THE DATA DIRECTORY
This patch makes the server skip opening the binlog index file if starting with --help. Without this patch, with an empty data directory, the binlog index file will be created and left in the data directory. If we then do 'mysqld --initialize' on the same data directory, it will fail.
1 parent 41ad148 commit 19ee77e

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

mysql-test/r/help_verbose.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ Pattern "\[ERROR\]" not found
55
# There should be no leftovers in the datadir.
66
# There should be no errors
77
Pattern "\[ERROR\]" not found
8+
# There should be no errors
9+
Pattern "\[ERROR\]" not found
10+
# There should be no leftovers in the datadir.

mysql-test/t/help_verbose.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,29 @@
7272
# Cleanup
7373
--remove_files_wildcard $BUGDIR *
7474
--rmdir $BUGDIR
75+
76+
###########################################################################
77+
# 4. Run --help --verbose and --log-bin on an existing but empty datadir.
78+
###########################################################################
79+
80+
--let $BUGDIR= $MYSQL_TMP_DIR/help_verbose_tc4
81+
--let $LOG_FILE = $BUGDIR/mysqld.log
82+
--let $TEST_DATADIR= $BUGDIR/data
83+
84+
--mkdir $BUGDIR
85+
--mkdir $TEST_DATADIR
86+
87+
--exec $MYSQLD --no-defaults --help --verbose --log-bin --server-id=1 --datadir=$TEST_DATADIR --lc-messages-dir=$MESSAGES_DIR --secure-file-priv="" > $LOG_FILE 2>&1
88+
89+
--echo # There should be no errors
90+
--let SEARCH_FILE= $LOG_FILE
91+
--let SEARCH_PATTERN= \[ERROR\]
92+
--source include/search_pattern.inc
93+
94+
--echo # There should be no leftovers in the datadir.
95+
--list_files $TEST_DATADIR
96+
97+
# Cleanup
98+
--remove_files_wildcard $BUGDIR *
99+
--rmdir $TEST_DATADIR
100+
--rmdir $BUGDIR

sql/mysqld.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3857,7 +3857,13 @@ a file name for --log-bin-index option", opt_binlog_index_name);
38573857
opt_bin_logname=my_strdup(key_memory_opt_bin_logname,
38583858
buf, MYF(0));
38593859
}
3860-
if (mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE))
3860+
3861+
/*
3862+
Skip opening the index file if we start with --help. This is necessary
3863+
to avoid creating the file in an otherwise empty datadir, which will
3864+
cause a succeeding 'mysqld --initialize' to fail.
3865+
*/
3866+
if (!opt_help && mysql_bin_log.open_index_file(opt_binlog_index_name, ln, TRUE))
38613867
{
38623868
unireg_abort(MYSQLD_ABORT_EXIT);
38633869
}

0 commit comments

Comments
 (0)