mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug #21072 Duplicate key error in NDB references wrong key: Added new printout for duplicate key error when key is unknown
This commit is contained in:
@@ -2031,16 +2031,28 @@ void handler::print_keydup_error(uint key_nr, const char *msg)
|
||||
/* Write the duplicated key in the error message */
|
||||
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);
|
||||
uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(msg);
|
||||
if (str.length() >= max_length)
|
||||
|
||||
if (key_nr == MAX_KEY)
|
||||
{
|
||||
str.length(max_length-4);
|
||||
str.append(STRING_WITH_LEN("..."));
|
||||
/* Key is unknown */
|
||||
str.length(0);
|
||||
key_nr= -1;
|
||||
my_printf_error(ER_DUP_ENTRY, msg,
|
||||
MYF(0), str.c_ptr(), "*UNKNOWN*");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Table is opened and defined at this point */
|
||||
key_unpack(&str,table,(uint) key_nr);
|
||||
uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(msg);
|
||||
if (str.length() >= max_length)
|
||||
{
|
||||
str.length(max_length-4);
|
||||
str.append(STRING_WITH_LEN("..."));
|
||||
}
|
||||
my_printf_error(ER_DUP_ENTRY, msg,
|
||||
MYF(0), str.c_ptr(), table->key_info[key_nr].name);
|
||||
}
|
||||
my_printf_error(ER_DUP_ENTRY, msg,
|
||||
MYF(0), str.c_ptr(), table->key_info[key_nr].name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user