diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_sum.cc | 1 | ||||
-rw-r--r-- | sql/sql_class.h | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 12 |
3 files changed, 14 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 6ca3f024f61..1ee48dfb763 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1986,6 +1986,7 @@ bool Item_func_group_concat::setup(THD *thd) } count_field_types(tmp_table_param,all_fields,0); + tmp_table_param->need_const= 1; if (table) { /* diff --git a/sql/sql_class.h b/sql/sql_class.h index b6bf0dcdc45..85ff901fe72 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1325,10 +1325,12 @@ public: bool using_indirect_summary_function; /* If >0 convert all blob fields to varchar(convert_blob_length) */ uint convert_blob_length; + bool need_const; /* <=> const items are saved in tmp table */ TMP_TABLE_PARAM() :copy_field(0), group_parts(0), - group_length(0), group_null_parts(0), convert_blob_length(0) + group_length(0), group_null_parts(0), convert_blob_length(0), + need_const(0) {} ~TMP_TABLE_PARAM() { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d3e8b3ab9e7..fc85f49093d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2262,7 +2262,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond, */ (*key_fields)->null_rejecting= (cond->functype() == Item_func::EQ_FUNC) && ((*value)->type() == Item::FIELD_ITEM) && - ((Item_field*)*value)->field->maybe_null(); + + (((Item_field*)*value)->field->maybe_null() || + ((Item_field *)*value)->field->table->maybe_null); (*key_fields)++; } @@ -5199,7 +5201,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, param->using_indirect_summary_function=1; continue; } - if (item->const_item() && (int) hidden_field_count <= 0) + if (item->const_item() && (int) hidden_field_count <= 0 && + !param->need_const) continue; // We don't have to store this } if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields) @@ -6317,6 +6320,11 @@ join_read_always_key(JOIN_TAB *tab) int error; TABLE *table= tab->table; + for (uint i= 0 ; i < tab->ref.key_parts ; i++) + { + if ((tab->ref.null_rejecting & 1 << i) && tab->ref.items[i]->is_null()) + return -1; + } if (!table->file->inited) table->file->ha_index_init(tab->ref.key); if (cp_buffer_from_ref(tab->join->thd, &tab->ref)) |