From 5c764a0eb82c87ace0df9744922f27229a7e212a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 2 Jul 2016 14:52:20 +0200 Subject: [PATCH] clarify ER_CANT_DROP_FIELD_OR_KEY include the dropped object type --- .../extra/rpl_tests/rpl_extra_col_master.test | 2 +- mysql-test/r/alter_table.result | 20 ++++----- mysql-test/r/check_constraint.result | 2 +- mysql-test/r/create_drop_binlog.result | 2 +- mysql-test/r/create_drop_index.result | 2 +- mysql-test/r/key.result | 2 +- .../engines/funcs/r/ix_drop_error.result | 2 +- mysql-test/suite/innodb/r/innodb-index.result | 4 +- .../rpl/r/rpl_extra_col_master_innodb.result | 2 +- .../rpl/r/rpl_extra_col_master_myisam.result | 2 +- sql/share/errmsg-utf8.txt | 44 +++++++++---------- sql/sql_class.h | 6 +++ sql/sql_table.cc | 10 +---- .../mysql-test/connect/r/xml_mdev5261.result | 4 +- storage/innobase/handler/handler0alter.cc | 2 +- .../rpl/r/rpl_extra_col_master_tokudb.result | 2 +- storage/xtradb/handler/handler0alter.cc | 2 +- 17 files changed, 54 insertions(+), 56 deletions(-) diff --git a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test index b438ebd24f9..0559e93676b 100644 --- a/mysql-test/extra/rpl_tests/rpl_extra_col_master.test +++ b/mysql-test/extra/rpl_tests/rpl_extra_col_master.test @@ -126,7 +126,7 @@ SELECT f1,f2,f3,f4,f5,f6,f7,f8,f9, --disable_query_log call mtr.add_suppression("Slave SQL.*Table definition on master and slave does not match: Column 2 type mismatch.* 1535"); -call mtr.add_suppression("Slave.*Can.t DROP .c7.; check that .* exists.* error.* 1091"); +call mtr.add_suppression("Slave.*Can.t DROP COLUMN .c7.; check that .* exists.* error.* 1091"); call mtr.add_suppression("Slave.*Unknown column .c7. in .t15.* error.* 1054"); call mtr.add_suppression("Slave.*Key column .c6. doesn.t exist in table.* error.* 1072"); call mtr.add_suppression("Slave SQL.*Column 2 of table .test.t1.. cannot be converted from type.* error.* 1677"); diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 6a91103279c..3461038f85e 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -414,12 +414,12 @@ t1 CREATE TABLE `t1` ( UNIQUE KEY `b` (`b`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t1 DROP PRIMARY KEY; -ERROR 42000: Can't DROP `PRIMARY`; check that it exists +ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists DROP TABLE t1; create table t1 (a int, b int, key(a)); insert into t1 values (1,1), (2,2); alter table t1 drop key no_such_key; -ERROR 42000: Can't DROP `no_such_key`; check that it exists +ERROR 42000: Can't DROP INDEX `no_such_key`; check that it exists alter table t1 drop key a; drop table t1; CREATE TABLE T12207(a int) ENGINE=MYISAM; @@ -1374,7 +1374,7 @@ Note 1060 Duplicate column name 'lol' ALTER TABLE t1 DROP COLUMN IF EXISTS lol; ALTER TABLE t1 DROP COLUMN IF EXISTS lol; Warnings: -Note 1091 Can't DROP `lol`; check that it exists +Note 1091 Can't DROP COLUMN `lol`; check that it exists ALTER TABLE t1 ADD KEY IF NOT EXISTS x_param(x_param); ALTER TABLE t1 ADD KEY IF NOT EXISTS x_param(x_param); Warnings: @@ -1385,7 +1385,7 @@ Note 1054 Unknown column 'lol' in 't1' DROP INDEX IF EXISTS x_param ON t1; DROP INDEX IF EXISTS x_param ON t1; Warnings: -Note 1091 Can't DROP `x_param`; check that it exists +Note 1091 Can't DROP INDEX `x_param`; check that it exists CREATE INDEX IF NOT EXISTS x_param1 ON t1(x_param); CREATE INDEX IF NOT EXISTS x_param1 ON t1(x_param); Warnings: @@ -1416,7 +1416,7 @@ Note 1060 Duplicate column name 'lol' ALTER TABLE t1 DROP COLUMN IF EXISTS lol; ALTER TABLE t1 DROP COLUMN IF EXISTS lol; Warnings: -Note 1091 Can't DROP `lol`; check that it exists +Note 1091 Can't DROP COLUMN `lol`; check that it exists ALTER TABLE t1 ADD KEY IF NOT EXISTS x_param(x_param); ALTER TABLE t1 ADD KEY IF NOT EXISTS x_param(x_param); Warnings: @@ -1427,7 +1427,7 @@ Note 1054 Unknown column 'lol' in 't1' DROP INDEX IF EXISTS x_param ON t1; DROP INDEX IF EXISTS x_param ON t1; Warnings: -Note 1091 Can't DROP `x_param`; check that it exists +Note 1091 Can't DROP INDEX `x_param`; check that it exists CREATE INDEX IF NOT EXISTS x_param1 ON t1(x_param); CREATE INDEX IF NOT EXISTS x_param1 ON t1(x_param); Warnings: @@ -1447,7 +1447,7 @@ Note 1061 Duplicate key name 'fk' ALTER TABLE t2 DROP FOREIGN KEY IF EXISTS fk; ALTER TABLE t2 DROP FOREIGN KEY IF EXISTS fk; Warnings: -Note 1091 Can't DROP `fk`; check that it exists +Note 1091 Can't DROP FOREIGN KEY `fk`; check that it exists SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1461,7 +1461,7 @@ Note 1061 Duplicate key name 't2_ibfk_1' ALTER TABLE t2 DROP FOREIGN KEY IF EXISTS t2_ibfk_1; ALTER TABLE t2 DROP FOREIGN KEY IF EXISTS t2_ibfk_1; Warnings: -Note 1091 Can't DROP `t2_ibfk_1`; check that it exists +Note 1091 Can't DROP FOREIGN KEY `t2_ibfk_1`; check that it exists SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -1486,10 +1486,10 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ALTER TABLE t2 DROP KEY k_id, DROP KEY IF EXISTS k_id; Warnings: -Note 1091 Can't DROP `k_id`; check that it exists +Note 1091 Can't DROP INDEX `k_id`; check that it exists ALTER TABLE t2 DROP COLUMN a, DROP COLUMN IF EXISTS a; Warnings: -Note 1091 Can't DROP `a`; check that it exists +Note 1091 Can't DROP COLUMN `a`; check that it exists SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/r/check_constraint.result b/mysql-test/r/check_constraint.result index 005415f7124..1ffe0ba3ba6 100644 --- a/mysql-test/r/check_constraint.result +++ b/mysql-test/r/check_constraint.result @@ -83,7 +83,7 @@ t2 CREATE TABLE `t2` ( CONSTRAINT `CONSTRAINT_1` CHECK (a+b+c < 500) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t2 drop constraint c; -ERROR 42000: Can't DROP `c`; check that it exists +ERROR 42000: Can't DROP CONSTRAINT `c`; check that it exists alter table t2 drop constraint min; show create table t2; Table Create Table diff --git a/mysql-test/r/create_drop_binlog.result b/mysql-test/r/create_drop_binlog.result index e8e8094a347..e330851bd6c 100644 --- a/mysql-test/r/create_drop_binlog.result +++ b/mysql-test/r/create_drop_binlog.result @@ -363,7 +363,7 @@ t1 CREATE TABLE `t1` ( DROP INDEX IF EXISTS i1 ON t1; DROP INDEX IF EXISTS i1 ON t1; Warnings: -Note 1091 Can't DROP `i1`; check that it exists +Note 1091 Can't DROP INDEX `i1`; check that it exists DROP TABLE t1; DROP TABLE IF EXISTS t1; Warnings: diff --git a/mysql-test/r/create_drop_index.result b/mysql-test/r/create_drop_index.result index a38ab7f6aed..7df6aeb5838 100644 --- a/mysql-test/r/create_drop_index.result +++ b/mysql-test/r/create_drop_index.result @@ -16,7 +16,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP INDEX IF EXISTS i1 ON t1; Warnings: -Note 1091 Can't DROP `i1`; check that it exists +Note 1091 Can't DROP INDEX `i1`; check that it exists SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 0d6e7d046e7..26af6320e79 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -467,7 +467,7 @@ alter table t1 drop index c2, add index (c2(4),c3(7)); alter table t1 add primary key (c1, c2), drop primary key; alter table t1 drop primary key; alter table t1 add primary key (c1, c2), drop primary key; -ERROR 42000: Can't DROP `PRIMARY`; check that it exists +ERROR 42000: Can't DROP INDEX `PRIMARY`; check that it exists show create table t1; Table Create Table t1 CREATE TABLE `t1` ( diff --git a/mysql-test/suite/engines/funcs/r/ix_drop_error.result b/mysql-test/suite/engines/funcs/r/ix_drop_error.result index f8cdd7918cb..61d9fa69379 100644 --- a/mysql-test/suite/engines/funcs/r/ix_drop_error.result +++ b/mysql-test/suite/engines/funcs/r/ix_drop_error.result @@ -1,7 +1,7 @@ DROP TABLE IF EXISTS t9; CREATE TABLE t9(c1 INTEGER NOT NULL); DROP INDEX i1 ON t9; -ERROR 42000: Can't DROP `i1`; check that it exists +ERROR 42000: Can't DROP INDEX `i1`; check that it exists DROP TABLE t9; SHOW TABLES; Tables_in_test diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 5758a8ec6b5..e6ee836ae13 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -544,9 +544,9 @@ t2 CREATE TABLE `t2` ( delete from t1; ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)) drop index dc on t4; -ERROR 42000: Can't DROP `dc`; check that it exists +ERROR 42000: Can't DROP INDEX `dc`; check that it exists alter table t3 drop foreign key dc; -ERROR 42000: Can't DROP `dc`; check that it exists +ERROR 42000: Can't DROP FOREIGN KEY `dc`; check that it exists alter table t4 drop foreign key dc; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result b/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result index 15370dff39a..81302266d82 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_innodb.result @@ -636,7 +636,7 @@ c1 c3 hex(c4) c5 c6 ************ connection slave; include/wait_for_slave_sql_error.inc [errno=1091] -Last_SQL_Error = 'Error 'Can't DROP `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' +Last_SQL_Error = 'Error 'Can't DROP COLUMN `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' STOP SLAVE; RESET SLAVE; diff --git a/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result b/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result index d04d91be6d1..12567f89af9 100644 --- a/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result +++ b/mysql-test/suite/rpl/r/rpl_extra_col_master_myisam.result @@ -636,7 +636,7 @@ c1 c3 hex(c4) c5 c6 ************ connection slave; include/wait_for_slave_sql_error.inc [errno=1091] -Last_SQL_Error = 'Error 'Can't DROP `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' +Last_SQL_Error = 'Error 'Can't DROP COLUMN `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' STOP SLAVE; RESET SLAVE; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index f440b9b3a3d..8dfa519ba2d 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -2071,29 +2071,27 @@ ER_CANT_REMOVE_ALL_FIELDS 42000 swe "Man kan inte radera alla fält med ALTER TABLE. Använd DROP TABLE istället" ukr "Не можливо видалити всі стовбці за допомогою ALTER TABLE. Для цього скористайтеся DROP TABLE" ER_CANT_DROP_FIELD_OR_KEY 42000 - cze "Nemohu zrušit %`-.192s (provést DROP). Zkontrolujte, zda neexistují záznamy/klíče" - dan "Kan ikke udføre DROP %`-.192s. Undersøg om feltet/nøglen eksisterer." - nla "Kan %`-.192s niet weggooien. Controleer of het veld of de zoeksleutel daadwerkelijk bestaat." - eng "Can't DROP %`-.192s; check that it exists" - est "Ei suuda kustutada %`-.192s. Kontrolli kas tulp/võti eksisteerib" - fre "Ne peut effacer (DROP) %`-.192s. Vérifiez s'il existe" - ger "Kann %`-.192s nicht löschen. Existiert es?" - greek "Αδύνατη η διαγραφή (DROP) %`-.192s. Παρακαλώ ελέγξτε αν το πεδίο/κλειδί υπάρχει" - hun "A DROP %`-.192s nem lehetseges. Ellenorizze, hogy a mezo/kulcs letezik-e" - ita "Impossibile cancellare %`-.192s. Controllare che il campo chiave esista" - jpn "%`-.192s を削除できません。列/索引の存在を確認して下さい。" - kor "%`-.192s를 DROP할 수 없습니다. 칼럼이나 키가 존재하는지 채크하세요." - nor "Kan ikke DROP %`-.192s. Undersøk om felt/nøkkel eksisterer." - norwegian-ny "Kan ikkje DROP %`-.192s. Undersøk om felt/nøkkel eksisterar." - pol "Nie można wykonać operacji DROP %`-.192s. SprawdĽ, czy to pole/klucz istnieje" - por "Não se pode fazer DROP %`-.192s. Confira se esta coluna/chave existe" - rum "Nu pot sa DROP %`-.192s. Verifica daca coloana/cheia exista" - rus "Невозможно удалить (DROP) %`-.192s. Убедитесь что он действительно существует" - serbian "Ne mogu da izvršim komandu drop 'DROP' na %`-.192s. Proverite da li ta kolona (odnosno ključ) postoji" - slo "Nemôžem zrušiť (DROP) %`-.192s. Skontrolujte, či neexistujú záznamy/kľúče" - spa "No puedo ELIMINAR %`-.192s. compuebe que el campo/clave existe" - swe "Kan inte ta bort %`-.192s. Kontrollera att begränsningen/fältet/nyckel finns" - ukr "Не можу DROP %`-.192s. Перевірте, чи він існує" + cze "Nemohu zrušit (DROP %s) %`-.192s. Zkontrolujte, zda neexistují záznamy/klíče" + dan "Kan ikke udføre DROP %s %`-.192s. Undersøg om feltet/nøglen eksisterer." + nla "DROP %s: Kan %`-.192s niet weggooien. Controleer of het veld of de zoeksleutel daadwerkelijk bestaat." + eng "Can't DROP %s %`-.192s; check that it exists" + est "Ei suuda kustutada (DROP %s) %`-.192s. Kontrolli kas tulp/võti eksisteerib" + fre "Ne peut effacer (DROP %s) %`-.192s. Vérifiez s'il existe" + ger "DROP %s: Kann %`-.192s nicht löschen. Existiert es?" + greek "Αδύνατη η διαγραφή (DROP %s) %`-.192s. Παρακαλώ ελέγξτε αν το πεδίο/κλειδί υπάρχει" + hun "A DROP %s %`-.192s nem lehetseges. Ellenorizze, hogy a mezo/kulcs letezik-e" + ita "Impossibile cancellare (DROP %s) %`-.192s. Controllare che il campo chiave esista" + nor "Kan ikke DROP %s %`-.192s. Undersøk om felt/nøkkel eksisterer." + norwegian-ny "Kan ikkje DROP %s %`-.192s. Undersøk om felt/nøkkel eksisterar." + pol "Nie można wykonać operacji DROP %s %`-.192s. SprawdĽ, czy to pole/klucz istnieje" + por "Não se pode fazer DROP %s %`-.192s. Confira se esta coluna/chave existe" + rum "Nu pot sa DROP %s %`-.192s. Verifica daca coloana/cheia exista" + rus "Невозможно удалить (DROP %s) %`-.192s. Убедитесь что он действительно существует" + serbian "Ne mogu da izvršim komandu drop 'DROP %s' na %`-.192s. Proverite da li ta kolona (odnosno ključ) postoji" + slo "Nemôžem zrušiť (DROP %s) %`-.192s. Skontrolujte, či neexistujú záznamy/kľúče" + spa "No puedo eliminar (DROP %s) %`-.192s. compuebe que el campo/clave existe" + swe "Kan inte ta bort (DROP %s) %`-.192s. Kontrollera att begränsningen/fältet/nyckel finns" + ukr "Не можу DROP %s %`-.192s. Перевірте, чи він існує" ER_INSERT_INFO cze "Záznamů: %ld Zdvojených: %ld Varování: %ld" dan "Poster: %ld Ens: %ld Advarsler: %ld" diff --git a/sql/sql_class.h b/sql/sql_class.h index 0318b6a249c..55c0948d46e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -272,6 +272,12 @@ public: */ Alter_drop *clone(MEM_ROOT *mem_root) const { return new (mem_root) Alter_drop(*this); } + const char *type_name() + { + return type == COLUMN ? "COLUMN" : + type == CHECK_CONSTRAINT ? "CONSTRAINT" : + type == KEY ? "INDEX" : "FOREIGN KEY"; + } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cb272402e90..de843172c75 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5947,7 +5947,7 @@ drop_create_field: push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_CANT_DROP_FIELD_OR_KEY, ER_THD(thd, ER_CANT_DROP_FIELD_OR_KEY), - drop->name); + drop->type_name(), drop->name); drop_it.remove(); if (alter_info->drop_list.is_empty()) alter_info->flags&= ~(Alter_info::ALTER_DROP_COLUMN | @@ -7890,7 +7890,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, case Alter_drop::KEY: case Alter_drop::COLUMN: case Alter_drop::CHECK_CONSTRAINT: - my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), + my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop->type_name(), alter_info->drop_list.head()->name); goto err; case Alter_drop::FOREIGN_KEY: @@ -7899,12 +7899,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } } } - if (alter_info->alter_list.elements) - { - my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), - alter_info->alter_list.head()->name); - goto err; - } if (!create_info->comment.str) { diff --git a/storage/connect/mysql-test/connect/r/xml_mdev5261.result b/storage/connect/mysql-test/connect/r/xml_mdev5261.result index 2a3ecedcb3a..f91194d570c 100644 --- a/storage/connect/mysql-test/connect/r/xml_mdev5261.result +++ b/storage/connect/mysql-test/connect/r/xml_mdev5261.result @@ -19,7 +19,7 @@ SELECT * FROM t1 WHERE i = 5; i 5 ALTER TABLE t1 DROP INDEX i; -ERROR 42000: Can't DROP `i`; check that it exists +ERROR 42000: Can't DROP INDEX `i`; check that it exists DROP INDEX i ON t1; -ERROR 42000: Can't DROP `i`; check that it exists +ERROR 42000: Can't DROP INDEX `i`; check that it exists DROP TABLE t1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 71b419b6935..bb7efa104fa 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -3789,7 +3789,7 @@ check_if_ok_to_rename: } my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), - drop->name); + drop->type_name(), drop->name); goto err_exit; found_fk: continue; diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result b/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result index 4f57368bf8e..58291bc7fd1 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_extra_col_master_tokudb.result @@ -636,7 +636,7 @@ c1 c3 hex(c4) c5 c6 ************ connection slave; include/wait_for_slave_sql_error.inc [errno=1091] -Last_SQL_Error = 'Error 'Can't DROP `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' +Last_SQL_Error = 'Error 'Can't DROP COLUMN `c7`; check that it exists' on query. Default database: 'test'. Query: 'ALTER TABLE t14 DROP COLUMN c7'' STOP SLAVE; RESET SLAVE; diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 68d80d2bff0..5724d9fe8ff 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -3803,7 +3803,7 @@ check_if_ok_to_rename: } my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), - drop->name); + drop->type_name(), drop->name); goto err_exit; found_fk: continue;