Commit 531c0eee authored by Jimmy Yang's avatar Jimmy Yang

Address bug #55465 ERROR 1280 (42000): Incorrect index name '<index name>',

adding a couple FK related messages.

rb://409 approved by Sunny Bains
parent 0812058d
......@@ -2140,7 +2140,7 @@ dict_foreign_add_to_cache(
mem_heap_free(foreign->heap);
}
return(DB_CANNOT_ADD_CONSTRAINT);
return(DB_FOREIGN_NO_INDEX);
}
for_in_cache->referenced_table = ref_table;
......@@ -2184,7 +2184,7 @@ dict_foreign_add_to_cache(
mem_heap_free(foreign->heap);
}
return(DB_CANNOT_ADD_CONSTRAINT);
return(DB_REFERENCING_NO_INDEX);
}
for_in_cache->foreign_table = for_table;
......
......@@ -707,7 +707,9 @@ convert_error_code_to_mysql(
return(HA_ERR_ROW_IS_REFERENCED);
} else if (error == (int) DB_CANNOT_ADD_CONSTRAINT) {
} else if (error == (int) DB_CANNOT_ADD_CONSTRAINT
|| error == (int) DB_FOREIGN_NO_INDEX
|| error == (int) DB_REFERENCING_NO_INDEX) {
return(HA_ERR_CANNOT_ADD_FOREIGN);
......@@ -6099,6 +6101,8 @@ ha_innobase::rename_table(
innobase_commit_low(trx);
trx_free_for_mysql(trx);
switch (error) {
case DB_DUPLICATE_KEY:
/* Add a special case to handle the Duplicated Key error
and return DB_ERROR instead.
This is to avoid a possible SIGSEGV error from mysql error
......@@ -6111,10 +6115,28 @@ ha_innobase::rename_table(
the dup key error here is due to an existing table whose name
is the one we are trying to rename to) and return the generic
error code. */
if (error == (int) DB_DUPLICATE_KEY) {
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to);
error = DB_ERROR;
break;
case DB_FOREIGN_NO_INDEX:
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_CANNOT_ADD_FOREIGN,
"Alter or rename of table '%s' failed"
" because the new table is a child table"
" in a FK relationship and it does not"
" have an index that contains foreign"
" keys as its prefix columns.", norm_to);
break;
case DB_REFERENCING_NO_INDEX:
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_CANNOT_ADD_FOREIGN,
"Alter or rename of table '%s' failed"
" because the new table is a parent table"
" in a FK relationship and it does not"
" have an index that contains foreign"
" keys as its prefix columns.", norm_to);
break;
}
error = convert_error_code_to_mysql(error, NULL);
......
......@@ -73,6 +73,12 @@ Created 5/24/1996 Heikki Tuuri
a later version of the engine. */
#define DB_INTERRUPTED 49 /* the query has been interrupted with
"KILL QUERY N;" */
#define DB_FOREIGN_NO_INDEX 50 /* the child (foreign) table does not
have an index that contains the
foreign keys as its prefix columns */
#define DB_REFERENCING_NO_INDEX 51 /* the parent (referencing) table does
not have an index that contains the
foreign keys as its prefix columns */
/* The following are partial failure codes */
#define DB_FAIL 1000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment