Bug #25746 ndb: 4209 error with 2 VARCHAR primary keys
Submitted: 22 Jan 2007 9:35 Modified: 25 Jan 2007 8:17
Reporter: Tomas Ulin
Status: Closed
Category:Server: Cluster Severity:S3 (Non-critical)
Version:5.0, 5.1 OS:
Assigned to: Tomas Ulin Target Version:

[22 Jan 2007 9:35] Tomas Ulin
Description:
Currently only reported for replication in 5.1, unsure if it is posible to get in 5.0

error 4209 is reported on slave when delete from a table containing 2 VARCHAR primary keys
each with storage length > 255

How to repeat:
master-slave with rowbased replication

master:

CREATE TABLE t1 ( a VARBINARY(40) NOT NULL, b VARCHAR(256) CHARACTER SET UTF8 NOT NULL, c
VARCHAR(256) CHARACTER SET UTF8 NOT NULL, PRIMARY KEY(b, c) ) engine=ndbcluster;
INSERT INTO t1 VALUES ("a", "ab", "abc");
DELETE FROM t1;

slave:

start slave, and the error occurs when the delete event is executed.

Suggested fix:
===== ../sql/ha_ndbcluster.cc 1.389 vs edited =====

3704,3705c3713
<       if ((field->type() ==  MYSQL_TYPE_VARCHAR) &&
<         ((Field_varstring*)field)->length_bytes == 1)
---
>       if (field->type() ==  MYSQL_TYPE_VARCHAR)
3710,3712c3718,3727
<       buff[0] = ptr[0];
<       buff[1] = 0;
<       memcpy(buff+2, ptr + 1, len);
---
>         if (((Field_varstring*)field)->length_bytes == 1)
>         {
>           buff[0] = ptr[0];
>           buff[1] = 0;
>           memcpy(buff+2, ptr + 1, len);
>         }
>         else
>         {
>           memcpy(buff, ptr, len+2);
>         }
[22 Jan 2007 16:05] Tomas Ulin
simpler case to generate error (no replication needed):

CREATE TABLE t1 (
a VARBINARY(40) NOT NULL,
b VARCHAR (256) CHARACTER SET UTF8 NOT NULL,
c VARCHAR(256) CHARACTER SET UTF8 NOT NULL,
PRIMARY KEY (b,c))  ENGINE=ndbcluster;
INSERT INTO t1 VALUES
("a","ab","abc"),("b","abc","abcd"),("c","abc","ab"),("d","ab","ab"),("e","abc","abc");
SELECT * FROM t1 ORDER BY a;
[22 Jan 2007 18:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/18572
[23 Jan 2007 1:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/18590
[24 Jan 2007 2:50] Tomas Ulin
pushed to 5.1.15
[24 Jan 2007 9:02] Tomas Ulin
pushed to 5.0.36
[25 Jan 2007 8:17] Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of
that product and will be incorporated into the next release.

If necessary, you can access the source repository and build the latest available version,
including the bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.0.36 and 5.1.15 changelogs.