Commit d82386b6 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-24848 Assertion rlen<llen failed when applying MEMSET

btr_cur_upd_rec_in_place(): Prefer WRITE to MEMSET for a single-byte
operation.

log_phys_t::apply(): Relax the assertion to allow a single-byte MEMSET,
even though it is 1 byte longer than a WRITE record.
parent fc5e03f0
CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB
ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES (1,2021),(2,21),(3,0);
UPDATE t1 SET a = NULL;
# shutdown server
# remove datadir
# xtrabackup move back
# restart
SELECT * FROM t1;
pk a
1 NULL
2 NULL
3 NULL
DROP TABLE t1;
--source include/have_innodb.inc
--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup
CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB
ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES (1,2021),(2,21),(3,0);
UPDATE t1 SET a = NULL;
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
exec $XTRABACKUP --prepare --verbose --target-dir=$targetdir;
--source include/restart_and_restore.inc
rmdir $targetdir;
SELECT * FROM t1;
DROP TABLE t1;
......@@ -3,7 +3,7 @@
Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2015, 2020, MariaDB Corporation.
Copyright (c) 2015, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -4149,7 +4149,16 @@ void btr_cur_upd_rec_in_place(rec_t *rec, const dict_index_t *index,
}
ut_ad(!index->table->not_redundant());
if (ulint size = rec_get_nth_field_size(rec, n)) {
switch (ulint size = rec_get_nth_field_size(rec, n)) {
case 0:
break;
case 1:
mtr->write<1,mtr_t::MAYBE_NOP>(
*block,
rec_get_field_start_offs(rec, n) + rec,
0U);
break;
default:
mtr->memset(
block,
page_offset(rec_get_field_start_offs(
......
......@@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2020, MariaDB Corporation.
Copyright (c) 2013, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -490,7 +490,7 @@ struct log_phys_t : public log_rec_t
llen= len;
if ((b & 0x70) == MEMSET)
{
ut_ad(rlen < llen);
ut_ad(rlen <= llen);
if (UNIV_UNLIKELY(rlen != 1))
{
size_t s;
......@@ -499,7 +499,7 @@ struct log_phys_t : public log_rec_t
memcpy(frame + last_offset + s, l, llen - s);
}
else
memset(frame + last_offset, *l, llen);
memset(frame + last_offset, *l, llen);
goto next_after_applying_write;
}
const size_t slen= mlog_decode_varint_length(*l);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment