Skip to content

Commit 0da39ca

Browse files
committed
fix BIGINT+MEDIUMINT type aggregation
1 parent 347eeef commit 0da39ca

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

mysql-test/r/type_uint.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@ this
1414
0
1515
4294967295
1616
drop table t1;
17+
create table t1 (a bigint unsigned, b mediumint unsigned);
18+
insert t1 values (1,2),(0xffffffffffffffff,0xffffff);
19+
select coalesce(a,b), coalesce(b,a) from t1;
20+
coalesce(a,b) coalesce(b,a)
21+
1 2
22+
18446744073709551615 16777215
23+
create table t2 as select a from t1 union select b from t1;
24+
show create table t2;
25+
Table Create Table
26+
t2 CREATE TABLE `t2` (
27+
`a` bigint(20) unsigned DEFAULT NULL
28+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
29+
select * from t2;
30+
a
31+
1
32+
18446744073709551615
33+
2
34+
16777215
35+
drop table t1, t2;

mysql-test/t/type_uint.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ select * from t1;
1515
drop table t1;
1616

1717
# End of 4.1 tests
18+
19+
create table t1 (a bigint unsigned, b mediumint unsigned);
20+
insert t1 values (1,2),(0xffffffffffffffff,0xffffff);
21+
select coalesce(a,b), coalesce(b,a) from t1;
22+
create table t2 as select a from t1 union select b from t1;
23+
show create table t2;
24+
select * from t2;
25+
drop table t1, t2;

sql/field.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static enum_field_types field_types_merge_rules [FIELDTYPE_NUM][FIELDTYPE_NUM]=
359359
//MYSQL_TYPE_NULL MYSQL_TYPE_TIMESTAMP
360360
MYSQL_TYPE_LONGLONG, MYSQL_TYPE_VARCHAR,
361361
//MYSQL_TYPE_LONGLONG MYSQL_TYPE_INT24
362-
MYSQL_TYPE_LONGLONG, MYSQL_TYPE_LONG,
362+
MYSQL_TYPE_LONGLONG, MYSQL_TYPE_LONGLONG,
363363
//MYSQL_TYPE_DATE MYSQL_TYPE_TIME
364364
MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VARCHAR,
365365
//MYSQL_TYPE_DATETIME MYSQL_TYPE_YEAR

0 commit comments

Comments
 (0)