summaryrefslogtreecommitdiff
path: root/sql/my_decimal.h
diff options
context:
space:
mode:
authorunknown <iggy@amd64.(none)>2008-04-28 14:12:52 -0400
committerunknown <iggy@amd64.(none)>2008-04-28 14:12:52 -0400
commit525ecab12200f4d2ba78f4c419eb653315a5e805 (patch)
tree63adfa5e2dda4dbf457962e9944d16e000c562c6 /sql/my_decimal.h
parent28a089825771dc29a2ac12a2a805f269e5d2c4d2 (diff)
parent96e405b6627181b063bde4cdae98310a1abf9eab (diff)
downloadmariadb-git-525ecab12200f4d2ba78f4c419eb653315a5e805.tar.gz
Merge amd64.(none):/src/rel_clean_up/my50-rel_clean_up
into amd64.(none):/src/rel_clean_up/my51-rel_clean_up mysql-test/r/type_decimal.result: Auto merged mysql-test/t/type_decimal.test: Auto merged sql/my_decimal.h: Auto merged
Diffstat (limited to 'sql/my_decimal.h')
-rw-r--r--sql/my_decimal.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/my_decimal.h b/sql/my_decimal.h
index 1885036f42b..e73e0d4080d 100644
--- a/sql/my_decimal.h
+++ b/sql/my_decimal.h
@@ -169,14 +169,23 @@ inline int check_result_and_overflow(uint mask, int result, my_decimal *val)
inline uint my_decimal_length_to_precision(uint length, uint scale,
bool unsigned_flag)
{
- return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1));
+ /* Precision can't be negative thus ignore unsigned_flag when length is 0. */
+ DBUG_ASSERT(length || !scale);
+ return (uint) (length - (scale>0 ? 1:0) -
+ (unsigned_flag || !length ? 0:1));
}
inline uint32 my_decimal_precision_to_length(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);
set_if_smaller(precision, DECIMAL_MAX_PRECISION);
- return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1));
+ return (uint32)(precision + (scale>0 ? 1:0) +
+ (unsigned_flag || !precision ? 0:1));
}
inline