summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-29 13:16:26 +0400
committerunknown <ramil/ram@ramil.myoffice.izhnet.ru>2007-10-29 13:16:26 +0400
commit3076fff2bcda6cf1de901aff0e0a658b635054a1 (patch)
tree82d1286179fdd8dc0b04ae78c05b66ba0bb938e6 /sql
parent1fe29801e8a8d395b3a348b26186279e5aa18b84 (diff)
parent90081aedc697902a911f2c336f7deb64146a9339 (diff)
downloadmariadb-git-3076fff2bcda6cf1de901aff0e0a658b635054a1.tar.gz
Merge mysql.com:/home/ram/work/b30782/b30782.5.0
into mysql.com:/home/ram/work/b30782/b30782.5.1 sql/item_cmpfunc.cc: Auto merged mysql-test/r/case.result: manual merge. mysql-test/t/case.test: manual merge. sql/item_cmpfunc.h: manual merge.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_cmpfunc.cc36
-rw-r--r--sql/item_cmpfunc.h3
2 files changed, 33 insertions, 6 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 9b7b7b1a62a..5642c671dbd 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2557,6 +2557,23 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
}
+void Item_func_case::agg_str_lengths(Item* arg)
+{
+ set_if_bigger(max_length, arg->max_length);
+ set_if_bigger(decimals, arg->decimals);
+ unsigned_flag= unsigned_flag && arg->unsigned_flag;
+}
+
+
+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()
{
@@ -2620,15 +2637,22 @@ void Item_func_case::fix_length_and_dec()
max_length=0;
decimals=0;
- for (uint i=0 ; i < ncases ; i+=2)
+ unsigned_flag= TRUE;
+ if (cached_result_type == STRING_RESULT)
{
- set_if_bigger(max_length,args[i+1]->max_length);
- set_if_bigger(decimals,args[i+1]->decimals);
+ for (uint i= 0; i < ncases; i+= 2)
+ agg_str_lengths(args[i + 1]);
+ if (else_expr_num != -1)
+ agg_str_lengths(args[else_expr_num]);
}
- if (else_expr_num != -1)
+ else
{
- set_if_bigger(max_length,args[else_expr_num]->max_length);
- set_if_bigger(decimals,args[else_expr_num]->decimals);
+ for (uint i= 0; i < ncases; i+= 2)
+ agg_num_lengths(args[i + 1]);
+ if (else_expr_num != -1)
+ agg_num_lengths(args[else_expr_num]);
+ max_length= my_decimal_precision_to_length(max_length + decimals, decimals,
+ unsigned_flag);
}
}
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index a5252cc08f7..8ef87d0dd59 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -713,6 +713,7 @@ public:
bool is_null();
};
+
/* Functions to handle the optimized IN */
@@ -1139,6 +1140,8 @@ public:
Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
void cleanup();
+ void agg_str_lengths(Item *arg);
+ void agg_num_lengths(Item *arg);
};
/*