Skip to content

Commit a145442

Browse files
committed
MDEV-21045 AddressSanitizer: use-after-poison in mem_heap_dup / row_log_table_get_pk_col
row_log_table_get_pk_col(): read instant field value from instant alter table when it's required.
1 parent 24a279b commit a145442

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,21 @@ a b vb
264264
5 NULL NULL
265265
DROP TABLE t1;
266266
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
267+
#
268+
# MDEV-21045 AddressSanitizer: use-after-poison in mem_heap_dup / row_log_table_get_pk_col
269+
#
270+
CREATE TABLE t1 (a TEXT) ENGINE = InnoDB ROW_FORMAT=REDUNDANT;
271+
INSERT INTO t1 (a) VALUES ('foo');
272+
ALTER TABLE t1 ADD COLUMN b INT DEFAULT 0,algorithm=instant;
273+
connect con2,localhost,root,,test;
274+
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL onlinealter WAIT_FOR update';
275+
ALTER TABLE t1 ADD PRIMARY KEY (b);
276+
connection default;
277+
SET DEBUG_SYNC='now WAIT_FOR onlinealter';
278+
UPDATE t1 SET b = 1;
279+
SET DEBUG_SYNC='now SIGNAL update';
280+
connection con2;
281+
connection default;
282+
SET DEBUG_SYNC='RESET';
283+
disconnect con2;
284+
DROP TABLE t1;

mysql-test/suite/innodb/t/instant_alter_debug.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,29 @@ SELECT * FROM t1;
293293
DROP TABLE t1;
294294

295295
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
296+
297+
--echo #
298+
--echo # MDEV-21045 AddressSanitizer: use-after-poison in mem_heap_dup / row_log_table_get_pk_col
299+
--echo #
300+
CREATE TABLE t1 (a TEXT) ENGINE = InnoDB ROW_FORMAT=REDUNDANT;
301+
INSERT INTO t1 (a) VALUES ('foo');
302+
303+
ALTER TABLE t1 ADD COLUMN b INT DEFAULT 0,algorithm=instant;
304+
305+
--connect (con2,localhost,root,,test)
306+
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL onlinealter WAIT_FOR update';
307+
--send
308+
ALTER TABLE t1 ADD PRIMARY KEY (b);
309+
310+
--connection default
311+
SET DEBUG_SYNC='now WAIT_FOR onlinealter';
312+
UPDATE t1 SET b = 1;
313+
SET DEBUG_SYNC='now SIGNAL update';
314+
315+
--connection con2
316+
--reap
317+
318+
--connection default
319+
SET DEBUG_SYNC='RESET';
320+
--disconnect con2
321+
DROP TABLE t1;

storage/innobase/row/row0log.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,10 @@ row_log_table_get_pk_col(
11641164

11651165
field = rec_get_nth_field(rec, offsets, i, &len);
11661166

1167+
if (len == UNIV_SQL_DEFAULT) {
1168+
field = log->instant_field_value(i, &len);
1169+
}
1170+
11671171
if (len == UNIV_SQL_NULL) {
11681172
if (!log->allow_not_null) {
11691173
return(DB_INVALID_NULL);

0 commit comments

Comments
 (0)