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.