Commit 30da40bb authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-18160/MDEV-18162 Assertion failure or crash after DROP COLUMN

dict_table_t::instant_column(): Correctly compute the value of
metadata_changed. The original computation in
commit 00372075 would essentially
invoke memcmp(x,x,y), which can only return 0.
parent 39a8caa5
......@@ -638,6 +638,16 @@ INSERT INTO t1 VALUES (1);
ALTER TABLE t1 ADD COLUMN b INT;
ALTER TABLE t1 MODIFY COLUMN a INT NULL;
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
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 (a INT PRIMARY KEY, b INT, c INT, d INT) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
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
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
......@@ -1222,6 +1232,16 @@ INSERT INTO t1 VALUES (1);
ALTER TABLE t1 ADD COLUMN b INT;
ALTER TABLE t1 MODIFY COLUMN a INT NULL;
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
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 (a INT PRIMARY KEY, b INT, c INT, d INT) ENGINE=InnoDB ROW_FORMAT=COMPACT;
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
(id INT PRIMARY KEY, c2 INT UNIQUE,
c3 POINT NOT NULL DEFAULT ST_GeomFromText('POINT(3 4)'),
......@@ -1806,10 +1826,20 @@ INSERT INTO t1 VALUES (1);
ALTER TABLE t1 ADD COLUMN b INT;
ALTER TABLE t1 MODIFY COLUMN a INT NULL;
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
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 (a INT PRIMARY KEY, b INT, c INT, d INT) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
disconnect analyze;
SELECT variable_value-@old_instant instants
FROM information_schema.global_status
WHERE variable_name = 'innodb_instant_alter_column';
instants
131
143
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
......@@ -522,6 +522,19 @@ ALTER TABLE t1 ADD COLUMN b INT;
ALTER TABLE t1 MODIFY COLUMN a INT NULL;
DROP TABLE t1;
# MDEV-18160/MDEV-18162 Failing assertion on ALTER
eval CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT) $engine;
INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
eval CREATE TABLE t1 (a INT PRIMARY KEY, b INT, c INT, d INT) $engine;
INSERT INTO t1 SET a=1;
ALTER TABLE t1 DROP c;
ALTER TABLE t1 DROP b, ADD v INT AS (a);
DROP TABLE t1;
dec $format;
}
disconnect analyze;
......
......@@ -645,15 +645,18 @@ inline bool dict_table_t::instant_column(const dict_table_t& table,
* sizeof *instant->dropped);
}
const field_map_element_t* field_map = old_instant
? old_instant->field_map : NULL;
init_instant<true>(table);
if (!metadata_changed) {
metadata_changed = !old_instant
|| memcmp(old_instant->field_map,
metadata_changed = !field_map
|| memcmp(field_map,
instant->field_map,
(index->n_fields
- index->first_user_field())
* sizeof *old_instant->field_map);
* sizeof *field_map);
}
}
......
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