Bug #38518 REPLACE on NDB tables does not consider DEFAULT values
Submitted: 1 Aug 2008 10:33 Modified: 14 Aug 2008 5:56
Reporter: Ivan Zoratti Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:6.2.15 OS:Any
Assigned to: CPU Architecture:Any

[1 Aug 2008 10:33] Ivan Zoratti
Description:
When you use the REPLACE statement on a NDB table, the DEFAULT value is not used. This behaviour is different from the use of REPLACE with other storage engines and with INSERT on a NDB table. Migrations from other storage engines to NDB are not possible because of this bug.

How to repeat:
CREATE TABLE callerid ( cardid varchar(20) NOT NULL DEFAULT '', callerid varchar(20) NOT NULL DEFAULT '', usertype varchar(10) DEFAULT 'XXX', KEY (cardid, usertype) ) ENGINE=ndbcluster DEFAULT CHARSET=utf8;

replace into callerid (cardid,callerid) values ('7225824','01274449137');

select * from callerid;
+---------+-------------+----------+
| cardid  | callerid    | usertype |
+---------+-------------+----------+
| 7225824 | 01274449137 | NULL     | 
+---------+-------------+----------+
1 row in set (0.00 sec)

If you execute the same statement with InnoDB, the result is:

select * from callerid;
+---------+-------------+----------+
| cardid  | callerid    | usertype |
+---------+-------------+----------+
| 7225824 | 01274449137 | XXX      | 
+---------+-------------+----------+
1 row in set (0.00 sec)

The same result on a NDB table can be obtained with an INSERT:

insert into callerid (cardid, callerid) values ('7225825','01274449136');
Query OK, 1 row affected (0.00 sec)

select * from callerid;
+---------+-------------+----------+
| cardid  | callerid    | usertype |
+---------+-------------+----------+
| 7225824 | 01274449137 | XXX      | 
+---------+-------------+----------+
1 row in set (0.00 sec)

Suggested fix:
Make REPLACE consistent with INSERT and with other storage engines.
[14 Aug 2008 5:56] Bernd Ocklin
This is related to http://bugs.mysql.com/bug.php?id=22045 and was fixed with   http://lists.mysql.com/commits/44903 which is part of next ndb 6.2 and 6.4. Its also fixed in 6.3.13.