Skip to content

Commit

Permalink
bugfix: allow dropping a constraint and a column together
Browse files Browse the repository at this point in the history
post-fix for 04b288a
  • Loading branch information
vuvova committed Sep 18, 2017
1 parent 429ca9a commit 0757a1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions mysql-test/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
2 changes: 2 additions & 0 deletions mysql-test/t/alter_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0757a1b

Please sign in to comment.