Merging
This commit is contained in:
commit
be0917049b
@ -229,3 +229,18 @@ create table t1 (s1 float(0,2));
|
|||||||
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
|
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
|
||||||
create table t1 (s1 float(1,2));
|
create table t1 (s1 float(1,2));
|
||||||
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
|
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 's1').
|
||||||
|
create table t1 (d double(10,1));
|
||||||
|
create table t2 (d double(10,9));
|
||||||
|
insert into t1 values ("100000000.0");
|
||||||
|
insert into t2 values ("1.23456780");
|
||||||
|
create table t3 select * from t2 union select * from t1;
|
||||||
|
select * from t3;
|
||||||
|
d
|
||||||
|
1.234567800
|
||||||
|
100000000.000000000
|
||||||
|
show create table t3;
|
||||||
|
Table Create Table
|
||||||
|
t3 CREATE TABLE `t3` (
|
||||||
|
`d` double(22,9) default NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
drop table t1, t2, t3;
|
||||||
|
@ -146,6 +146,19 @@ select * from t1 where reckey=109;
|
|||||||
select * from t1 where reckey=1.09E2;
|
select * from t1 where reckey=1.09E2;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #13372 (decimal union)
|
||||||
|
#
|
||||||
|
create table t1 (d double(10,1));
|
||||||
|
create table t2 (d double(10,9));
|
||||||
|
insert into t1 values ("100000000.0");
|
||||||
|
insert into t2 values ("1.23456780");
|
||||||
|
create table t3 select * from t2 union select * from t1;
|
||||||
|
select * from t3;
|
||||||
|
show create table t3;
|
||||||
|
drop table t1, t2, t3;
|
||||||
|
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
#
|
#
|
||||||
|
23
sql/item.cc
23
sql/item.cc
@ -5705,6 +5705,8 @@ enum_field_types Item_type_holder::get_real_type(Item *item)
|
|||||||
|
|
||||||
bool Item_type_holder::join_types(THD *thd, Item *item)
|
bool Item_type_holder::join_types(THD *thd, Item *item)
|
||||||
{
|
{
|
||||||
|
uint max_length_orig= max_length;
|
||||||
|
uint decimals_orig= decimals;
|
||||||
DBUG_ENTER("Item_type_holder::join_types");
|
DBUG_ENTER("Item_type_holder::join_types");
|
||||||
DBUG_PRINT("info:", ("was type %d len %d, dec %d name %s",
|
DBUG_PRINT("info:", ("was type %d len %d, dec %d name %s",
|
||||||
fld_type, max_length, decimals,
|
fld_type, max_length, decimals,
|
||||||
@ -5731,7 +5733,10 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
max_length= max(max_length, display_length(item));
|
max_length= max(max_length, display_length(item));
|
||||||
if (Field::result_merge_type(fld_type) == STRING_RESULT)
|
|
||||||
|
switch (Field::result_merge_type(fld_type))
|
||||||
|
{
|
||||||
|
case STRING_RESULT:
|
||||||
{
|
{
|
||||||
const char *old_cs, *old_derivation;
|
const char *old_cs, *old_derivation;
|
||||||
old_cs= collation.collation->name;
|
old_cs= collation.collation->name;
|
||||||
@ -5745,7 +5750,23 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
|
|||||||
"UNION");
|
"UNION");
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
case REAL_RESULT:
|
||||||
|
{
|
||||||
|
if (decimals != NOT_FIXED_DEC)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:;
|
||||||
|
};
|
||||||
maybe_null|= item->maybe_null;
|
maybe_null|= item->maybe_null;
|
||||||
get_full_info(item);
|
get_full_info(item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user