Commit 41fe972d authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-21744 Assertion `!rec_offs_nth_sql_null(offsets, n)' failed

commit 08ba3887 of MDEV-12353
introduced an incorrect assumption, which was documented by
the failing assertion.

After instant ADD COLUMN, we can have a null (and in-place) UPDATE
of NULL to NULL. No data needs to be written for such updates.

For ROW_FORMAT=REDUNDANT, we reserve space for the NULL values,
and to be compatible with existing behaviour, we will zerofill
the unused data bytes when updating to NULL value.
parent 055ce75d
...@@ -318,8 +318,8 @@ ...@@ -318,8 +318,8 @@
FROM information_schema.global_status FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column'; WHERE variable_name = 'innodb_instant_alter_column';
instants instants
-199 -202
+201 +204
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
# #
# MDEV-18266: Changing an index comment unnecessarily rebuilds index # MDEV-18266: Changing an index comment unnecessarily rebuilds index
...@@ -935,6 +935,18 @@ DROP TABLE t1; ...@@ -935,6 +935,18 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT; CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
ALTER TABLE t1 MODIFY b INT FIRST; ALTER TABLE t1 MODIFY b INT FIRST;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
INSERT INTO t1 SET pk=1;
ALTER TABLE t1 ADD COLUMN b INT;
BEGIN;
UPDATE t1 SET pk=2;
UPDATE t1 SET pk=1;
connection analyze;
SELECT * FROM t1;
pk b
1 NULL
connection default;
DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE, (id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'), c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
...@@ -1815,6 +1827,18 @@ DROP TABLE t1; ...@@ -1815,6 +1827,18 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=COMPACT; CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
ALTER TABLE t1 MODIFY b INT FIRST; ALTER TABLE t1 MODIFY b INT FIRST;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 SET pk=1;
ALTER TABLE t1 ADD COLUMN b INT;
BEGIN;
UPDATE t1 SET pk=2;
UPDATE t1 SET pk=1;
connection analyze;
SELECT * FROM t1;
pk b
1 NULL
connection default;
DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE, (id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'), c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
...@@ -2695,12 +2719,24 @@ DROP TABLE t1; ...@@ -2695,12 +2719,24 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ALTER TABLE t1 MODIFY b INT FIRST; ALTER TABLE t1 MODIFY b INT FIRST;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1 SET pk=1;
ALTER TABLE t1 ADD COLUMN b INT;
BEGIN;
UPDATE t1 SET pk=2;
UPDATE t1 SET pk=1;
connection analyze;
SELECT * FROM t1;
pk b
1 NULL
connection default;
DROP TABLE t1;
disconnect analyze; disconnect analyze;
SELECT variable_value-@old_instant instants SELECT variable_value-@old_instant instants
FROM information_schema.global_status FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column'; WHERE variable_name = 'innodb_instant_alter_column';
instants instants
199 202
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
# #
# MDEV-18266: Changing an index comment unnecessarily rebuilds index # MDEV-18266: Changing an index comment unnecessarily rebuilds index
......
...@@ -830,6 +830,18 @@ eval CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) $engine; ...@@ -830,6 +830,18 @@ eval CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a,b)) $engine;
ALTER TABLE t1 MODIFY b INT FIRST; ALTER TABLE t1 MODIFY b INT FIRST;
DROP TABLE t1; DROP TABLE t1;
# MDEV-21744 Assertion `!rec_offs_nth_sql_null(offsets, n)' failed
eval CREATE TABLE t1 (pk INT PRIMARY KEY) $engine;
INSERT INTO t1 SET pk=1;
ALTER TABLE t1 ADD COLUMN b INT;
BEGIN;
UPDATE t1 SET pk=2;
UPDATE t1 SET pk=1;
connection analyze;
SELECT * FROM t1;
connection default;
DROP TABLE t1;
dec $format; dec $format;
let $redundant_4k= 0; let $redundant_4k= 0;
} }
......
...@@ -4136,7 +4136,12 @@ void btr_cur_upd_rec_in_place(rec_t *rec, const dict_index_t *index, ...@@ -4136,7 +4136,12 @@ void btr_cur_upd_rec_in_place(rec_t *rec, const dict_index_t *index,
ut_ad(!rec_offs_nth_default(offsets, n)); ut_ad(!rec_offs_nth_default(offsets, n));
if (UNIV_UNLIKELY(dfield_is_null(&uf->new_val))) { if (UNIV_UNLIKELY(dfield_is_null(&uf->new_val))) {
ut_ad(!rec_offs_nth_sql_null(offsets, n)); if (rec_offs_nth_sql_null(offsets, n)) {
ut_ad(index->table->is_instant());
ut_ad(n >= index->n_core_fields);
continue;
}
ut_ad(!index->table->not_redundant()); ut_ad(!index->table->not_redundant());
if (ulint size = rec_get_nth_field_size(rec, n)) { if (ulint size = rec_get_nth_field_size(rec, n)) {
mtr->memset( mtr->memset(
......
...@@ -2411,7 +2411,11 @@ trx_undo_prev_version_build( ...@@ -2411,7 +2411,11 @@ trx_undo_prev_version_build(
ut_ad(!rec_offs_nth_default(offsets, n)); ut_ad(!rec_offs_nth_default(offsets, n));
if (UNIV_UNLIKELY(dfield_is_null(&uf->new_val))) { if (UNIV_UNLIKELY(dfield_is_null(&uf->new_val))) {
ut_ad(!rec_offs_nth_sql_null(offsets, n)); if (rec_offs_nth_sql_null(offsets, n)) {
ut_ad(index->table->is_instant());
ut_ad(n >= index->n_core_fields);
continue;
}
ut_ad(!index->table->not_redundant()); ut_ad(!index->table->not_redundant());
ulint l = rec_get_1byte_offs_flag(*old_vers) ulint l = rec_get_1byte_offs_flag(*old_vers)
? (n + 1) : (n + 1) * 2; ? (n + 1) : (n + 1) * 2;
......
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