diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-07-03 14:36:04 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-07-03 14:36:04 +0400 |
commit | 2d4df13ef28f4d5f0fbb67d570bfce9c1ebe1881 (patch) | |
tree | 06e2ea011ccd6c53fc3aca4b2248b33e484509e3 /sql/my_decimal.h | |
parent | e2ac8c07bdd2e58f5f7b4919a76a0d1881f3ed5e (diff) | |
parent | 096c12b2c42b83d879314276fe6471edf8c61fd0 (diff) | |
download | mariadb-git-2d4df13ef28f4d5f0fbb67d570bfce9c1ebe1881.tar.gz |
Manual merge.
Diffstat (limited to 'sql/my_decimal.h')
-rw-r--r-- | sql/my_decimal.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 0e79f70ab4e..21669e82c44 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -183,6 +183,19 @@ inline uint my_decimal_length_to_precision(uint length, uint scale, (unsigned_flag || !length ? 0:1)); } +inline uint32 my_decimal_precision_to_length_no_truncation(uint precision, + uint8 scale, + bool unsigned_flag) +{ + /* + When precision is 0 it means that original length was also 0. Thus + unsigned_flag is ignored in this case. + */ + DBUG_ASSERT(precision || !scale); + return (uint32)(precision + (scale > 0 ? 1 : 0) + + (unsigned_flag || !precision ? 0 : 1)); +} + inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, bool unsigned_flag) { @@ -192,8 +205,8 @@ inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, */ DBUG_ASSERT(precision || !scale); set_if_smaller(precision, DECIMAL_MAX_PRECISION); - return (uint32)(precision + (scale>0 ? 1:0) + - (unsigned_flag || !precision ? 0:1)); + return my_decimal_precision_to_length_no_truncation(precision, scale, + unsigned_flag); } inline |