summaryrefslogtreecommitdiff
path: root/sql/key.cc
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-05-27 20:01:43 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-05-27 20:01:43 +0400
commitf1e1d1bd005f7b5d732c560f04e1f05608e2671f (patch)
tree74ba6d5c624ff12b86aa5a763515ad02800307a8 /sql/key.cc
parent8fa381fda36f3386a7116ff57dc93329891611df (diff)
downloadmariadb-git-f1e1d1bd005f7b5d732c560f04e1f05608e2671f.tar.gz
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 mysql-test/r/errors.result: test case mysql-test/r/type_binary.result: result fix mysql-test/t/errors.test: test case sql/key.cc: For BINARY(N) strip trailing zeroes to make the error message nice-looking
Diffstat (limited to 'sql/key.cc')
-rw-r--r--sql/key.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/key.cc b/sql/key.cc
index d593850ca10..582334620ad 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -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)