mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Fix Bug #16290 Unclear error message when adding foreign key constraint
rb://502 approved by Sunny Bains
This commit is contained in:
parent
a8266151de
commit
f64026427e
4 changed files with 37 additions and 2 deletions
|
|
@ -960,6 +960,8 @@ convert_error_code_to_mysql(
|
|||
return(HA_ERR_ROW_IS_REFERENCED);
|
||||
|
||||
case DB_CANNOT_ADD_CONSTRAINT:
|
||||
case DB_CHILD_NO_INDEX:
|
||||
case DB_PARENT_NO_INDEX:
|
||||
return(HA_ERR_CANNOT_ADD_FOREIGN);
|
||||
|
||||
case DB_CANNOT_DROP_CONSTRAINT:
|
||||
|
|
@ -6977,6 +6979,29 @@ ha_innobase::create(
|
|||
trx, stmt, stmt_len, norm_name,
|
||||
create_info->options & HA_LEX_CREATE_TMP_TABLE);
|
||||
|
||||
switch (error) {
|
||||
|
||||
case DB_PARENT_NO_INDEX:
|
||||
push_warning_printf(
|
||||
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
HA_ERR_CANNOT_ADD_FOREIGN,
|
||||
"Create table '%s' with foreign key constraint"
|
||||
" failed. There is no index in the referenced"
|
||||
" table where the referenced columns appear"
|
||||
" as the first columns.\n", norm_name);
|
||||
break;
|
||||
|
||||
case DB_CHILD_NO_INDEX:
|
||||
push_warning_printf(
|
||||
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
HA_ERR_CANNOT_ADD_FOREIGN,
|
||||
"Create table '%s' with foreign key constraint"
|
||||
" failed. There is no index in the referencing"
|
||||
" table where referencing columns appear"
|
||||
" as the first columns.\n", norm_name);
|
||||
break;
|
||||
}
|
||||
|
||||
error = convert_error_code_to_mysql(error, flags, NULL);
|
||||
|
||||
if (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue