From f47b2d38f6c4851ef6bd069f5d1ffe033056d582 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 28 Jan 2010 16:48:33 +0300 Subject: Subquery optimizations: non-semijoin materialization - Backport into Maria DB 5.3, part 1 --- sql/item_buff.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sql/item_buff.cc') diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 2f45d0a17c2..037a988ebbc 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -27,11 +27,16 @@ Create right type of Cached_item for an item. */ -Cached_item *new_Cached_item(THD *thd, Item *item) +Cached_item *new_Cached_item(THD *thd, Item *item, bool use_result_field) { if (item->real_item()->type() == Item::FIELD_ITEM && !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG)) - return new Cached_item_field((Item_field *) (item->real_item())); + { + Item_field *real_item= (Item_field *) item->real_item(); + Field *cached_field= use_result_field ? real_item->result_field : + real_item->field; + return new Cached_item_field(cached_field); + } switch (item->result_type()) { case STRING_RESULT: return new Cached_item_str(thd, (Item_field *) item); -- cgit v1.2.1 From e5f238a05152efbd4b05425511eeed59c3026779 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 6 Jul 2010 19:16:24 +0400 Subject: Fix buildbot valgrind failure - Item_in_subselect::init_left_expr_cache() should not try to guess whether the left expression is accessed "over the grouping operation" (i.e. the subselect is evaluated after the grouping while the left_expr is an Item_ref that wraps an expression from before the grouping). Instead, let new_Cached_item not to try accessing item->real_item() when creating left expr cache. --- sql/item_buff.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sql/item_buff.cc') diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 037a988ebbc..13183a33e59 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -27,14 +27,13 @@ Create right type of Cached_item for an item. */ -Cached_item *new_Cached_item(THD *thd, Item *item, bool use_result_field) +Cached_item *new_Cached_item(THD *thd, Item *item, bool pass_through_ref) { - if (item->real_item()->type() == Item::FIELD_ITEM && + if (pass_through_ref && item->real_item()->type() == Item::FIELD_ITEM && !(((Item_field *) (item->real_item()))->field->flags & BLOB_FLAG)) { Item_field *real_item= (Item_field *) item->real_item(); - Field *cached_field= use_result_field ? real_item->result_field : - real_item->field; + Field *cached_field= real_item->field; return new Cached_item_field(cached_field); } switch (item->result_type()) { -- cgit v1.2.1