mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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
This commit is contained in:
@ -1253,3 +1253,29 @@ id
|
||||
5
|
||||
99
|
||||
drop table t1;
|
||||
create table t1 (f1 decimal(60,25), f2 decimal(60,25));
|
||||
insert into t1 values (0.0,0.0);
|
||||
select f1 from t1 union all select f2 from t1;
|
||||
f1
|
||||
0.0000000000000000000000000
|
||||
0.0000000000000000000000000
|
||||
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
|
||||
union all
|
||||
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
|
||||
description f1
|
||||
XXXXXXXXXXXXXXXXXXXX 0.0000000000000000000000000
|
||||
YYYYYYYYYYYYYYYYYYYY 0.0000000000000000000000000
|
||||
drop table t1;
|
||||
create table t1 (f1 decimal(60,24), f2 decimal(60,24));
|
||||
insert into t1 values (0.0,0.0);
|
||||
select f1 from t1 union all select f2 from t1;
|
||||
f1
|
||||
0.000000000000000000000000
|
||||
0.000000000000000000000000
|
||||
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
|
||||
union all
|
||||
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
|
||||
description f1
|
||||
XXXXXXXXXXXXXXXXXXXX 0.000000000000000000000000
|
||||
YYYYYYYYYYYYYYYYYYYY 0.000000000000000000000000
|
||||
drop table t1;
|
||||
|
@ -756,4 +756,22 @@ select 99 union all select id from t1 order by 1;
|
||||
select id from t1 union all select 99 order by 1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #14216: UNION + DECIMAL wrong values in result
|
||||
#
|
||||
create table t1 (f1 decimal(60,25), f2 decimal(60,25));
|
||||
insert into t1 values (0.0,0.0);
|
||||
select f1 from t1 union all select f2 from t1;
|
||||
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
|
||||
union all
|
||||
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
|
||||
drop table t1;
|
||||
create table t1 (f1 decimal(60,24), f2 decimal(60,24));
|
||||
insert into t1 values (0.0,0.0);
|
||||
select f1 from t1 union all select f2 from t1;
|
||||
select 'XXXXXXXXXXXXXXXXXXXX' as description, f1 from t1
|
||||
union all
|
||||
select 'YYYYYYYYYYYYYYYYYYYY' as description, f2 from t1;
|
||||
drop table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
@ -3274,6 +3274,9 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
|
||||
{
|
||||
int delta1= max_length_orig - decimals_orig;
|
||||
int delta2= item->max_length - item->decimals;
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user