#At file:///home/gluh/MySQL/mysql-trunk-bugfixing/ based on revid:sergey.glukhov@stripped7155443-24vqi9o8rpnkyci7
3069 Sergey Glukhov 2010-05-27
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
modified:
mysql-test/r/errors.result
mysql-test/r/type_binary.result
mysql-test/t/errors.test
sql/key.cc
=== modified file 'mysql-test/r/errors.result'
--- a/mysql-test/r/errors.result 2010-02-23 18:43:26 +0000
+++ b/mysql-test/r/errors.result 2010-05-27 16:01:43 +0000
@@ -120,3 +120,17 @@ SET sql_quote_show_create= _utf8 x'5452C
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'TRÜE'
SET sql_quote_show_create=_latin1 x'5452DC45';
ERROR 42000: Variable 'sql_quote_show_create' can't be set to the value of 'TRÜE'
+#
+# Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type
+#
+CREATE TABLE t1(c1 BINARY(10), c2 BINARY(10), c3 BINARY(10),
+PRIMARY KEY(c1,c2,c3));
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+ERROR 23000: Duplicate entry 'abc-abc-abc' for key 'PRIMARY'
+DROP TABLE t1;
+CREATE TABLE t1 (f1 VARBINARY(19) PRIMARY KEY);
+INSERT INTO t1 VALUES ('abc\0\0');
+INSERT INTO t1 VALUES ('abc\0\0');
+ERROR 23000: Duplicate entry 'abc\x00\x00' for key 'PRIMARY'
+DROP TABLE t1;
=== modified file 'mysql-test/r/type_binary.result'
--- a/mysql-test/r/type_binary.result 2009-10-15 12:23:43 +0000
+++ b/mysql-test/r/type_binary.result 2010-05-27 16:01:43 +0000
@@ -47,7 +47,7 @@ create table t1 (s1 binary(2) primary ke
insert into t1 values (0x01);
insert into t1 values (0x0120);
insert into t1 values (0x0100);
-ERROR 23000: Duplicate entry '\x01\x00' for key 'PRIMARY'
+ERROR 23000: Duplicate entry '\x01' for key 'PRIMARY'
select hex(s1) from t1 order by s1;
hex(s1)
0100
=== modified file 'mysql-test/t/errors.test'
--- a/mysql-test/t/errors.test 2009-12-22 09:35:56 +0000
+++ b/mysql-test/t/errors.test 2010-05-27 16:01:43 +0000
@@ -140,3 +140,18 @@ SET sql_quote_show_create= _utf8 x'5452C
--error ER_WRONG_VALUE_FOR_VAR
SET sql_quote_show_create=_latin1 x'5452DC45';
+--echo #
+--echo # Bug#52430 Incorrect key in the error message for duplicate key error involving BINARY type
+--echo #
+CREATE TABLE t1(c1 BINARY(10), c2 BINARY(10), c3 BINARY(10),
+PRIMARY KEY(c1,c2,c3));
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+--error ER_DUP_ENTRY
+INSERT INTO t1 (c1,c2,c3) VALUES('abc','abc','abc');
+DROP TABLE t1;
+
+CREATE TABLE t1 (f1 VARBINARY(19) PRIMARY KEY);
+INSERT INTO t1 VALUES ('abc\0\0');
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES ('abc\0\0');
+DROP TABLE t1;
=== modified file 'sql/key.cc'
--- a/sql/key.cc 2010-03-31 14:05:33 +0000
+++ b/sql/key.cc 2010-05-27 16:01:43 +0000
@@ -354,6 +354,16 @@ void key_unpack(String *to,TABLE *table,
{
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)
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20100527160143-57nas8nplzpj26dz.bundle
Thread |
---|
• bzr commit into mysql-trunk-bugfixing branch (Sergey.Glukhov:3069)Bug#52430 | Sergey Glukhov | 27 May |