diff options
author | unknown <hf@deer.(none)> | 2005-10-10 21:09:34 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2005-10-10 21:09:34 +0500 |
commit | 172e971078a6d6e64e128dc3a09729d238019947 (patch) | |
tree | eb10c16fad31ed83735a3b84f7f64b3a0e938bf5 /sql/item.cc | |
parent | 48f6c0c91ea9a918bec128d186c4a791b3366516 (diff) | |
parent | b9c4cb33e04ea1d30c734d6431c5318da5de07ce (diff) | |
download | mariadb-git-172e971078a6d6e64e128dc3a09729d238019947.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.cc | 24 |
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; |