diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2008-12-12 14:59:10 +0400 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2008-12-12 14:59:10 +0400 |
commit | 5ff1bcbc2a3cf3b28ce11673d89a1d2b3d8ad376 (patch) | |
tree | 1b340a524e8568f5499ec8ad3d40354f9417c3e3 /sql | |
parent | ffe23f0eb736609915d3c201c3f2556819698dc1 (diff) | |
download | mariadb-git-5ff1bcbc2a3cf3b28ce11673d89a1d2b3d8ad376.tar.gz |
rollback of bug #40761 fix
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_cmpfunc.cc | 50 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 1 | ||||
-rw-r--r-- | sql/item_func.cc | 10 | ||||
-rw-r--r-- | sql/item_func.h | 2 |
4 files changed, 29 insertions, 34 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 759e912cc82..3b1d18b4252 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2069,23 +2069,21 @@ Item_func_ifnull::fix_length_and_dec() { agg_result_type(&hybrid_type, args, 2); maybe_null=args[1]->maybe_null; + decimals= max(args[0]->decimals, args[1]->decimals); + unsigned_flag= args[0]->unsigned_flag && args[1]->unsigned_flag; if (hybrid_type == DECIMAL_RESULT || hybrid_type == INT_RESULT) { - max_length= 0; - decimals= 0; - unsigned_flag= TRUE; - agg_num_lengths(args[0]); - agg_num_lengths(args[1]); - max_length= my_decimal_precision_to_length(max_length + decimals, decimals, - unsigned_flag); + int len0= args[0]->max_length - args[0]->decimals + - (args[0]->unsigned_flag ? 0 : 1); + + int len1= args[1]->max_length - args[1]->decimals + - (args[1]->unsigned_flag ? 0 : 1); + + max_length= max(len0, len1) + decimals + (unsigned_flag ? 0 : 1); } else - { max_length= max(args[0]->max_length, args[1]->max_length); - decimals= max(args[0]->decimals, args[1]->decimals); - unsigned_flag=args[0]->unsigned_flag && args[1]->unsigned_flag; - } switch (hybrid_type) { case STRING_RESULT: @@ -2240,6 +2238,8 @@ void Item_func_if::fix_length_and_dec() { maybe_null=args[1]->maybe_null || args[2]->maybe_null; + decimals= max(args[1]->decimals, args[2]->decimals); + unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); @@ -2276,20 +2276,16 @@ Item_func_if::fix_length_and_dec() if ((cached_result_type == DECIMAL_RESULT ) || (cached_result_type == INT_RESULT)) { - max_length= 0; - decimals= 0; - unsigned_flag= TRUE; - agg_num_lengths(args[1]); - agg_num_lengths(args[2]); - max_length= my_decimal_precision_to_length(max_length + decimals, decimals, - unsigned_flag); + int len1= args[1]->max_length - args[1]->decimals + - (args[1]->unsigned_flag ? 0 : 1); + + int len2= args[2]->max_length - args[2]->decimals + - (args[2]->unsigned_flag ? 0 : 1); + + max_length=max(len1, len2) + decimals + (unsigned_flag ? 0 : 1); } else - { max_length= max(args[1]->max_length, args[2]->max_length); - decimals= max(args[1]->decimals, args[2]->decimals); - unsigned_flag=args[1]->unsigned_flag && args[2]->unsigned_flag; - } } @@ -2637,6 +2633,16 @@ void Item_func_case::agg_str_lengths(Item* arg) } +void Item_func_case::agg_num_lengths(Item *arg) +{ + uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, + arg->unsigned_flag) - arg->decimals; + set_if_bigger(max_length, len); + set_if_bigger(decimals, arg->decimals); + unsigned_flag= unsigned_flag && arg->unsigned_flag; +} + + void Item_func_case::fix_length_and_dec() { Item **agg; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 6ecbfba140f..db831c7030c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -759,6 +759,7 @@ public: Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } void agg_str_lengths(Item *arg); + void agg_num_lengths(Item *arg); }; diff --git a/sql/item_func.cc b/sql/item_func.cc index c650b0ae933..c0d08d9b213 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5668,13 +5668,3 @@ void Item_func_sp::update_used_tables() const_item_cache= FALSE; } } - - -void Item_func::agg_num_lengths(Item *arg) -{ - uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals, - arg->unsigned_flag) - arg->decimals; - set_if_bigger(max_length, len); - set_if_bigger(decimals, arg->decimals); - unsigned_flag= unsigned_flag && arg->unsigned_flag; -} diff --git a/sql/item_func.h b/sql/item_func.h index d4da0b7a853..6dcf32cba07 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -193,8 +193,6 @@ public: void * arg, traverse_order order); bool is_expensive_processor(byte *arg); virtual bool is_expensive() { return 0; } -protected: - void agg_num_lengths(Item *arg); }; |