Skip to content

Commit 499deca

Browse files
author
Alexander Barkov
committed
A clean-up for c8141f5
MDEV-7950 Item_func::type() takes 0.26% in OLTP RO (Step#2) - Item_ref was doing unnecessary extra job after the "MDEV-7950 Step#2" patch. Fallback to Item::build_equal_items() if real_type() is not FIELD_ITEM. Note, Item_ref::build_equal_items() will most likely be further simplified. Waiting for Sanja and Igor to check a possibly dead code. - Safety: Adding Item_sum::build_equal_items() with ASSERT, as Item_sum should never appear in build_equal_items() context.
1 parent 9cdf5c2 commit 499deca

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

sql/item.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,6 +3575,22 @@ class Item_ref :public Item_ident
35753575
Item *get_tmp_table_item(THD *thd);
35763576
table_map used_tables() const;
35773577
void update_used_tables();
3578+
COND *build_equal_items(THD *thd, COND_EQUAL *inherited,
3579+
bool link_item_fields)
3580+
{
3581+
/*
3582+
Item_ref cannot refer to Item_field when build_equal_items() is called,
3583+
because all "WHERE/HAVING field" are already replaced to
3584+
"WHERE/HAVING field<>0" by this time. See normalize_cond().
3585+
TODO: make sure with Igor and Sanja, perhaps the below expression
3586+
can be simplified just to a Item::build_equal_items() call.
3587+
*/
3588+
return real_type() == FIELD_ITEM ?
3589+
Item_ident_or_func_or_sum::build_equal_items(thd, inherited,
3590+
link_item_fields) :
3591+
Item::build_equal_items(thd, inherited,
3592+
link_item_fields);
3593+
}
35783594
bool const_item() const
35793595
{
35803596
return (*ref)->const_item();

sql/item_sum.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,17 @@ class Item_sum :public Item_func_or_sum
444444
*/
445445
table_map used_tables() const { return used_tables_cache; }
446446
void update_used_tables ();
447+
COND *build_equal_items(THD *thd, COND_EQUAL *inherited,
448+
bool link_item_fields)
449+
{
450+
/*
451+
Item_sum (and derivants) of the original WHERE/HAVING clauses
452+
should already be replaced to Item_aggregate_ref by the time when
453+
build_equal_items() is called. See Item::split_sum_func2().
454+
*/
455+
DBUG_ASSERT(0);
456+
return Item::build_equal_items(thd, inherited, link_item_fields);
457+
}
447458
bool is_null() { return null_value; }
448459
void make_const ()
449460
{

0 commit comments

Comments
 (0)