From 42155a35d1baadf047d80eeb4594c2c15cc17cad Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Oct 2005 18:12:57 -0700 Subject: 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 --- sql/item.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sql/item.cc') 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; -- cgit v1.2.1