summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-10-10 21:09:34 +0500
committerunknown <hf@deer.(none)>2005-10-10 21:09:34 +0500
commitaac2575bdb061a52a9995a2c0aea45e067da0848 (patch)
treeeb10c16fad31ed83735a3b84f7f64b3a0e938bf5 /sql/item.cc
parent5d2bc92523991e4304d4cbad8b4759023f6213d8 (diff)
parent0834f7d3fd950dc51d655e5b7eb207999c585e87 (diff)
downloadmariadb-git-aac2575bdb061a52a9995a2c0aea45e067da0848.tar.gz
Merge bk@192.168.21.1:/usr/home/bk/mysql-4.1
into deer.(none):/home/hf/work/mysql-4.1.13372 sql/item.cc: Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc
index 78e9c02f5f3..7419bc173d5 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3223,9 +3223,14 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
bool Item_type_holder::join_types(THD *thd, Item *item)
{
+ uint max_length_orig= max_length;
+ uint decimals_orig= decimals;
max_length= max(max_length, display_length(item));
+ decimals= max(decimals, item->decimals);
fld_type= Field::field_type_merge(fld_type, get_real_type(item));
- if (Field::result_merge_type(fld_type) == STRING_RESULT)
+ switch (Field::result_merge_type(fld_type))
+ {
+ case STRING_RESULT:
{
const char *old_cs, *old_derivation;
old_cs= collation.collation->name;
@@ -3239,8 +3244,23 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
"UNION");
return TRUE;
}
+ break;
}
- decimals= max(decimals, item->decimals);
+ case REAL_RESULT:
+ {
+ if (decimals != NOT_FIXED_DEC)
+ {
+ int delta1= max_length_orig - decimals_orig;
+ int delta2= item->max_length - item->decimals;
+ max_length= min(max(delta1, delta2) + decimals,
+ (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7);
+ }
+ else
+ max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7;
+ break;
+ }
+ default:;
+ };
maybe_null|= item->maybe_null;
get_full_info(item);
return FALSE;