Commit af0c56ce authored by Alexander Barkov's avatar Alexander Barkov

MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c

on server shutdown after SELECT with CONVERT_TZ

It's wrong to return my_empty_string from val_str().
Removing my_empty_string. Using make_empty_result() instead.
parent 46c98a8f
......@@ -24,6 +24,8 @@ SET date_format='%Y%m%d';
SET date_format='%Y.%m.%d';
SET date_format='%d.%m.%Y';
SET date_format='%m-%d-%Y';
SET datetime_format= NULL;
ERROR 42000: Variable 'datetime_format' can't be set to the value of 'NULL'
set datetime_format= '%Y%m%d%H%i%s';
set datetime_format= '%Y-%m-%d %H:%i:%s';
set datetime_format= '%m-%d-%y %H:%i:%s.%f';
......
......@@ -326,5 +326,11 @@ NULL
Warnings:
Warning 1292 Incorrect datetime value: '00:00:00'
#
# MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c on server shutdown after SELECT with CONVERT_TZ
#
SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' );
CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' )
NULL
#
# End of 5.3 tests
#
......@@ -32,6 +32,8 @@ SET date_format='%Y.%m.%d';
SET date_format='%d.%m.%Y';
SET date_format='%m-%d-%Y';
--error ER_WRONG_VALUE_FOR_VAR
SET datetime_format= NULL;
set datetime_format= '%Y%m%d%H%i%s';
set datetime_format= '%Y-%m-%d %H:%i:%s';
set datetime_format= '%m-%d-%y %H:%i:%s.%f';
......
......@@ -297,6 +297,12 @@ DROP TABLE t1;
SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
--echo #
--echo # MDEV-5506 safe_mutex: Trying to lock unitialized mutex at safemalloc.c on server shutdown after SELECT with CONVERT_TZ
--echo #
SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' );
--echo #
--echo # End of 5.3 tests
--echo #
......@@ -40,11 +40,6 @@ C_MODE_START
#include "../mysys/my_static.h" // For soundex_map
C_MODE_END
/**
@todo Remove this. It is not safe to use a shared String object.
*/
String my_empty_string("",default_charset_info);
/*
Convert an array of bytes to a hexadecimal representation.
......@@ -2250,7 +2245,7 @@ String *Item_func_make_set::val_str(String *str)
ulonglong bits;
bool first_found=0;
Item **ptr=args+1;
String *result=&my_empty_string;
String *result= make_empty_result();
bits=args[0]->val_int();
if ((null_value=args[0]->null_value))
......
......@@ -2357,7 +2357,6 @@ extern pthread_attr_t connection_attrib;
extern I_List<THD> threads;
extern I_List<NAMED_LIST> key_caches;
extern MY_BITMAP temp_pool;
extern String my_empty_string;
extern const String my_null_string;
extern SHOW_VAR status_vars[];
#endif /* MYSQL_SERVER */
......
......@@ -2196,13 +2196,11 @@ bool sys_var_thd_date_time_format::check(THD *thd, set_var *var)
String str(buff,sizeof(buff) - 1, system_charset_info), *res;
DATE_TIME_FORMAT *format;
if (!(res=var->value->val_str(&str)))
res= &my_empty_string;
if (!(format= date_time_format_make(date_time_type,
res->ptr(), res->length())))
if (!(res= var->value->val_str(&str)) ||
!(format= date_time_format_make(date_time_type,
res->ptr(), res->length())))
{
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res->c_ptr());
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, res ? res->c_ptr() : "NULL");
return 1;
}
......
......@@ -1923,12 +1923,13 @@ bool select_result::check_simple_select() const
static String default_line_term("\n",default_charset_info);
static String default_escaped("\\",default_charset_info);
static String default_field_term("\t",default_charset_info);
static String default_enclosed_and_line_start("", default_charset_info);
sql_exchange::sql_exchange(char *name,bool flag)
:file_name(name), opt_enclosed(0), dumpfile(flag), skip_lines(0)
{
field_term= &default_field_term;
enclosed= line_start= &my_empty_string;
enclosed= line_start= &default_enclosed_and_line_start;
line_term= &default_line_term;
escaped= &default_escaped;
cs= NULL;
......
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