Commit bec93d48 authored by ramil@ram-book.(none)'s avatar ramil@ram-book.(none)

fix for bug #4082: Integer lengths cause truncation with DISTINCT CONCAT and InnoDB

parent 6a476984
...@@ -413,7 +413,7 @@ explain t2; ...@@ -413,7 +413,7 @@ explain t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES NULL a int(11) YES NULL
b bigint(11) 0 b bigint(11) 0
c bigint(10) 0 c bigint(11) 0
d date YES NULL d date YES NULL
e char(1) e char(1)
f datetime YES NULL f datetime YES NULL
...@@ -432,11 +432,11 @@ Table Create Table ...@@ -432,11 +432,11 @@ Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`ifnull(a,a)` tinyint(4) default NULL, `ifnull(a,a)` tinyint(4) default NULL,
`ifnull(b,b)` smallint(6) default NULL, `ifnull(b,b)` smallint(6) default NULL,
`ifnull(c,c)` mediumint(9) default NULL, `ifnull(c,c)` mediumint(8) default NULL,
`ifnull(d,d)` int(11) default NULL, `ifnull(d,d)` int(11) default NULL,
`ifnull(e,e)` bigint(20) default NULL, `ifnull(e,e)` bigint(20) default NULL,
`ifnull(f,f)` float(3,2) default NULL, `ifnull(f,f)` float(24,2) default NULL,
`ifnull(g,g)` double(4,3) default NULL, `ifnull(g,g)` double(53,3) default NULL,
`ifnull(h,h)` decimal(5,4) default NULL, `ifnull(h,h)` decimal(5,4) default NULL,
`ifnull(i,i)` year(4) default NULL, `ifnull(i,i)` year(4) default NULL,
`ifnull(j,j)` date default NULL, `ifnull(j,j)` date default NULL,
......
...@@ -1637,3 +1637,9 @@ ERROR 42S21: Duplicate column name 'c1' ...@@ -1637,3 +1637,9 @@ ERROR 42S21: Duplicate column name 'c1'
alter table t1 add key (c1,c1,c2); alter table t1 add key (c1,c1,c2);
ERROR 42S21: Duplicate column name 'c1' ERROR 42S21: Duplicate column name 'c1'
drop table t1; drop table t1;
create table t1(a int(1) , b int(1)) engine=innodb;
insert into t1 values ('1111', '3333');
select distinct concat(a, b) from t1;
concat(a, b)
11113333
drop table t1;
...@@ -92,7 +92,7 @@ show create table t2; ...@@ -92,7 +92,7 @@ show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`col1` double default NULL, `col1` double default NULL,
`col2` double(22,5) default NULL, `col2` double(53,5) default NULL,
`col3` double default NULL, `col3` double default NULL,
`col4` double default NULL `col4` double default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
......
...@@ -1168,3 +1168,12 @@ alter table t1 add key (c1,c2,c1); ...@@ -1168,3 +1168,12 @@ alter table t1 add key (c1,c2,c1);
--error 1060 --error 1060
alter table t1 add key (c1,c1,c2); alter table t1 add key (c1,c1,c2);
drop table t1; drop table t1;
#
# Bug #4082: integer truncation
#
create table t1(a int(1) , b int(1)) engine=innodb;
insert into t1 values ('1111', '3333');
select distinct concat(a, b) from t1;
drop table t1;
...@@ -554,7 +554,7 @@ void Item_field::set_field(Field *field_par) ...@@ -554,7 +554,7 @@ void Item_field::set_field(Field *field_par)
{ {
field=result_field=field_par; // for easy coding with fields field=result_field=field_par; // for easy coding with fields
maybe_null=field->maybe_null(); maybe_null=field->maybe_null();
max_length=field_par->field_length; max_length=field_par->max_length();
decimals= field->decimals(); decimals= field->decimals();
table_name=field_par->table_name; table_name=field_par->table_name;
field_name=field_par->field_name; field_name=field_par->field_name;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment