diff options
author | Ingo Struewing <ingo.struewing@sun.com> | 2009-09-16 12:07:57 +0200 |
---|---|---|
committer | Ingo Struewing <ingo.struewing@sun.com> | 2009-09-16 12:07:57 +0200 |
commit | 3dea04c58bf665d98e3bbdb12a6386c5920c1b77 (patch) | |
tree | d6c4b43c4e319ca234f7b16ce0cb6d54cd1fad9f /sql | |
parent | 540b2dc0041c292220d389bbb5b87a8410aef3f4 (diff) | |
parent | 10406ae65871de074e807e626f9ede686e9321d4 (diff) | |
download | mariadb-git-3dea04c58bf665d98e3bbdb12a6386c5920c1b77.tar.gz |
Pull from mysql-5.0-bugteam
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index e3fe67f4324..6f697a1665a 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -600,6 +600,7 @@ String *Item_func_concat_ws::val_str(String *str) String tmp_sep_str(tmp_str_buff, sizeof(tmp_str_buff),default_charset_info), *sep_str, *res, *res2,*use_as_buff; uint i; + bool is_const= 0; null_value=0; if (!(sep_str= args[0]->val_str(&tmp_sep_str))) @@ -613,7 +614,11 @@ String *Item_func_concat_ws::val_str(String *str) // If not, return the empty string for (i=1; i < arg_count; i++) if ((res= args[i]->val_str(str))) + { + is_const= args[i]->const_item() || !args[i]->used_tables(); break; + } + if (i == arg_count) return &my_empty_string; @@ -631,7 +636,7 @@ String *Item_func_concat_ws::val_str(String *str) current_thd->variables.max_allowed_packet); goto null; } - if (res->alloced_length() >= + if (!is_const && res->alloced_length() >= res->length() + sep_str->length() + res2->length()) { // Use old buffer res->append(*sep_str); // res->length() > 0 always diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b670e6e3637..9d5e67c9532 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1474,12 +1474,8 @@ JOIN::optimize() } } - /* - If this join belongs to an uncacheable subquery save - the original join - */ - if (select_lex->uncacheable && !is_top_level_join() && - init_save_join_tab()) + /* If this join belongs to an uncacheable query save the original join */ + if (select_lex->uncacheable && init_save_join_tab()) DBUG_RETURN(-1); /* purecov: inspected */ } |