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

MDEV-18218 Assertion `0' failed in btr_page_reorganize_low upon DROP 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.
parent b13d356a
......@@ -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)'),
......@@ -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)'),
......@@ -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;
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
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