Commit cfa94b43 authored by Sergei Golubchik's avatar Sergei Golubchik

revert

  revid:georgi.kodinov@oracle.com-20120309130449-82e3bs5v3et1x0ef
  committer: Georgi Kodinov <Georgi.Kodinov@Oracle.com>
  timestamp: Fri 2012-03-09 15:04:49 +0200
  message:
    Bug #12408412: GROUP_CONCAT + ORDER BY + INPUT/OUTPUT SAME 
    USER VARIABLE = CRASH
    Moved the preparation of the variables that receive the output from 
    SELECT INTO from execution time (JOIN:execute) to compile time 
    (JOIN::prepare). This ensures that if the same variable is used in the
    SELECT part of SELECT INTO it will be properly marked as non-const
    for this query.
    Test case added.
    Used proper fast iterator.

a better fix (much smaller and without regressions) is coming from 5.1
parent 8161c677
...@@ -416,14 +416,6 @@ DROP TRIGGER trg1; ...@@ -416,14 +416,6 @@ DROP TRIGGER trg1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #12408412: GROUP_CONCAT + ORDER BY + INPUT/OUTPUT
--echo # SAME USER VARIABLE = CRASH
--echo #
SET @bug12408412=1;
SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412;
# #
# MDEV-616 LP BUG#1002126 # MDEV-616 LP BUG#1002126
# Bug #11764371 57196: MORE FUN WITH ASSERTION: !TABLE->FILE || # Bug #11764371 57196: MORE FUN WITH ASSERTION: !TABLE->FILE ||
......
...@@ -3110,11 +3110,6 @@ int select_exists_subselect::send_data(List<Item> &items) ...@@ -3110,11 +3110,6 @@ int select_exists_subselect::send_data(List<Item> &items)
int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
{ {
unit= u; unit= u;
List_iterator_fast<my_var> var_li(var_list);
List_iterator_fast<Item> it(list);
Item *item;
my_var *mv;
Item_func_set_user_var **suv;
if (var_list.elements != list.elements) if (var_list.elements != list.elements)
{ {
...@@ -3122,30 +3117,6 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) ...@@ -3122,30 +3117,6 @@ int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0)); ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
return 1; return 1;
} }
/*
Iterate over the destination variables and mark them as being
updated in this query.
We need to do this at JOIN::prepare time to ensure proper
const detection of Item_func_get_user_var that is determined
by the presence of Item_func_set_user_vars
*/
suv= set_var_items= (Item_func_set_user_var **)
sql_alloc(sizeof(Item_func_set_user_var *) * list.elements);
while ((mv= var_li++) && (item= it++))
{
if (!mv->local)
{
*suv= new Item_func_set_user_var(mv->s, item);
(*suv)->fix_fields(thd, 0);
}
else
*suv= NULL;
suv++;
}
return 0; return 0;
} }
...@@ -3465,7 +3436,6 @@ int select_dumpvar::send_data(List<Item> &items) ...@@ -3465,7 +3436,6 @@ int select_dumpvar::send_data(List<Item> &items)
List_iterator<Item> it(items); List_iterator<Item> it(items);
Item *item; Item *item;
my_var *mv; my_var *mv;
Item_func_set_user_var **suv;
DBUG_ENTER("select_dumpvar::send_data"); DBUG_ENTER("select_dumpvar::send_data");
if (unit->offset_limit_cnt) if (unit->offset_limit_cnt)
...@@ -3478,19 +3448,20 @@ int select_dumpvar::send_data(List<Item> &items) ...@@ -3478,19 +3448,20 @@ int select_dumpvar::send_data(List<Item> &items)
my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0)); my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
for (suv= set_var_items; ((mv= var_li++) && (item= it++)); suv++) while ((mv= var_li++) && (item= it++))
{ {
if (mv->local) if (mv->local)
{ {
DBUG_ASSERT(!*suv);
if (thd->spcont->set_variable(thd, mv->offset, &item)) if (thd->spcont->set_variable(thd, mv->offset, &item))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
else else
{ {
DBUG_ASSERT(*suv); Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item);
(*suv)->save_item_result(item); if (suv->fix_fields(thd, 0))
if ((*suv)->update()) DBUG_RETURN (1);
suv->save_item_result(item);
if (suv->update())
DBUG_RETURN (1); DBUG_RETURN (1);
} }
} }
......
...@@ -4025,7 +4025,6 @@ class my_var : public Sql_alloc { ...@@ -4025,7 +4025,6 @@ class my_var : public Sql_alloc {
class select_dumpvar :public select_result_interceptor { class select_dumpvar :public select_result_interceptor {
ha_rows row_count; ha_rows row_count;
Item_func_set_user_var **set_var_items;
public: public:
List<my_var> var_list; List<my_var> var_list;
select_dumpvar() { var_list.empty(); row_count= 0;} select_dumpvar() { var_list.empty(); row_count= 0;}
......
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