summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-01-08 11:35:08 +0200
committerMonty <monty@mariadb.org>2018-01-30 21:33:56 +0200
commitb9b17e63407759f73835e9e002f57657ef88cf38 (patch)
tree85c517c0971c8fee04665330053dd4f605a6e744
parenta2393ff22e2ffc12f23fcd224e8dd07fba65c1d9 (diff)
downloadmariadb-git-b9b17e63407759f73835e9e002f57657ef88cf38.tar.gz
Updated error message for wrong foreign key constraint
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk-warnings.result18
-rw-r--r--mysql-test/suite/innodb/r/innodb-fk.result4
-rw-r--r--mysql-test/suite/innodb/r/innodb-fkcheck.result4
-rw-r--r--mysql-test/suite/innodb_gis/r/point_basic.result6
-rw-r--r--sql/handler.cc3
-rw-r--r--sql/share/errmsg-utf8.txt24
-rw-r--r--storage/innobase/handler/handler0alter.cc2
7 files changed, 31 insertions, 30 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-fk-warnings.result b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
index 792cae85b55..fc3f45f3d0a 100644
--- a/mysql-test/suite/innodb/r/innodb-fk-warnings.result
+++ b/mysql-test/suite/innodb/r/innodb-fk-warnings.result
@@ -27,7 +27,7 @@ show warnings;
Level Code Message
Warning 150 Create table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
create table t1(a int not null primary key, b int) engine=innodb;
create table t2(a int, b int, constraint a foreign key a (a) references t1(a),
@@ -36,7 +36,7 @@ ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
create table t2(a int, b int, constraint a foreign key a (a) references t1(a)) engine=innodb;
alter table t2 add constraint b foreign key (b) references t2(b);
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
@@ -44,7 +44,7 @@ show warnings;
Level Code Message
Warning 150 Alter table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t2, t1;
create table t1 (f1 integer primary key) engine=innodb;
alter table t1 add constraint c1 foreign key (f1) references t11(f1);
@@ -53,7 +53,7 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t1` with foreign key constraint failed. Referenced table `test`.`t11` not found in the data dictionary near ' foreign key (f1) references t11(f1)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t1;
create temporary table t1(a int not null primary key, b int, key(b)) engine=innodb;
create temporary table t2(a int, foreign key(a) references t1(a)) engine=innodb;
@@ -76,14 +76,14 @@ show warnings;
Level Code Message
Warning 150 Create table `mysqld.1`.`t2` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(a) references t1(a)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
alter table t1 add foreign key(b) references t1(a);
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
show warnings;
Level Code Message
Warning 150 Alter table `mysqld.1`.`t1` with foreign key constraint failed. Referenced table `mysqld.1`.`t1` not found in the data dictionary near 'foreign key(b) references t1(a)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t1;
create table t1(a int not null primary key, b int, key(b)) engine=innodb;
alter table t1 add foreign key(a,b) references t1(a);
@@ -106,14 +106,14 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t1` with foreign key constraint failed. You have defined a SET NULL condition but column 'f1' is defined as NOT NULL in ' foreign key (f1) references t1(f1) on update set null' near ' on update set null'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
create table t2(a int not null, foreign key(a) references t1(f1) on delete set null) engine=innodb;
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
show warnings;
Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. You have defined a SET NULL condition but column 'a' is defined as NOT NULL in 'foreign key(a) references t1(f1) on delete set null) engine=innodb' near ' on delete set null) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
create table t1 (id int not null primary key, f1 int, f2 int, key(f1)) engine=innodb;
create table t2(a char(20), key(a), foreign key(a) references t1(f1)) engine=innodb;
@@ -122,5 +122,5 @@ show warnings;
Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. Field type or character set for column 'a' does not mach referenced column 'f1' near 'foreign key(a) references t1(f1)) engine=innodb'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
drop table t1;
diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result
index 2eb19764769..4efa0214999 100644
--- a/mysql-test/suite/innodb/r/innodb-fk.result
+++ b/mysql-test/suite/innodb/r/innodb-fk.result
@@ -53,7 +53,7 @@ Level Code Message
Warning 150 Create table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary near ' FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
) ENGINE=InnoDB'.
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `t2`
CREATE TABLE t2 (
id int(11) NOT NULL AUTO_INCREMENT,
f2 int(11) NOT NULL,
@@ -67,7 +67,7 @@ show warnings;
Level Code Message
Warning 150 Alter table `test`.`t2` with foreign key constraint failed. Referenced table `test`.`t3` not found in the data dictionary near ' FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
drop table t2;
drop table t1;
CREATE DATABASE kg_test1;
diff --git a/mysql-test/suite/innodb/r/innodb-fkcheck.result b/mysql-test/suite/innodb/r/innodb-fkcheck.result
index c6beabb0f50..efa227e4035 100644
--- a/mysql-test/suite/innodb/r/innodb-fkcheck.result
+++ b/mysql-test/suite/innodb/r/innodb-fkcheck.result
@@ -37,7 +37,7 @@ ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `b`
DROP TABLE IF EXISTS d;
Warnings:
Note 1051 Unknown table 'bug_fk.d'
@@ -76,7 +76,7 @@ ERROR HY000: Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint
show warnings;
Level Code Message
Error 1005 Can't create table `bug_fk`.`b` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `b`
set foreign_key_checks=0;
drop table c;
drop table d;
diff --git a/mysql-test/suite/innodb_gis/r/point_basic.result b/mysql-test/suite/innodb_gis/r/point_basic.result
index faaef07c112..0fa5021dab9 100644
--- a/mysql-test/suite/innodb_gis/r/point_basic.result
+++ b/mysql-test/suite/innodb_gis/r/point_basic.result
@@ -1526,7 +1526,7 @@ show warnings;
Level Code Message
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
ALTER TABLE parent DROP INDEX idx1;
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
Got one of the listed errors
@@ -1534,7 +1534,7 @@ show warnings;
Level Code Message
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
ALTER TABLE child DROP INDEX idx2;
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
Got one of the listed errors
@@ -1542,7 +1542,7 @@ show warnings;
Level Code Message
Warning 150 Alter table '`test`.`child`' with foreign key constraint failed. There is only prefix index in the referenced table where the referenced columns appear as the first columns near 'FOREIGN KEY(p) REFERENCES parent(p)'.
Error 1005 Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
-Warning 1215 Cannot add foreign key constraint
+Warning 1215 Cannot add foreign key constraint for `#sql-temporary`
DROP TABLE child, parent;
#
# Bug#28763: Selecting geometry fields in UNION caused server crash.
diff --git a/sql/handler.cc b/sql/handler.cc
index f03e7848f3c..155dba790f3 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4899,7 +4899,8 @@ int ha_create_table(THD *thd, const char *path,
share.m_psi= PSI_CALL_get_table_share(temp_table, &share);
- if (open_table_from_share(thd, &share, &empty_clex_str, 0, READ_ALL, 0, &table, true))
+ if (open_table_from_share(thd, &share, &empty_clex_str, 0, READ_ALL, 0,
+ &table, true))
goto err;
update_create_info_from_table(create_info, &table);
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 03e7b8a1098..db07df0fe9a 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -4528,18 +4528,18 @@ ER_TABLE_CANT_HANDLE_FT
spa "El tipo de tabla usada (%s) no soporta índices FULLTEXT"
swe "Tabelltypen (%s) har inte hantering av FULLTEXT-index"
ukr "Використаний тип таблиці (%s) не підтримує FULLTEXT індексів"
-ER_CANNOT_ADD_FOREIGN
- nla "Kan foreign key beperking niet toevoegen"
- eng "Cannot add foreign key constraint"
- fre "Impossible d'ajouter des contraintes d'index externe"
- ger "Fremdschlüssel-Beschränkung kann nicht hinzugefügt werden"
- ita "Impossibile aggiungere il vincolo di integrita' referenziale (foreign key constraint)"
- jpn "外部キー制約を追加できません。"
- por "Não pode acrescentar uma restrição de chave estrangeira"
- rus "Невозможно добавить ограничения внешнего ключа"
- serbian "Ne mogu da dodam proveru spoljnog ključa"
- spa "No puede adicionar clave extranjera constraint"
- swe "Kan inte lägga till 'FOREIGN KEY constraint'"
+ER_CANNOT_ADD_FOREIGN
+ nla "Kan foreign key beperking niet toevoegen vor `%s`"
+ eng "Cannot add foreign key constraint for `%s`"
+ fre "Impossible d'ajouter des contraintes d'index externe à `%s`"
+ ger "Fremdschlüssel-Beschränkung kann nicht hinzugefügt werden für `%s`"
+ ita "Impossibile aggiungere il vincolo di integrita' referenziale (foreign key constraint) a `%s`"
+ jpn "`%s` 外部キー制約を追加できません。"
+ por "Não pode acrescentar uma restrição de chave estrangeira para `%s`"
+ rus "Невозможно добавить ограничения внешнего ключа для `%s`"
+ serbian "Ne mogu da dodam proveru spoljnog ključa na `%s`"
+ spa "No puede adicionar clave extranjera constraint para `%s`"
+ swe "Kan inte lägga till 'FOREIGN KEY constraint' för `%s`'"
ER_NO_REFERENCED_ROW 23000
nla "Kan onderliggende rij niet toevoegen: foreign key beperking gefaald"
eng "Cannot add or update a child row: a foreign key constraint fails"
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 237e5740c5b..7c47340fae7 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1799,7 +1799,7 @@ innobase_get_foreign_key_info(
/* Not possible to add a foreign key without a
referenced column */
mutex_exit(&dict_sys->mutex);
- my_error(ER_CANNOT_ADD_FOREIGN, MYF(0));
+ my_error(ER_CANNOT_ADD_FOREIGN, MYF(0), tbl_namep);
goto err_exit;
}