Skip to content

Commit 177c191

Browse files
committed
MDEV-11606 Server crashes in mi_make_key / sort_key_read
Problem was that one internal record buffer in MYISAM was not big enough to handle virtual fields. Fixed by extending buffer. Fixed test case to 79 characters
1 parent c9b3e45 commit 177c191

File tree

4 files changed

+351
-167
lines changed

4 files changed

+351
-167
lines changed

mysql-test/suite/vcol/r/vcol_keys_myisam.result

Lines changed: 154 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,3 @@
1-
create table t1 (a int, b int as (a+1), c int, index(b));
2-
insert t1 (a,c) values (0x7890abcd, 0x76543210);
3-
insert t1 (a,c) select seq, sin(seq)*10000 from seq_1_to_1000;
4-
explain select * from t1 where b=10;
5-
id select_type table type possible_keys key key_len ref rows Extra
6-
1 SIMPLE t1 ref b b 5 const 1
7-
select * from t1 where b=10;
8-
a b c
9-
9 10 4121
10-
11-
MyISAM file: datadir/test/t1
12-
Record format: Fixed length
13-
Character set: latin1_swedish_ci (8)
14-
Data records: 1001 Deleted blocks: 0
15-
Recordlength: 9
16-
17-
table description:
18-
Key Start Len Index Type
19-
1 10 4 multip. long NULL
20-
update t1 set a=20 where b=10;
21-
select * from t1 where b=10;
22-
a b c
23-
select * from t1 where b=21;
24-
a b c
25-
20 21 4121
26-
20 21 9129
27-
delete from t1 where b=21;
28-
select * from t1 where b=21;
29-
a b c
30-
alter table t1 add column d char(20) as (concat(a,c));
31-
select * from t1 where b=11;
32-
a b c d
33-
10 11 -5440 10-5440
34-
create index i on t1 (d);
35-
check table t1;
36-
Table Op Msg_type Msg_text
37-
test.t1 check status OK
38-
select * from t1 where b=11;
39-
a b c d
40-
10 11 -5440 10-5440
41-
check table t1 quick;
42-
Table Op Msg_type Msg_text
43-
test.t1 check status OK
44-
select * from t1 where b=11;
45-
a b c d
46-
10 11 -5440 10-5440
47-
check table t1 medium;
48-
Table Op Msg_type Msg_text
49-
test.t1 check status OK
50-
select * from t1 where b=11;
51-
a b c d
52-
10 11 -5440 10-5440
53-
check table t1 extended;
54-
Table Op Msg_type Msg_text
55-
test.t1 check status OK
56-
show keys from t1;
57-
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
58-
t1 1 b 1 b A 999 NULL NULL YES BTREE
59-
t1 1 i 1 d A 999 NULL NULL YES BTREE
60-
select * from t1 where b=11;
61-
a b c d
62-
10 11 -5440 10-5440
63-
delete from t1 where b=12;
64-
analyze table t1;
65-
Table Op Msg_type Msg_text
66-
test.t1 analyze status OK
67-
show keys from t1;
68-
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
69-
t1 1 b 1 b A 998 NULL NULL YES BTREE
70-
t1 1 i 1 d A 998 NULL NULL YES BTREE
71-
select * from t1 where b=11;
72-
a b c d
73-
10 11 -5440 10-5440
74-
optimize table t1;
75-
Table Op Msg_type Msg_text
76-
test.t1 optimize status OK
77-
show keys from t1;
78-
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
79-
t1 1 b 1 b A 998 NULL NULL YES BTREE
80-
t1 1 i 1 d A 998 NULL NULL YES BTREE
81-
select * from t1 where b=11;
82-
a b c d
83-
10 11 -5440 10-5440
84-
repair table t1;
85-
Table Op Msg_type Msg_text
86-
test.t1 repair status OK
87-
select * from t1 where b=11;
88-
a b c d
89-
10 11 -5440 10-5440
90-
repair table t1 quick;
91-
Table Op Msg_type Msg_text
92-
test.t1 repair status OK
93-
select * from t1 where b=11;
94-
a b c d
95-
10 11 -5440 10-5440
96-
repair table t1 extended;
97-
Table Op Msg_type Msg_text
98-
test.t1 repair status OK
99-
select * from t1 where b=11;
100-
a b c d
101-
10 11 -5440 10-5440
102-
repair table t1 use_frm;
103-
Table Op Msg_type Msg_text
104-
test.t1 repair warning Number of rows changed from 0 to 998
105-
test.t1 repair status OK
106-
select * from t1 where b=11;
107-
a b c d
108-
10 11 -5440 10-5440
109-
update t1 set a=30 where b=11;
110-
select * from t1 where b=11;
111-
a b c d
112-
select * from t1 where b=31;
113-
a b c d
114-
30 31 -5440 30-5440
115-
30 31 -9880 30-9880
116-
drop table t1;
1171
SET @@session.storage_engine = 'MyISAM';
1182
# - UNIQUE KEY
1193
# - INDEX
@@ -325,3 +209,157 @@ INDEX(vc(32))
325209
);
326210
DELETE FROM t1 WHERE vc IS NULL ORDER BY pk;
327211
DROP TABLE t1;
212+
#
213+
# Original test
214+
#
215+
create table t1 (a int, b int as (a+1), c int, index(b));
216+
insert t1 (a,c) values (0x7890abcd, 0x76543210);
217+
insert t1 (a,c) select seq, sin(seq)*10000 from seq_1_to_1000;
218+
explain select * from t1 where b=10;
219+
id select_type table type possible_keys key key_len ref rows Extra
220+
1 SIMPLE t1 ref b b 5 const 1
221+
select * from t1 where b=10;
222+
a b c
223+
9 10 4121
224+
225+
MyISAM file: datadir/test/t1
226+
Record format: Fixed length
227+
Character set: latin1_swedish_ci (8)
228+
Data records: 1001 Deleted blocks: 0
229+
Recordlength: 9
230+
231+
table description:
232+
Key Start Len Index Type
233+
1 10 4 multip. long NULL
234+
update t1 set a=20 where b=10;
235+
select * from t1 where b=10;
236+
a b c
237+
select * from t1 where b=21;
238+
a b c
239+
20 21 4121
240+
20 21 9129
241+
delete from t1 where b=21;
242+
select * from t1 where b=21;
243+
a b c
244+
alter table t1 add column d char(20) as (concat(a,c));
245+
select * from t1 where b=11;
246+
a b c d
247+
10 11 -5440 10-5440
248+
create index i on t1 (d);
249+
check table t1;
250+
Table Op Msg_type Msg_text
251+
test.t1 check status OK
252+
select * from t1 where b=11;
253+
a b c d
254+
10 11 -5440 10-5440
255+
check table t1 quick;
256+
Table Op Msg_type Msg_text
257+
test.t1 check status OK
258+
select * from t1 where b=11;
259+
a b c d
260+
10 11 -5440 10-5440
261+
check table t1 medium;
262+
Table Op Msg_type Msg_text
263+
test.t1 check status OK
264+
select * from t1 where b=11;
265+
a b c d
266+
10 11 -5440 10-5440
267+
check table t1 extended;
268+
Table Op Msg_type Msg_text
269+
test.t1 check status OK
270+
show keys from t1;
271+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
272+
t1 1 b 1 b A 999 NULL NULL YES BTREE
273+
t1 1 i 1 d A 999 NULL NULL YES BTREE
274+
select * from t1 where b=11;
275+
a b c d
276+
10 11 -5440 10-5440
277+
delete from t1 where b=12;
278+
analyze table t1;
279+
Table Op Msg_type Msg_text
280+
test.t1 analyze status OK
281+
show keys from t1;
282+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
283+
t1 1 b 1 b A 998 NULL NULL YES BTREE
284+
t1 1 i 1 d A 998 NULL NULL YES BTREE
285+
select * from t1 where b=11;
286+
a b c d
287+
10 11 -5440 10-5440
288+
optimize table t1;
289+
Table Op Msg_type Msg_text
290+
test.t1 optimize status OK
291+
show keys from t1;
292+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
293+
t1 1 b 1 b A 998 NULL NULL YES BTREE
294+
t1 1 i 1 d A 998 NULL NULL YES BTREE
295+
select * from t1 where b=11;
296+
a b c d
297+
10 11 -5440 10-5440
298+
repair table t1;
299+
Table Op Msg_type Msg_text
300+
test.t1 repair status OK
301+
select * from t1 where b=11;
302+
a b c d
303+
10 11 -5440 10-5440
304+
repair table t1 quick;
305+
Table Op Msg_type Msg_text
306+
test.t1 repair status OK
307+
select * from t1 where b=11;
308+
a b c d
309+
10 11 -5440 10-5440
310+
repair table t1 extended;
311+
Table Op Msg_type Msg_text
312+
test.t1 repair status OK
313+
select * from t1 where b=11;
314+
a b c d
315+
10 11 -5440 10-5440
316+
repair table t1 use_frm;
317+
Table Op Msg_type Msg_text
318+
test.t1 repair warning Number of rows changed from 0 to 998
319+
test.t1 repair status OK
320+
select * from t1 where b=11;
321+
a b c d
322+
10 11 -5440 10-5440
323+
update t1 set a=30 where b=11;
324+
select * from t1 where b=11;
325+
a b c d
326+
select * from t1 where b=31;
327+
a b c d
328+
30 31 -5440 30-5440
329+
30 31 -9880 30-9880
330+
drop table t1;
331+
#
332+
# MDEV-11606 Server crashes in mi_make_key / sort_key_read
333+
#
334+
CREATE TABLE t1 (
335+
pk BIGINT AUTO_INCREMENT,
336+
col_date DATE NULL,
337+
col_datetime DATETIME(1) NULL,
338+
col_int TINYINT(13) UNSIGNED ZEROFILL NULL,
339+
col_varchar VARBINARY(2222) NULL,
340+
col_timestamp TIMESTAMP(2) NULL,
341+
col_bit BIT(64) NOT NULL DEFAULT 0,
342+
col_blob MEDIUMBLOB NULL,
343+
col_dec DECIMAL(10,9) ZEROFILL NOT NULL DEFAULT 0,
344+
col_time TIME(4) NULL,
345+
col_year YEAR NOT NULL DEFAULT '1970',
346+
col_char CHAR(129) NULL,
347+
col_enum SET('','a','b','c','d','e','f','foo','bar') NULL,
348+
vcol_dec DECIMAL(50,18) ZEROFILL AS (col_dec) VIRTUAL,
349+
vcol_bit BIT(48) AS (col_bit) VIRTUAL,
350+
vcol_char CHAR(224) AS (col_char) VIRTUAL,
351+
vcol_datetime DATETIME(4) AS (col_datetime) VIRTUAL,
352+
vcol_year YEAR AS (col_year) VIRTUAL,
353+
vcol_varchar VARBINARY(356) AS (col_varchar) VIRTUAL,
354+
vcol_blob MEDIUMBLOB AS (col_blob) VIRTUAL,
355+
vcol_timestamp TIMESTAMP(5) AS (col_timestamp) VIRTUAL,
356+
vcol_int BIGINT(46) AS (col_int) VIRTUAL,
357+
vcol_time TIME(1) AS (col_time) VIRTUAL,
358+
vcol_date DATE AS (col_date) VIRTUAL,
359+
vcol_enum SET('','a','b','c','d','e','f','foo','bar') AS (col_enum) VIRTUAL,
360+
UNIQUE(pk),
361+
PRIMARY KEY(pk)
362+
) ENGINE=MyISAM;
363+
ALTER TABLE t1 ADD INDEX(col_enum,vcol_int);
364+
ALTER TABLE t1 ADD INDEX(col_year);
365+
DROP TABLE t1;

0 commit comments

Comments
 (0)