summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-07-07 10:30:52 +0300
committerunknown <bell@sanja.is.com.ua>2003-07-07 10:30:52 +0300
commit2cd6d8ec6bd7a4a04a0b19943da0f331df25cf0f (patch)
tree9d2dbc3b4a17e7aed69920ac3310ee909444ee3c /sql/item_sum.cc
parenta6943f99887b4883cb489697eb8ce7593e40ac37 (diff)
parentcd3e15a6f998a74c0f04560bd8243a04e3218d66 (diff)
downloadmariadb-git-2cd6d8ec6bd7a4a04a0b19943da0f331df25cf0f.tar.gz
merge
mysql-test/t/subselect.test: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_func.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 43534276759..9dd6fb04dfb 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1114,7 +1114,7 @@ void Item_sum_count_distinct::make_unique()
bool Item_sum_count_distinct::setup(THD *thd)
{
List<Item> list;
- SELECT_LEX *select_lex= current_lex->current_select;
+ SELECT_LEX *select_lex= thd->lex.current_select;
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
return 1;
@@ -1599,7 +1599,7 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
warning_available(0), key_length(0), rec_offset(0),
tree_mode(0), distinct(is_distinct), warning_for_row(0),
separator(is_separator), tree(&tree_base), table(0),
- order(0), tables_list(0), group_concat_max_len(0),
+ order(0), tables_list(0),
show_elements(0), arg_count_order(0), arg_count_field(0),
arg_show_fields(0), count_cut_values(0)
@@ -1607,8 +1607,11 @@ Item_func_group_concat::Item_func_group_concat(bool is_distinct,
original= 0;
quick_group= 0;
mark_as_sum_func();
- SELECT_LEX *select_lex= current_lex->current_select;
+ item_thd= current_thd;
+ SELECT_LEX *select_lex= item_thd->lex.current_select;
order= 0;
+ group_concat_max_len= item_thd->variables.group_concat_max_len;
+
arg_show_fields= arg_count_field= is_select->elements;
arg_count_order= is_order ? is_order->elements : 0;
@@ -1773,7 +1776,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
result_field= 0;
null_value= 1;
- fix_length_and_dec();
+ max_length= group_concat_max_len;
thd->allow_sum_func= 1;
if (!(tmp_table_param= new TMP_TABLE_PARAM))
return 1;
@@ -1785,11 +1788,12 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
bool Item_func_group_concat::setup(THD *thd)
{
+ DBUG_ENTER("Item_func_group_concat::setup");
List<Item> list;
- SELECT_LEX *select_lex= current_lex->current_select;
+ SELECT_LEX *select_lex= thd->lex.current_select;
if (select_lex->linkage == GLOBAL_OPTIONS_TYPE)
- return 1;
+ DBUG_RETURN(1);
/*
all not constant fields are push to list and create temp table
*/
@@ -1798,7 +1802,7 @@ bool Item_func_group_concat::setup(THD *thd)
{
Item *item= args[i];
if (list.push_back(item))
- return 1;
+ DBUG_RETURN(1);
if (item->const_item())
{
(void) item->val_int();
@@ -1807,7 +1811,7 @@ bool Item_func_group_concat::setup(THD *thd)
}
}
if (always_null)
- return 0;
+ DBUG_RETURN(0);
List<Item> all_fields(list);
if (arg_count_order)
@@ -1818,13 +1822,18 @@ bool Item_func_group_concat::setup(THD *thd)
}
count_field_types(tmp_table_param,all_fields,0);
+ if (table)
+ {
+ free_tmp_table(thd, table);
+ tmp_table_param->cleanup();
+ }
/*
We have to create a temporary table for that we get descriptions of fields
(types, sizes and so on).
*/
if (!(table=create_tmp_table(thd, tmp_table_param, all_fields, 0,
- 0, 0, 0,select_lex->options | thd->options)))
- return 1;
+ 0, 0, 0,select_lex->options | thd->options)))
+ DBUG_RETURN(1);
table->file->extra(HA_EXTRA_NO_ROWS);
table->no_rows= 1;
@@ -1873,9 +1882,6 @@ bool Item_func_group_concat::setup(THD *thd)
max_elements_in_tree= ((key_length) ?
thd->variables.max_heap_table_size/key_length : 1);
};
- item_thd= thd;
-
- group_concat_max_len= thd->variables.group_concat_max_len;
/*
Copy table and tree_mode if they belong to this item (if item have not
@@ -1886,7 +1892,7 @@ bool Item_func_group_concat::setup(THD *thd)
original->table= table;
original->tree_mode= tree_mode;
}
- return 0;
+ DBUG_RETURN(0);
}
/* This is used by rollup to create a separate usable copy of the function */