diff options
author | unknown <jimw@mysql.com> | 2005-10-28 18:12:57 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-10-28 18:12:57 -0700 |
commit | 42155a35d1baadf047d80eeb4594c2c15cc17cad (patch) | |
tree | 0ecd7190c09834d899b776fddb2abdee55622205 /sql/item.cc | |
parent | 5a9dc44dac8658448c81fc1203aa4355af03463b (diff) | |
download | mariadb-git-42155a35d1baadf047d80eeb4594c2c15cc17cad.tar.gz |
Fix bug in handling of decimal fields in UNION statements that could
cause a crash or write to an incorrect memory location. (Bug #14216)
mysql-test/r/union.result:
Update results
mysql-test/t/union.test:
Add regression test
sql/item.cc:
Set max_length for decimal fields correctly
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/item.cc b/sql/item.cc index 642a0ccf1b4..56f0beeeb44 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3274,8 +3274,11 @@ bool Item_type_holder::join_types(THD *thd, Item *item) { 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); + if (fld_type == MYSQL_TYPE_DECIMAL) + max_length= max(delta1, delta2) + decimals; + else + 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; |