Skip to content

Commit a5d9ec9

Browse files
author
Yasufumi Kinoshita
committed
Bug#36840107: mysql crash after update inplace in instant ddl redundant table
Updating newly added column's value for the older version row must not be "in place update", because the older row might not have even flags space for the new columns. This bug leads the updating newly added column's value for the older version row to be "in place update" wrongly. The reason is rec_get_instant_offset() doesn't treat NULL default value of the newly added columns as DEFAULT value. This fix adds REC_OFFS_DEFAULT bit for NULL default value at rec_get_instant_offset(). Change-Id: I109f4e2ff6836767eec710cca3851dcbe8dde972
1 parent 6d22681 commit a5d9ec9

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

mysql-test/suite/innodb/include/instant_add_column_debug.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ SHOW CREATE TABLE t1;
4848
SELECT * FROM t1;
4949

5050
DROP TABLE t1;
51+
52+
#
53+
# Bug#36840107 mysql crash after update inplace in instant ddl redundant table
54+
#
55+
--eval CREATE TABLE t1 (a INT, b INT) row_format=$row_format
56+
INSERT INTO t1 VALUES(0,0);
57+
ALTER TABLE t1 ADD COLUMN c varchar(25) DEFAULT NULL, ALGORITHM=INSTANT;
58+
UPDATE t1 SET c="" WHERE a=0;
59+
SELECT * FROM t1;
60+
DROP TABLE t1;

mysql-test/suite/innodb/r/instant_add_column_debug.result

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ a b d
3939
8 6 20
4040
10 1 10
4141
DROP TABLE t1;
42+
CREATE TABLE t1 (a INT, b INT) row_format=REDUNDANT;
43+
INSERT INTO t1 VALUES(0,0);
44+
ALTER TABLE t1 ADD COLUMN c varchar(25) DEFAULT NULL, ALGORITHM=INSTANT;
45+
UPDATE t1 SET c="" WHERE a=0;
46+
SELECT * FROM t1;
47+
a b c
48+
0 0
49+
DROP TABLE t1;
4250
############################################
4351
# Test instant ADD COLUMN for DYNAMIC format
4452
############################################
@@ -80,6 +88,14 @@ a b d
8088
8 6 20
8189
10 1 10
8290
DROP TABLE t1;
91+
CREATE TABLE t1 (a INT, b INT) row_format=DYNAMIC;
92+
INSERT INTO t1 VALUES(0,0);
93+
ALTER TABLE t1 ADD COLUMN c varchar(25) DEFAULT NULL, ALGORITHM=INSTANT;
94+
UPDATE t1 SET c="" WHERE a=0;
95+
SELECT * FROM t1;
96+
a b c
97+
0 0
98+
DROP TABLE t1;
8399
############################################
84100
# Test instant ADD COLUMN for COMPACT format
85101
############################################
@@ -121,3 +137,11 @@ a b d
121137
8 6 20
122138
10 1 10
123139
DROP TABLE t1;
140+
CREATE TABLE t1 (a INT, b INT) row_format=COMPACT;
141+
INSERT INTO t1 VALUES(0,0);
142+
ALTER TABLE t1 ADD COLUMN c varchar(25) DEFAULT NULL, ALGORITHM=INSTANT;
143+
UPDATE t1 SET c="" WHERE a=0;
144+
SELECT * FROM t1;
145+
a b c
146+
0 0
147+
DROP TABLE t1;

storage/innobase/rem/rec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static inline uint64_t rec_get_instant_offset(const dict_index_t *index,
507507
index->get_nth_default(n, &length);
508508

509509
if (length == UNIV_SQL_NULL) {
510-
return (offs | REC_OFFS_SQL_NULL);
510+
return (offs | REC_OFFS_DEFAULT | REC_OFFS_SQL_NULL);
511511
} else {
512512
return (offs | REC_OFFS_DEFAULT);
513513
}

0 commit comments

Comments
 (0)