From b0ba04a800ddc08d88e918ef597ffbe2d5efe832 Mon Sep 17 00:00:00 2001 From: Anirudh Mangipudi Date: Mon, 18 Feb 2013 19:13:06 +0530 Subject: [PATCH] Bug #12546953 "SHOW VARIABLES LIKE 'DATADIR';" RETURN EMPTY. Problem: =========================================================== If mysqld daemon is started without a --datadir option option, and we issue the SHOW VARIABLES LIKE 'DATADIR';SQL command at the client it returns an empty path. This is because mysql_real_data_home_ptr is being reset to NULL by Sys_var_charptr constructor call when the datadir is not given either through configuration file (no-defaults) or through mysqld parameters. Solution: =========================================================== mysql_real_data_home is an array which stores the path of the datadir and mysql_real_data_home_ptr is the pointer to it. The pointer is being set to NULL at the Sys_datadir, which is of type Sys_var_charptr, constructor call. This is because at Sys_datadir call the def_val parameter was being passed with DEFAULT(0) which is now replaced with DEFAULT(mysql_real_data_home). The patch has been tested manually as it is not possible to start mtr without a default config file. --- sql/sys_vars.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9e79cdcb6f3..2430a54ffd7 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -659,7 +659,7 @@ static Sys_var_ulong Sys_connect_timeout( static Sys_var_charptr Sys_datadir( "datadir", "Path to the database root directory", READ_ONLY GLOBAL_VAR(mysql_real_data_home_ptr), - CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(0)); + CMD_LINE(REQUIRED_ARG, 'h'), IN_FS_CHARSET, DEFAULT(mysql_real_data_home)); #ifndef DBUG_OFF static Sys_var_dbug Sys_dbug(