Bug #19906 REPLACE doesn't update TEXT fields correctly
Submitted: 18 May 2006 12:44 Modified: 22 Jun 2006 10:23
Reporter: Geert Vanderkelen
Status: Closed
Category:Server: Cluster Severity:S1 (Critical)
Version:5.0, 5.1 OS:Linux (Linux)
Assigned to: Martin Skold Target Version:

[18 May 2006 12:44] Geert Vanderkelen
Description:

Having a table with primary key and unique index, the TEXT fields are not updated
correctly. It does work when there is no unique index..

See 'How to repeat' for more:

mysql> REPLACE INTO t1 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1),
(1,1,1,'b','b','b',2), (1,1,1,'c','c','c',3);

mysql> select * from t1;
+---+---+---+------+------+------+----+------+
| a | b | c | x    | y    | z    | id | i    |
+---+---+---+------+------+------+----+------+
| 1 | 1 | 1 | a    | a    | a    |  3 |    3 | 
+---+---+---+------+------+------+----+------+

If you have the same table made with MyISAM, you would have:

+---+---+---+------+------+------+----+------+
| a | b | c | x    | y    | z    | id | i    |
+---+---+---+------+------+------+----+------+
| 1 | 1 | 1 | c    | c    | c    |  3 |    3 | 
+---+---+---+------+------+------+----+------+

Now, I thought doing the statements seperately with the NDB table:
mysql> replace into t1(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1);
mysql> replace into t1(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2);

But the result is wrong:
+---+---+---+------+------+------+----+------+
| a | b | c | x    | y    | z    | id | i    |
+---+---+---+------+------+------+----+------+
| 1 | 1 | 1 | a    | a    | a    |  2 |    2 | 
+---+---+---+------+------+------+----+------+

How to repeat:

CREATE TABLE `t1` (
  `a` int(11) NOT NULL,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
  `x` text,
  `y` text,
  `z` text,
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `i` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `a` (`a`,`b`,`c`)
) ENGINE=ndbcluster;

REPLACE INTO t1 (a,b,c,x,y,z,i) VALUES (1,1,1,'a','a','a',1), (1,1,1,'b','b','b',2),
(1,1,1,'c','c','c',3);

SELECT * FROM t1;

REPLACE INTO t1(a,b,c,x,y,z,i) values (1,1,1,'a','a','a',1);
REPLACE INTO t1(a,b,c,x,y,z,i) values (1,1,1,'b','b','b',2);

SELECT * FROM t1;
[22 May 2006 18:54] Jonas Oreland
customer gives higher prio = 29
[20 Jun 2006 15:41] 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/7921
[20 Jun 2006 16:00] 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/7922
[20 Jun 2006 16:48] 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/7928
[21 Jun 2006 9:41] 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/7990
[22 Jun 2006 10:23] 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 bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 5.0.23 and 5.1.12 changelogs. Closed.