summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-11-25 13:19:01 +0200
committerMichael Widenius <monty@askmonty.org>2010-11-25 13:19:01 +0200
commit721a6a6a6d3de10d24396ba96d6b8a013080f843 (patch)
treeb082df5b3d891b626ca070e34175fc5e0e618147 /sql/sql_select.cc
parentbabdbbbfd2d24b7a953ea3978bf076202995faa9 (diff)
downloadmariadb-git-721a6a6a6d3de10d24396ba96d6b8a013080f843.tar.gz
A proper fix for bug #57688.
Introduced a new flag in the class Item. The flag is set to 1 only for items that are used in GROUP BY lists of queries with ROLLUP.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 972f4f7610f..60bfa0dfcd6 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8919,6 +8919,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
For some of the inner tables there are conjunctive predicates
that reject nulls => the outer join can be replaced by an inner join.
*/
+ if (table->outer_join && !table->embedding && table->table)
+ table->table->maybe_null= FALSE;
table->outer_join= 0;
if (table->on_expr)
{
@@ -9005,6 +9007,8 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
while ((tbl= it++))
{
tbl->embedding= table->embedding;
+ if (!tbl->embedding && !tbl->on_expr && tbl->table)
+ tbl->table->maybe_null= FALSE;
tbl->join_list= table->join_list;
}
li.replace(nested_join->join_list);
@@ -9882,7 +9886,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
If item have to be able to store NULLs but underlaid field can't do it,
create_tmp_field_from_field() can't be used for tmp field creation.
*/
- if (field->maybe_null && !field->field->maybe_null())
+ if (field->maybe_null && field->in_rollup && !field->field->maybe_null())
{
result= create_tmp_field_from_item(thd, item, table, NULL,
modify_item, convert_blob_length);
@@ -13508,8 +13512,6 @@ static bool
list_contains_unique_index(TABLE *table,
bool (*find_func) (Field *, void *), void *data)
{
- if (table->pos_in_table_list->outer_join)
- return 0;
for (uint keynr= 0; keynr < table->s->keys; keynr++)
{
if (keynr == table->s->primary_key ||
@@ -13523,7 +13525,7 @@ list_contains_unique_index(TABLE *table,
key_part < key_part_end;
key_part++)
{
- if (key_part->field->real_maybe_null() ||
+ if (key_part->field->maybe_null() ||
!find_func(key_part->field, data))
break;
}
@@ -16337,6 +16339,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
if (arg_changed)
{
expr->maybe_null= 1;
+ expr->in_rollup= 1;
*changed= TRUE;
}
}
@@ -16400,6 +16403,7 @@ bool JOIN::rollup_init()
if (*group_tmp->item == item)
{
item->maybe_null= 1;
+ item->in_rollup= 1;
found_in_group= 1;
break;
}