Commit 0757a1b3 authored by Sergei Golubchik's avatar Sergei Golubchik

bugfix: allow dropping a constraint and a column together

post-fix for 04b288ae
parent 429ca9a8
......@@ -2228,12 +2228,11 @@ alter table t1 drop column a;
ERROR 42S22: Unknown column 'a' in 'CHECK'
alter table t1 drop column b, add column b bigint first;
ERROR 42S22: Unknown column 'b' in 'CHECK'
alter table t1 drop column a, 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,
CONSTRAINT `CONSTRAINT_1` CHECK (`a` > `b`)
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int, b int, check(a>0));
......@@ -2265,12 +2264,11 @@ drop table t1;
create table t1 (a int, b int, c int, unique(a,b));
alter table t1 drop column a;
ERROR 42000: Key column 'a' doesn't exist in table
alter table t1 drop column a, drop index a;
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,
UNIQUE KEY `a` (`a`,`b`)
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
......@@ -1852,6 +1852,7 @@ create table t1 (a int, b int, check(a>b));
alter table t1 drop column a;
--error ER_BAD_FIELD_ERROR
alter table t1 drop column b, add column b bigint first;
alter table t1 drop column a, drop constraint constraint_1;
show create table t1;
drop table t1;
......@@ -1873,5 +1874,6 @@ drop table t1;
create table t1 (a int, b int, c int, unique(a,b));
--error ER_KEY_COLUMN_DOES_NOT_EXITS
alter table t1 drop column a;
alter table t1 drop column a, drop index a;
show create table t1;
drop table t1;
......@@ -8041,7 +8041,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
}
/* see if the constraint depends on *only* on dropped fields */
if (dropped_fields)
if (!drop && dropped_fields)
{
table->default_column_bitmaps();
bitmap_clear_all(table->read_set);
......
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