Commit 2dff8fec authored by Monty's avatar Monty

MDEV-15338 Crash in debug build when dropping column that is part of CHECK

Crash happened when deleting all columns that was part of a check constraint

The bug was that read map for from table was used when
checking CHECK constraint and was not properly reset
in copy_data_between_tables()
parent a107c79f
......@@ -52,3 +52,36 @@ connection default;
UNLOCK TABLES;
DROP TABLE t1;
disconnect con1;
#
# MDEV-15338
# Assertion `!table || (!table->read_set ||
# bitmap_is_set(table->read_set, field_index))'
# failed on dropping column with CHECK
#
CREATE TABLE t1 (a INT, b INT, CHECK (a>0)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,2),(3,4);
ALTER TABLE t1 DROP COLUMN a;
CREATE OR REPLACE TABLE t1 (a INT, b INT, CHECK (a>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b;
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b;
ERROR 42S22: Unknown column 'b' in 'CHECK'
ALTER TABLE t1 DROP COLUMN a, DROP COLUMN b;
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP CONSTRAINT `CONSTRAINT_1`;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b, DROP CONSTRAINT `CONSTRAINT_1`;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
......@@ -79,3 +79,27 @@ disconnect con1;
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
--echo #
--echo # MDEV-15338
--echo # Assertion `!table || (!table->read_set ||
--echo # bitmap_is_set(table->read_set, field_index))'
--echo # failed on dropping column with CHECK
--echo #
CREATE TABLE t1 (a INT, b INT, CHECK (a>0)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,2),(3,4);
ALTER TABLE t1 DROP COLUMN a;
CREATE OR REPLACE TABLE t1 (a INT, b INT, CHECK (a>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b;
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1 DROP COLUMN b;
ALTER TABLE t1 DROP COLUMN a, DROP COLUMN b;
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP CONSTRAINT `CONSTRAINT_1`;
SHOW CREATE TABLE t1;
CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
ALTER TABLE t1 DROP COLUMN b, DROP CONSTRAINT `CONSTRAINT_1`;
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -9844,6 +9844,11 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff);
/* Set read map for all fields in from table */
from->default_column_bitmaps();
bitmap_set_all(from->read_set);
from->file->column_bitmaps_signal();
/* We can abort alter table for any table type */
thd->abort_on_warning= !ignore && thd->is_strict_mode();
......
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