1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type

For BINARY(N) strip trailing zeroes to make the error message nice-looking
This commit is contained in:
Sergey Glukhov
2010-05-27 20:01:43 +04:00
parent 6f55a81074
commit 20bd61a6e1
4 changed files with 40 additions and 1 deletions

View File

@ -354,6 +354,16 @@ void key_unpack(String *to,TABLE *table,uint idx)
{
CHARSET_INFO *cs= field->charset();
field->val_str(&tmp);
/*
For BINARY(N) strip trailing zeroes to make
the error message nice-looking
*/
if (field->binary() && field->type() == MYSQL_TYPE_STRING && tmp.length())
{
const char *tmp_end= tmp.ptr() + tmp.length();
while (tmp_end > tmp.ptr() && !*--tmp_end);
tmp.length(tmp_end - tmp.ptr() + 1);
}
if (cs->mbmaxlen > 1 &&
table->field[key_part->fieldnr - 1]->field_length !=
key_part->length)