diff options
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 6c5d3a580ec..4640597d2ec 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -275,7 +275,7 @@ handler *get_ha_partition(partition_info *part_info) } else { - my_error(ER_OUTOFMEMORY, MYF(0), sizeof(ha_partition)); + my_error(ER_OUTOFMEMORY, MYF(0), static_cast<int>(sizeof(ha_partition))); } DBUG_RETURN(((handler*) partition)); } @@ -1661,7 +1661,8 @@ int ha_recover(HASH *commit_list) } if (!info.list) { - sql_print_error(ER(ER_OUTOFMEMORY), info.len*sizeof(XID)); + sql_print_error(ER(ER_OUTOFMEMORY), + static_cast<int>(info.len*sizeof(XID))); DBUG_RETURN(1); } @@ -2828,7 +2829,23 @@ void handler::print_error(int error, myf errflag) char key[MAX_KEY_LENGTH]; String str(key,sizeof(key),system_charset_info); /* Table is opened and defined at this point */ - key_unpack(&str,table,(uint) key_nr); + + /* + Use primary_key instead of key_nr because key_nr is a key + number in the child FK table, not in our 'table'. See + Bug#12661768 UPDATE IGNORE CRASHES SERVER IF TABLE IS INNODB + AND IT IS PARENT FOR OTHER ONE This bug gets a better fix in + MySQL 5.6, but it is too risky to get that in 5.1 and 5.5 + (extending the handler interface and adding new error message + codes) + */ + if (table->s->primary_key < MAX_KEY) + key_unpack(&str,table,table->s->primary_key); + else + { + LEX_CUSTRING tmp= {USTRING_WITH_LEN("Unknown key value")}; + str.set((const char*) tmp.str, tmp.length, system_charset_info); + } max_length= (MYSQL_ERRMSG_SIZE- (uint) strlen(ER(ER_FOREIGN_DUPLICATE_KEY))); if (str.length() >= max_length) |