Commit 83e25bbc authored by unknown's avatar unknown

fixed removed by previos patch thd->allow_sum_func "side effect" of setup_conds

renamed tables to prevent droping real tables


mysql-test/r/group_by.result:
  test of error message
mysql-test/r/subselect.result:
  renamed tables to prevent droping real tables
mysql-test/t/group_by.test:
  test of error message
mysql-test/t/subselect.test:
  renamed tables to prevent droping real tables
sql/sql_base.cc:
  moved thd->allow_sum_func assignment to upper level
sql/sql_select.cc:
  fixed removed by previos patch thd->allow_sum_func "side effect" of setup_conds
parent 4587ddda
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
Invalid use of group function
drop table if exists t1,t2,t3;
CREATE TABLE t1 (
spID int(10) unsigned,
......
This diff is collapsed.
-- error 1111
SELECT 1 FROM (SELECT 1) GROUP BY SUM(1);
#
# Test of group (Failed for Lars Hoss <lh@pbm.de>)
#
......
This diff is collapsed.
......@@ -2227,8 +2227,6 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
thd->set_query_id=1;
thd->cond_count= 0;
bool save_allow_sum_func= thd->allow_sum_func;
thd->allow_sum_func= 0;
if (*conds)
{
thd->where="where clause";
......@@ -2301,7 +2299,6 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
table->on_expr=and_conds(table->on_expr,cond_and);
}
}
thd->allow_sum_func= save_allow_sum_func;
DBUG_RETURN(test(thd->fatal_error));
}
......
......@@ -199,6 +199,26 @@ void fix_tables_pointers(SELECT_LEX *select_lex)
}
}
/*
Inline function to setup clauses without sum functions
*/
inline int setup_without_group(THD *thd, TABLE_LIST *tables,
List<Item> &fields,
List<Item> &all_fields,
COND **conds,
ORDER *order,
ORDER *group, bool *hidden_group_fields)
{
bool save_allow_sum_func= thd->allow_sum_func;
thd->allow_sum_func= 0;
int res= (setup_conds(thd,tables, conds) ||
setup_order(thd,tables, fields, all_fields, order) ||
setup_group(thd,tables, fields, all_fields, group,
hidden_group_fields));
thd->allow_sum_func= save_allow_sum_func;
return res;
}
/*****************************************************************************
Check fields, find best join, do the select and output fields.
mysql_select assumes that all tables are already opened
......@@ -233,10 +253,8 @@ JOIN::prepare(TABLE_LIST *tables_init,
if (setup_tables(tables_list) ||
setup_fields(thd,tables_list,fields_list,1,&all_fields,1) ||
setup_conds(thd,tables_list,&conds) ||
setup_order(thd,tables_list,fields_list,all_fields,order) ||
setup_group(thd,tables_list,fields_list,all_fields,group_list,
&hidden_group_fields))
setup_without_group(thd, tables_list, fields_list, all_fields,
&conds, order, group_list, &hidden_group_fields))
DBUG_RETURN(-1); /* purecov: inspected */
if (having)
......
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