summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-03-28 20:16:13 +0200
committerSergei Golubchik <serg@mariadb.org>2018-03-30 09:45:03 +0200
commit7a903784b780ea127d534e510a521b4126c3a655 (patch)
tree618a1fa57864298a432ce8e0bf94fee3c7c970e7 /sql/item_cmpfunc.h
parent4c77ef36c69b2919f8d788c4de9e1f2da07410d7 (diff)
downloadmariadb-git-7a903784b780ea127d534e510a521b4126c3a655.tar.gz
cleanup: Item_func_case
reorder items in args[] array. Instead of when1,then1,when2,then2,...[,case][,else] sort them as [case,]when1,when2,...,then1,then2,...[,else] in this case all items used for comparison take a continuous part of the array and can be aggregated directly. and all items that can be returned take a continuous part of the array and can be aggregated directly. Old code had to copy them to a temporary array before aggreation, and then copy back (thd->change_item_tree) everything that was changed. this is a 10.3 version of bf1ca14ff3f
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h18
1 files changed, 5 insertions, 13 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 3d11a226d07..d10bac0fced 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -2104,15 +2104,13 @@ class Item_func_case :public Item_func_case_expression
protected:
String tmp_value;
DTCollation cmp_collation;
- Item **arg_buffer;
- bool aggregate_then_and_else_arguments(THD *thd,
- Item **items, uint count,
- Item **else_expr);
+ bool aggregate_then_and_else_arguments(THD *thd, uint count);
virtual Item **else_expr_addr() const= 0;
virtual Item *find_item()= 0;
void print_when_then_arguments(String *str, enum_query_type query_type,
Item **items, uint count);
void print_else_argument(String *str, enum_query_type query_type, Item *item);
+ void reorder_args(uint start);
public:
Item_func_case(THD *thd, List<Item> &list)
:Item_func_case_expression(thd, list)
@@ -2129,13 +2127,6 @@ public:
enum precedence precedence() const { return BETWEEN_PRECEDENCE; }
CHARSET_INFO *compare_collation() const { return cmp_collation.collation; }
bool need_parentheses_in_default() { return true; }
- Item *build_clone(THD *thd)
- {
- Item_func_case *clone= (Item_func_case *) Item_func::build_clone(thd);
- if (clone)
- clone->arg_buffer= 0;
- return clone;
- }
};
@@ -2156,6 +2147,7 @@ public:
:Item_func_case(thd, list)
{
DBUG_ASSERT(arg_count >= 2);
+ reorder_args(0);
}
void print(String *str, enum_query_type query_type);
void fix_length_and_dec();
@@ -2200,6 +2192,7 @@ public:
m_found_types(0)
{
DBUG_ASSERT(arg_count >= 3);
+ reorder_args(1);
}
void cleanup()
{
@@ -2233,8 +2226,7 @@ public:
:Item_func_case_simple(thd, list)
{ }
const char *func_name() const { return "decode_oracle"; }
- void print(String *str, enum_query_type query_type)
- { Item_func::print(str, query_type); }
+ void print(String *str, enum_query_type query_type);
void fix_length_and_dec();
Item *find_item();
Item *get_copy(THD *thd)