diff options
author | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-03-27 13:40:35 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@sun.com> | 2009-03-27 13:40:35 +0300 |
commit | 1b93843864c16cc98494c0c805828d142eb5065d (patch) | |
tree | 2443db07ded3aa10caee6e9992b00b054780063c /sql/item.cc | |
parent | 15baa13f84b9880eb9217a3c3b4f19c51bdfaf2d (diff) | |
parent | 0b60184b90cfb7ed1eb927e5106eb194677d43f7 (diff) | |
download | mariadb-git-1b93843864c16cc98494c0c805828d142eb5065d.tar.gz |
Manual merge.
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 28ace4b114d..8a6420ff14e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7105,18 +7105,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 |