Commit ebb0b02c authored by Magne Mahre's avatar Magne Mahre

Bug #38124 "general_log_file" variable silently unset when using expression

                  
When assigning the new string value to the variable, the
Item::str_value member was used.  This is not according to
the protocol.  str_value is an internal member used for
temporary assignments, and is not consistently set for all
string operations.  It is set for constant strings, so it would
work in these cases, but not for string functions (concat,
substr, etc.)
                  
The correct approach is to use Item::val_str(..) to evaluate
and retrieve the string.

Backport from 6.0-codebase

6.0-codebase revno: 2617.31.17
parent 64dbe379
......@@ -309,6 +309,30 @@ SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
End of 5.1 tests
# --
# -- Bug#38124: "general_log_file" variable silently unset when
# -- using expression
# --
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file INTO @my_glf;
SET GLOBAL general_log_file = 'BUG38124.LOG';
SELECT @@general_log_file;
@@general_log_file
BUG38124.LOG
SET GLOBAL general_log_file = concat('BUG38124-2.LOG');
SELECT @@general_log_file;
@@general_log_file
BUG38124-2.LOG
SET GLOBAL general_log_file = substr('BUG38124-2.LOG',3,6);
SELECT @@general_log_file;
@@general_log_file
G38124
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file = @my_glf;
@@general_log_file = @my_glf
1
SET GLOBAL general_log_file = @old_general_log_file;
# Close connection con1
SET global general_log = @old_general_log;
SET global general_log_file = @old_general_log_file;
......
### t/log_state.test ###
#
# This test suffers from server
# Bug#38124 "general_log_file" variable silently unset when using expression
# In short:
# SET GLOBAL general_log_file = @<whatever>
# SET GLOBAL slow_query_log = @<whatever>
# cause that the value of these server system variables is set to default
# instead of the assigned values. There comes no error message or warning.
# If this bug is fixed please
# 1. try this test with "let $fixed_bug38124 = 0;"
# 2. remove all workarounds if 1. was successful.
let $fixed_bug38124 = 0;
--source include/not_embedded.inc
--source include/have_csv.inc
......@@ -166,16 +155,6 @@ SET @@global.general_log = @old_general_log;
SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
if(!$fixed_bug38124)
{
--disable_query_log
let $my_var = `SELECT @old_general_log_file`;
eval SET @@global.general_log_file = '$my_var';
let $my_var = `SELECT @old_slow_query_log_file`;
eval SET @@global.slow_query_log_file = '$my_var';
--enable_query_log
}
###########################################################################
......@@ -278,15 +257,6 @@ SET GLOBAL slow_query_log_file= NULL;
# Reset to initial values in case a setting above was successful.
SET GLOBAL general_log_file= @old_general_log_file;
SET GLOBAL slow_query_log_file= @old_slow_query_log_file;
if(!$fixed_bug38124)
{
--disable_query_log
let $my_var = `SELECT @old_general_log_file`;
eval SET @@global.general_log_file = '$my_var';
let $my_var = `SELECT @old_slow_query_log_file`;
eval SET @@global.slow_query_log_file = '$my_var';
--enable_query_log
}
###########################################################################
......@@ -307,15 +277,6 @@ SHOW VARIABLES LIKE '%log_file';
--echo
SET GLOBAL general_log_file = @old_general_log_file;
SET GLOBAL slow_query_log_file = @old_slow_query_log_file;
if(!$fixed_bug38124)
{
--disable_query_log
let $my_var = `SELECT @old_general_log_file`;
eval SET @@global.general_log_file = '$my_var';
let $my_var = `SELECT @old_slow_query_log_file`;
eval SET @@global.slow_query_log_file = '$my_var';
--enable_query_log
}
--echo
--echo # -- End of Bug#32748.
......@@ -351,19 +312,43 @@ SET @@global.general_log = @old_general_log;
SET @@global.general_log_file = @old_general_log_file;
SET @@global.slow_query_log = @old_slow_query_log;
SET @@global.slow_query_log_file = @old_slow_query_log_file;
if(!$fixed_bug38124)
{
--disable_query_log
let $my_var = `SELECT @old_general_log_file`;
eval SET @@global.general_log_file = '$my_var';
let $my_var = `SELECT @old_slow_query_log_file`;
eval SET @@global.slow_query_log_file = '$my_var';
--enable_query_log
}
--echo End of 5.1 tests
###########################################################################
--echo
--echo # --
--echo # -- Bug#38124: "general_log_file" variable silently unset when
--echo # -- using expression
--echo # --
# Store away the special DEFAULT value so we
# can compare it later, then try to set the
# general_log_file using different functions
# and expressions.
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file INTO @my_glf;
SET GLOBAL general_log_file = 'BUG38124.LOG';
SELECT @@general_log_file;
SET GLOBAL general_log_file = concat('BUG38124-2.LOG');
SELECT @@general_log_file;
SET GLOBAL general_log_file = substr('BUG38124-2.LOG',3,6);
SELECT @@general_log_file;
SET GLOBAL general_log_file = DEFAULT;
SELECT @@general_log_file = @my_glf;
## Reset to initial values
SET GLOBAL general_log_file = @old_general_log_file;
--enable_ps_protocol
#
......@@ -380,15 +365,6 @@ SET global general_log = @old_general_log;
SET global general_log_file = @old_general_log_file;
SET global slow_query_log = @old_slow_query_log;
SET global slow_query_log_file = @old_slow_query_log_file;
if(!$fixed_bug38124)
{
--disable_query_log
let $my_var = `SELECT @old_general_log_file`;
eval SET @@global.general_log_file = '$my_var';
let $my_var = `SELECT @old_slow_query_log_file`;
eval SET @@global.slow_query_log_file = '$my_var';
--enable_query_log
}
# Remove the log file that was created in the "default location"
# i.e var/run
......
......@@ -2535,9 +2535,20 @@ bool update_sys_var_str_path(THD *thd, sys_var_str *var_str,
{
MYSQL_QUERY_LOG *file_log;
char buff[FN_REFLEN];
char *res= 0, *old_value=(char *)(var ? var->value->str_value.ptr() : 0);
char *res= 0, *old_value= 0;
bool result= 0;
uint str_length= (var ? var->value->str_value.length() : 0);
uint str_length= 0;
if (var)
{
String str(buff, sizeof(buff), system_charset_info), *newval;
newval= var->value->val_str(&str);
old_value= newval->c_ptr();
str_length= strlen(old_value);
}
switch (log_type) {
case QUERY_LOG_SLOW:
......
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