Navigation Menu

Skip to content

Commit

Permalink
MDEV-18218 Assertion `0' failed in btr_page_reorganize_low upon DROP …
Browse files Browse the repository at this point in the history
…COLUMN

dict_table_t::init_instant(): Correctly initialize the length of
variable-length instantly dropped columns.

row_ins_index_entry_set_vals(): For variable-length instantly dropped
columns, write 0 bytes of data. For dropped fixed-length NOT NULL
columns, write the fixed length of NUL bytes as data.
  • Loading branch information
dr-m committed Jan 16, 2019
1 parent b13d356 commit edba047
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
23 changes: 22 additions & 1 deletion mysql-test/suite/innodb/r/instant_alter.result
Expand Up @@ -708,6 +708,13 @@ INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, b BLOB NOT NULL) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES (1,10,REPEAT('foobar',2000));
ALTER TABLE t1 DROP COLUMN b;
INSERT INTO t1 VALUES (2,20);
ALTER TABLE t1 ADD COLUMN vpk INT AS (pk);
ALTER TABLE t1 DROP COLUMN i;
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
Expand Down Expand Up @@ -1362,6 +1369,13 @@ INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, b BLOB NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES (1,10,REPEAT('foobar',2000));
ALTER TABLE t1 DROP COLUMN b;
INSERT INTO t1 VALUES (2,20);
ALTER TABLE t1 ADD COLUMN vpk INT AS (pk);
ALTER TABLE t1 DROP COLUMN i;
DROP TABLE t1;
CREATE TABLE t1
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
Expand Down Expand Up @@ -2016,10 +2030,17 @@ INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, b BLOB NOT NULL) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1 VALUES (1,10,REPEAT('foobar',2000));
ALTER TABLE t1 DROP COLUMN b;
INSERT INTO t1 VALUES (2,20);
ALTER TABLE t1 ADD COLUMN vpk INT AS (pk);
ALTER TABLE t1 DROP COLUMN i;
DROP TABLE t1;
disconnect analyze;
SELECT variable_value-@old_instant instants
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
149
155
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
11 changes: 11 additions & 0 deletions mysql-test/suite/innodb/t/instant_alter.test
Expand Up @@ -599,6 +599,17 @@ ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;

# MDEV-18218 Assertion `0' failed in btr_page_reorganize_low upon DROP COLUMN
eval CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, b BLOB NOT NULL) $engine;
INSERT INTO t1 VALUES (1,10,REPEAT('foobar',2000));
ALTER TABLE t1 DROP COLUMN b;
INSERT INTO t1 VALUES (2,20);
# this evicts and reloads the table definition until MDEV-17468 is fixed
ALTER TABLE t1 ADD COLUMN vpk INT AS (pk);
# this would load wrong metadata from the previous DROP COLUMN b, causing a crash
ALTER TABLE t1 DROP COLUMN i;
DROP TABLE t1;

dec $format;
}
disconnect analyze;
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/handler/handler0alter.cc
Expand Up @@ -199,7 +199,7 @@ inline void dict_table_t::init_instant(const dict_table_t& table)
}
field_map_it->set_ind(fixed_len
? uint16_t(fixed_len + 1)
: f.col->len > 255);
: DATA_BIG_COL(f.col));
field_map_it++;
ut_ad(f.col >= table.instant->dropped);
ut_ad(f.col < table.instant->dropped
Expand Down
3 changes: 2 additions & 1 deletion storage/innobase/row/row0ins.cc
Expand Up @@ -3462,8 +3462,9 @@ row_ins_index_entry_set_vals(
field->type.prtype = DATA_BINARY_TYPE;
} else {
ut_ad(col->len <= sizeof field_ref_zero);
ut_ad(ind_field->fixed_len <= col->len);
dfield_set_data(field, field_ref_zero,
col->len);
ind_field->fixed_len);
field->type.prtype = DATA_NOT_NULL;
}

Expand Down

0 comments on commit edba047

Please sign in to comment.