diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 5db9aa0b5847d..b75ae31e70c51 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -776,6 +776,26 @@ static MYSQL_SYSVAR_ENUM(log_level, mrn_log_level, static_cast(mrn_log_level), &mrn_log_level_typelib); +static int mrn_log_file_check(THD *thd, struct st_mysql_sys_var *var, + void *save, struct st_mysql_value *value) +{ + MRN_DBUG_ENTER_FUNCTION(); + + int len; + const char *new_value= value->val_str(value, NULL, &len); + + if (!new_value || len == 0) + { + my_printf_error(ER_MRN_INVALID_NULL_VALUE_NUM, + ER_MRN_INVALID_NULL_VALUE_STR, MYF(0), + "mroonga_log_file"); + DBUG_RETURN(1); + } + + *((const char **) save)= new_value; + + DBUG_RETURN(0); +} static void mrn_log_file_update(THD *thd, struct st_mysql_sys_var *var, void *var_ptr, const void *save) { @@ -848,7 +868,7 @@ static void mrn_log_file_update(THD *thd, struct st_mysql_sys_var *var, static MYSQL_SYSVAR_STR(log_file, mrn_log_file_path, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC, "log file for " MRN_PLUGIN_NAME_STRING, - NULL, + mrn_log_file_check, mrn_log_file_update, MRN_LOG_FILE_PATH); diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/variable_log_file_reject_null.result b/storage/mroonga/mysql-test/mroonga/storage/r/variable_log_file_reject_null.result new file mode 100644 index 0000000000000..c44462e7ac959 --- /dev/null +++ b/storage/mroonga/mysql-test/mroonga/storage/r/variable_log_file_reject_null.result @@ -0,0 +1,7 @@ +SET GLOBAL mroonga_log_file = NULL; +ERROR HY000: NULL value can't be used for mroonga_log_file +SET GLOBAL mroonga_log_file = ''; +ERROR HY000: NULL value can't be used for mroonga_log_file +SHOW GLOBAL VARIABLES LIKE 'mroonga_log_file'; +Variable_name Value +mroonga_log_file groonga.log diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/variable_log_file_reject_null.test b/storage/mroonga/mysql-test/mroonga/storage/t/variable_log_file_reject_null.test new file mode 100644 index 0000000000000..f6c53f1e682da --- /dev/null +++ b/storage/mroonga/mysql-test/mroonga/storage/t/variable_log_file_reject_null.test @@ -0,0 +1,30 @@ +# -*- mode: sql; sql-product: mysql -*- +# +# Copyright (C) 2026 hadeer +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +--source ../../include/mroonga/have_mroonga.inc +--source include/not_embedded.inc + +--error 16505 +SET GLOBAL mroonga_log_file = NULL; + +--error 16505 +SET GLOBAL mroonga_log_file = ''; + +SHOW GLOBAL VARIABLES LIKE 'mroonga_log_file'; + +--source ../../include/mroonga/have_mroonga_deinit.inc