1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-9969 mysql_install_db error processing ignore_db_dirs.

Check for same directories in the list added.
This commit is contained in:
Alexey Botchkov
2016-06-16 12:35:14 +04:00
parent 732e269405
commit 0e50b92482
3 changed files with 32 additions and 5 deletions

View File

@ -5,4 +5,5 @@ Test non-numeric value passed to number option.
Test that bad value for plugin enum option is rejected correctly. Test that bad value for plugin enum option is rejected correctly.
Test that --help --verbose works Test that --help --verbose works
Test that --not-known-option --help --verbose gives error Test that --not-known-option --help --verbose gives error
Test that specifying same directory several times handled properly.
Done. Done.

View File

@ -56,4 +56,12 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--error 2 --error 2
--exec $MYSQLD_BOOTSTRAP_CMD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 --exec $MYSQLD_BOOTSTRAP_CMD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
#
# MDEV-9969 mysql_install_db error processing ignore_db_dirs.
#
--echo Test that specifying same directory several times handled properly.
--exec echo "" | $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--echo Done. --echo Done.

View File

@ -720,12 +720,24 @@ ignore_db_dirs_process_additions()
for (i= 0; i < ignore_db_dirs_array.elements; i++) for (i= 0; i < ignore_db_dirs_array.elements; i++)
{ {
get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i); get_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
if (my_hash_insert(&ignore_db_dirs_hash, (uchar *) dir)) if (my_hash_insert(&ignore_db_dirs_hash, (uchar *)dir))
return true; {
ptr= strnmov(ptr, dir->str, dir->length); /* ignore duplicates from the config file */
if (i + 1 < ignore_db_dirs_array.elements) if (my_hash_search(&ignore_db_dirs_hash, (uchar *)dir->str, dir->length))
ptr= strmov(ptr, ","); {
sql_print_warning("Duplicate ignore-db-dir directory name '%.*s' "
"found in the config file(s). Ignoring the duplicate.",
(int) dir->length, dir->str);
my_free(dir);
goto continue_loop;
}
return true;
}
ptr= strnmov(ptr, dir->str, dir->length);
*(ptr++)= ',';
continue_loop:
/* /*
Set the transferred array element to NULL to avoid double free Set the transferred array element to NULL to avoid double free
in case of error. in case of error.
@ -734,6 +746,12 @@ ignore_db_dirs_process_additions()
set_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i); set_dynamic(&ignore_db_dirs_array, (uchar *) &dir, i);
} }
if (ptr > opt_ignore_db_dirs)
{
ptr--;
DBUG_ASSERT(*ptr == ',');
}
/* make sure the string is terminated */ /* make sure the string is terminated */
DBUG_ASSERT(ptr - opt_ignore_db_dirs <= (ptrdiff_t) len); DBUG_ASSERT(ptr - opt_ignore_db_dirs <= (ptrdiff_t) len);
*ptr= 0; *ptr= 0;