MDEV-17067 Server crash in write_block_record
Problem was that Create_field::create_length_to_internal_length() calculated a different pack_length for NEWDECIMAL compared to Field_new_decimal constructor which lead to some unused bytes in the middle of the record, which Aria didn't like.
This commit is contained in:
parent
f195286a3e
commit
490e220ad2
@ -1,4 +1,4 @@
|
||||
CREATE OR REPLACE TABLE t1 (
|
||||
CREATE OR REPLACE TABLE t1 (
|
||||
f1 DECIMAL(43,0) NOT NULL,
|
||||
f2 TIME(4) NULL,
|
||||
f3 BINARY(101) NULL,
|
||||
@ -24,3 +24,10 @@ INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
|
||||
Warnings:
|
||||
Note 1265 Data truncated for column 'f1' at row 1
|
||||
DROP TABLE t1;
|
||||
CREATE OR REPLACE TABLE t1 (a INT(45));
|
||||
INSERT IGNORE INTO t1 VALUES (1),(2);
|
||||
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
|
||||
select * from t2;
|
||||
f1 f2
|
||||
3 qux
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -29,3 +29,14 @@ CREATE OR REPLACE TABLE t1 (
|
||||
INSERT IGNORE INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12) VALUES
|
||||
(0.8,'16:01:46',NULL,'2006-03-01 12:44:34','2029-10-10 21:27:53','a','foo','1989-12-24','bar',9,1975,b'1');
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# MDEV-17067 Server crash in write_block_record
|
||||
#
|
||||
|
||||
CREATE OR REPLACE TABLE t1 (a INT(45));
|
||||
INSERT IGNORE INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE OR REPLACE TABLE t2 ENGINE=Aria AS SELECT SUM(a) AS f1, IFNULL( 'qux', ExtractValue( 'foo', 'bar' ) ) AS f2 FROM t1;
|
||||
select * from t2;
|
||||
DROP TABLE t1, t2;
|
||||
|
17
sql/field.cc
17
sql/field.cc
@ -9065,13 +9065,18 @@ void Create_field::create_length_to_internal_length(void)
|
||||
}
|
||||
break;
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
key_length= pack_length=
|
||||
my_decimal_get_binary_size(my_decimal_length_to_precision(length,
|
||||
decimals,
|
||||
flags &
|
||||
UNSIGNED_FLAG),
|
||||
decimals);
|
||||
{
|
||||
/*
|
||||
This code must be identical to code in
|
||||
Field_new_decimal::Field_new_decimal as otherwise the record layout
|
||||
gets out of sync.
|
||||
*/
|
||||
uint precision= my_decimal_length_to_precision(length, decimals,
|
||||
flags & UNSIGNED_FLAG);
|
||||
set_if_smaller(precision, DECIMAL_MAX_PRECISION);
|
||||
key_length= pack_length= my_decimal_get_binary_size(precision, decimals);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
key_length= pack_length= calc_pack_length(sql_type, length);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user