diff options
author | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-03-27 15:58:34 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-03-27 15:58:34 +0300 |
commit | dcac05be55b40a2be5e0a9d25567caa3c19e75d1 (patch) | |
tree | 8538630e9ee89f814bc37da8e1a1b32011cb3fb2 /sql/item.cc | |
parent | c2c47b67fd6f6130b941a0b50fa701b0bb105ba7 (diff) | |
parent | 0b60184b90cfb7ed1eb927e5106eb194677d43f7 (diff) | |
download | mariadb-git-dcac05be55b40a2be5e0a9d25567caa3c19e75d1.tar.gz |
Automerge.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/sql/item.cc b/sql/item.cc index 86a1b59d662..220c72059d1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6969,18 +6969,26 @@ bool Item_type_holder::join_types(THD *thd, Item *item) { if (decimals != NOT_FIXED_DEC) { - int delta1= max_length_orig - decimals_orig; - int delta2= item->max_length - item->decimals; - max_length= max(delta1, delta2) + decimals; - if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2) - { - max_length= FLT_DIG + 6; - decimals= NOT_FIXED_DEC; - } - if (fld_type == MYSQL_TYPE_DOUBLE && max_length > DBL_DIG + 2) + /* + For FLOAT(M,D)/DOUBLE(M,D) do not change precision + if both fields have the same M and D + */ + if (item->max_length != max_length_orig || + item->decimals != decimals_orig) { - max_length= DBL_DIG + 7; - decimals= NOT_FIXED_DEC; + int delta1= max_length_orig - decimals_orig; + int delta2= item->max_length - item->decimals; + max_length= max(delta1, delta2) + decimals; + if (fld_type == MYSQL_TYPE_FLOAT && max_length > FLT_DIG + 2) + { + max_length= MAX_FLOAT_STR_LENGTH; + decimals= NOT_FIXED_DEC; + } + else if (fld_type == MYSQL_TYPE_DOUBLE && max_length > DBL_DIG + 2) + { + max_length= MAX_DOUBLE_STR_LENGTH; + decimals= NOT_FIXED_DEC; + } } } else |