summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2005-11-13 17:56:20 -0800
committerunknown <igor@rurik.mysql.com>2005-11-13 17:56:20 -0800
commit2c748c3ef9980f5be1373fd5998349b9f63a9851 (patch)
tree284461e48d23194798480c65afd64354a9cec3f1 /sql/sql_select.cc
parentb10c7d60bd46135760c59291415c49db6e8d8f71 (diff)
parentb5182e4b92bf9d4043b4ab65dedb46c14f54f6ba (diff)
downloadmariadb-git-2c748c3ef9980f5be1373fd5998349b9f63a9851.tar.gz
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-2 sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/mysql_priv.h: Manual merge
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 44c4ec998bb..aa9991f4879 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -274,21 +274,20 @@ inline int setup_without_group(THD *thd, Item **ref_pointer_array,
ORDER *order,
ORDER *group, bool *hidden_group_fields)
{
- bool save_allow_sum_func;
int res;
+ nesting_map save_allow_sum_func=thd->lex->allow_sum_func ;
DBUG_ENTER("setup_without_group");
- save_allow_sum_func= thd->allow_sum_func;
- thd->allow_sum_func= 0;
+ thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
res= setup_conds(thd, tables, leaves, conds);
- thd->allow_sum_func= save_allow_sum_func;
+ thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields,
order);
- thd->allow_sum_func= 0;
+ thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
res= res || setup_group(thd, ref_pointer_array, tables, fields, all_fields,
group, hidden_group_fields);
- thd->allow_sum_func= save_allow_sum_func;
+ thd->lex->allow_sum_func= save_allow_sum_func;
DBUG_RETURN(res);
}
@@ -355,8 +354,9 @@ JOIN::prepare(Item ***rref_pointer_array,
if (having)
{
+ nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
thd->where="having clause";
- thd->allow_sum_func=1;
+ thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level;
select_lex->having_fix_field= 1;
bool having_fix_rc= (!having->fixed &&
(having->fix_fields(thd, &having) ||
@@ -366,6 +366,18 @@ JOIN::prepare(Item ***rref_pointer_array,
DBUG_RETURN(-1); /* purecov: inspected */
if (having->with_sum_func)
having->split_sum_func(thd, ref_pointer_array, all_fields);
+ thd->lex->allow_sum_func= save_allow_sum_func;
+ }
+ if (select_lex->inner_sum_func_list)
+ {
+ Item_sum *end=select_lex->inner_sum_func_list;
+ Item_sum *item_sum= end;
+ do
+ {
+ item_sum= item_sum->next;
+ item_sum->split_sum_func2(thd, ref_pointer_array,
+ all_fields, item_sum->ref_by, FALSE);
+ } while (item_sum != end);
}
if (!thd->lex->view_prepare_mode)
@@ -5197,7 +5209,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
join->const_table_map|=RAND_TABLE_BIT;
{ // Check const tables
COND *const_cond=
- make_cond_for_table(cond,join->const_table_map,(table_map) 0);
+ make_cond_for_table(cond,
+ join->const_table_map,
+ (table_map) 0);
DBUG_EXECUTE("where",print_where(const_cond,"constants"););
for (JOIN_TAB *tab= join->join_tab+join->const_tables;
tab < join->join_tab+join->tables ; tab++)