diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2014-01-28 12:25:29 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2014-01-28 12:25:29 +0400 |
commit | f189ed5009cfd4149aa90ba18bfc9c80de9f0a39 (patch) | |
tree | 04d87fca2479c120dac118eba46a2c03dc30004a | |
parent | 7ea9d1e692c69c8715d98a9dbc44289d47a65447 (diff) | |
download | mariadb-git-f189ed5009cfd4149aa90ba18bfc9c80de9f0a39.tar.gz |
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.
-rw-r--r-- | mysql-test/r/date_formats.result | 2 | ||||
-rw-r--r-- | mysql-test/r/timezone2.result | 6 | ||||
-rw-r--r-- | mysql-test/t/date_formats.test | 2 | ||||
-rw-r--r-- | mysql-test/t/timezone2.test | 6 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 7 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/set_var.cc | 10 | ||||
-rw-r--r-- | sql/sql_class.cc | 3 |
8 files changed, 23 insertions, 14 deletions
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 88255a06adb..c1519b769f5 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -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'; diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index 70f5ef9edc1..0ac4ddca277 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -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 # diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 55e08e420b1..81cd125d750 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -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'; diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 7764b39bf33..2d61c7631f2 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -298,5 +298,11 @@ 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 # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a21dd9cc02a..497739f112a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -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)) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 0bfdac2f531..ace62e9c640 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -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 */ diff --git a/sql/set_var.cc b/sql/set_var.cc index 94a1b6a1cef..44e54ab4eb1 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -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; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5b0d0470370..48d32a13a1b 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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; |