mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed bug#12185: Data type aggregation may produce wrong result
The Item::tmp_table_field_from_field_type() function creates Field_datetime object instead of Field_timestamp object for timestamp field thus always changing data type is a tmp table is used. The Field_blob object constructor which is used in the Item::tmp_table_field_from_field_type() is always setting packlength field of newly created blob to 4. This leads to changing fields data type for example from the blob to the longblob if a temporary table is used. The Item::make_string_field() function always converts Field_string objects to Field_varstring objects. This leads to changing data type from the char/binary to varchar/varbinary. Added appropriate Field_timestamp object constructor for using in the Item::tmp_table_field_from_field_type() function. Added Field_blob object constructor which sets pack length according to max_length argument. The Item::tmp_table_field_from_field_type() function now creates Field_timestamp object for a timestamp field. The Item_type_holder::display_length() now returns correct NULL length NULL length. The Item::make_string_field() function now doesn't change Field_string to Field_varstring in the case of Item_type_holder. The Item::tmp_table_field_from_field_type() function now uses the Field_blob constructor which sets packlength according to max_length.
This commit is contained in:
@ -1473,8 +1473,8 @@ Error 1146 Table 'test.t4' doesn't exist
|
||||
drop table t1,t2,t3;
|
||||
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
|
||||
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
|
||||
select name2 from t1 union all select name from t1 union all select id from t1;
|
||||
name2
|
||||
select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
|
||||
trim(name2)
|
||||
fff
|
||||
sss
|
||||
ttt
|
||||
|
Reference in New Issue
Block a user