summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-03-25 23:48:48 -0700
committerigor@olga.mysql.com <>2007-03-25 23:48:48 -0700
commit7773523f80d484ecea772b8d09a2ec34987ac706 (patch)
tree93fc847f1df9c6a887334d8d17cfd99d6d6fe646
parent081f43cc513ad204f3965cec95dfe0e3e0d74c34 (diff)
parent18ea806864365f5956210c1a781a19a90cb1a007 (diff)
downloadmariadb-git-7773523f80d484ecea772b8d09a2ec34987ac706.tar.gz
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27229
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/sql_select.cc26
2 files changed, 17 insertions, 12 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 422e9b4c6ea..368dc9a7d38 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -449,8 +449,7 @@ void Item_sum::update_used_tables ()
used_tables_cache&= PSEUDO_TABLE_BITS;
/* the aggregate function is aggregated into its local context */
- if (aggr_level == nest_level)
- used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
+ used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
}
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4fbc5dddb07..bb57764700d 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -9196,17 +9196,21 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Item::Type type=item->type();
if (not_all_columns)
{
- if (item->with_sum_func && type != Item::SUM_FUNC_ITEM &&
- (type == Item::SUBSELECT_ITEM ||
- (item->used_tables() & ~PSEUDO_TABLE_BITS)))
+ if (item->with_sum_func && type != Item::SUM_FUNC_ITEM)
{
- /*
- Mark that the we have ignored an item that refers to a summary
- function. We need to know this if someone is going to use
- DISTINCT on the result.
- */
- param->using_indirect_summary_function=1;
- continue;
+ if (item->used_tables() & OUTER_REF_TABLE_BIT)
+ item->update_used_tables();
+ if (type == Item::SUBSELECT_ITEM ||
+ (item->used_tables() & ~OUTER_REF_TABLE_BIT))
+ {
+ /*
+ Mark that the we have ignored an item that refers to a summary
+ function. We need to know this if someone is going to use
+ DISTINCT on the result.
+ */
+ param->using_indirect_summary_function=1;
+ continue;
+ }
}
if (item->const_item() && (int) hidden_field_count <= 0)
continue; // We don't have to store this
@@ -9391,6 +9395,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->s->default_values= table->record[1]+alloc_length;
}
copy_func[0]=0; // End marker
+ param->func_count= copy_func - param->items_to_copy;
recinfo=param->start_recinfo;
null_flags=(uchar*) table->record[0];
@@ -13571,6 +13576,7 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
if (!sum_item->quick_group)
param->quick_group=0; // UDF SUM function
param->sum_func_count++;
+ param->func_count++;
for (uint i=0 ; i < sum_item->arg_count ; i++)
{