Bug #13961 Triggers on tables with auto_increment insert bogus values into table
Submitted: 12 Oct 2005 14:59 Modified: 18 Oct 2005 23:39
Reporter: Martin Skold Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:5.0.13 OS:
Assigned to: Martin Skold CPU Architecture:Any

[12 Oct 2005 14:59] Martin Skold
Description:
When defining triggers on insert for a ndbcluster
table with an auto_increment key, the execution
seems to run into an error that is returned as a 
warning, the error code seems, however, to be
used as a bogus value instead of a real auto_increment
value. 
(the same example without auto_increment works fine)

How to repeat:
 CREATE TABLE  play  (
  playRef int(11) NOT NULL AUTO_INCREMENT,
  another int(11) default NULL,
  version int(11) default NULL,
  PRIMARY KEY  (`playRef`)
) ENGINE=ndbcluster;

CREATE TRIGGER updatePlay BEFORE UPDATE ON play FOR EACH ROW SET
NEW.version = OLD.version + 1;
CREATE TRIGGER insertPlay BEFORE INSERT ON play FOR EACH ROW SET NEW.version
= 1;

mysql> insert into play values(NULL,1,3);
Query OK, 1 row affected, 1 warning (0.04 sec)
                                                                                    
mysql> show warnings;
+-------+------+----------------------------------------------------------------------------------------------------------------+
| Level | Code | Message
                                            |
+-------+------+----------------------------------------------------------------------------------------------------------------+
| Error | 1296 | Got error 4006 'Connect failure - out of connection objects (increase MaxNoOfConcurrentTransactions)' from NDB |
+-------+------+----------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
 
mysql> select * from play;
+---------+---------+---------+
| playRef | another | version |
+---------+---------+---------+
|    4006 |       1 |       1 |
+---------+---------+---------+
1 row in set (0.01 sec)

Suggested fix:
Fix the way triggers (or maybe stored procedures) interact
with ndbcluster auto_increment values.
[14 Oct 2005 9:27] 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/internals/31103
[18 Oct 2005 12:44] Martin Skold
Pushed to 5.0.14
[18 Oct 2005 23:39] 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.14 changelog.