From 0757a1b3e25f2fc6c70e0021ad118e83388271d7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 24 Aug 2017 14:05:32 +0200 Subject: [PATCH] bugfix: allow dropping a constraint and a column together post-fix for 04b288ae47d --- mysql-test/r/alter_table.result | 10 ++++------ mysql-test/t/alter_table.test | 2 ++ sql/sql_table.cc | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index f7f87b810ce..13fbe00f2e3 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -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; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index ca2f73db5ca..487990b61cd 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -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; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f838d59f1d1..8a68d86659a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -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);