summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc15
-rw-r--r--sql/item_strfunc.h1
-rw-r--r--sql/item_sum.cc20
-rw-r--r--sql/item_sum.h1
4 files changed, 9 insertions, 28 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 6be9bee438e..864840b726e 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -950,17 +950,10 @@ String *Item_func_left::val_str(String *str)
return 0;
if (length <= 0)
return &my_empty_string;
- length= res->charpos(length);
- if (res->length() > (ulong) length)
- { // Safe even if const arg
- if (!res->alloced_length())
- { // Don't change const str
- str_value= *res; // Not malloced string
- res= &str_value;
- }
- res->length((uint) length);
- }
- return res;
+ if (res->length() <= (uint) length)
+ return res;
+ tmp_value.set(*res, 0, res->charpos(length));
+ return &tmp_value;
}
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index 22134733393..d5c6a05ac3e 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -180,6 +180,7 @@ public:
class Item_func_left :public Item_str_func
{
+ String tmp_value;
public:
Item_func_left(Item *a,Item *b) :Item_str_func(a,b) {}
String *val_str(String *);
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 0c5b29fc069..7c11a520d27 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1666,6 +1666,9 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
String tmp((char *)&buff,sizeof(buff),default_charset_info), tmp2;
char *record= (char*) item->table->record[0];
+ if (item->result.length())
+ item->result.append(*item->separator);
+
tmp.length(0);
for (uint i= 0; i < item->arg_count_field; i++)
@@ -1695,14 +1698,6 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)),
item->result.append(*res);
}
}
- if (item->tree_mode) // Last item of tree
- {
- item->show_elements++;
- if (item->show_elements < item->tree->elements_in_tree)
- item->result.append(*item->separator);
- }
- else
- item->result.append(*item->separator);
/* stop if length of result more than group_concat_max_len */
if (item->result.length() > item->group_concat_max_len)
@@ -1733,7 +1728,7 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
tree_mode(0), distinct(is_distinct), warning_for_row(0),
separator(is_separator), tree(&tree_base), table(0),
order(0), tables_list(0),
- show_elements(0), arg_count_order(0), arg_count_field(0),
+ arg_count_order(0), arg_count_field(0),
count_cut_values(0)
{
Item *item_select;
@@ -1799,7 +1794,6 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
order(item->order),
tables_list(item->tables_list),
group_concat_max_len(item->group_concat_max_len),
- show_elements(item->show_elements),
arg_count_order(item->arg_count_order),
arg_count_field(item->arg_count_field),
field_list_offset(item->field_list_offset),
@@ -2107,15 +2101,9 @@ String* Item_func_group_concat::val_str(String* str)
return 0;
if (tree_mode)
{
- show_elements= 0;
tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this,
left_root_right);
}
- else
- {
- if (!warning_for_row)
- result.length(result.length()-separator->length());
- }
if (count_cut_values && !warning_available)
{
warning_available= TRUE;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index ef947900fd2..648c0bb4572 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -694,7 +694,6 @@ class Item_func_group_concat : public Item_sum
ORDER **order;
TABLE_LIST *tables_list;
ulong group_concat_max_len;
- uint show_elements;
uint arg_count_order;
uint arg_count_field;
uint field_list_offset;