MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Martin Skold Date:September 3 2009 7:49am
Subject:bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2976) Bug#46712
View as plain text  
#At file:///home/marty/MySQL/mysql-5.1-telco-6.2_main/

 2976 Martin Skold	2009-09-03
      Bug #46712 Auto_increment work incorrectly when using triggers and NDB Cluster, added test case.
      modified:
        mysql-test/suite/ndb/r/ndb_auto_increment.result
        mysql-test/suite/ndb/t/ndb_auto_increment.test

=== modified file 'mysql-test/suite/ndb/r/ndb_auto_increment.result'
--- a/mysql-test/suite/ndb/r/ndb_auto_increment.result	2008-01-25 09:43:30 +0000
+++ b/mysql-test/suite/ndb/r/ndb_auto_increment.result	2009-09-03 07:49:50 +0000
@@ -3,6 +3,9 @@ DROP TABLE IF EXISTS t1;
 set @old_auto_increment_offset = @@session.auto_increment_offset;
 set @old_auto_increment_increment = @@session.auto_increment_increment;
 set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz;
+set @old_auto_increment_offset = @@session.auto_increment_offset;
+set @old_auto_increment_increment = @@session.auto_increment_increment;
+set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz;
 flush status;
 create table t1 (a int not null auto_increment primary key) engine ndb;
 insert into t1 values (NULL);
@@ -443,3 +446,56 @@ set auto_increment_offset = @old_auto_in
 set auto_increment_increment = @old_auto_increment_increment;
 set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
 drop table t1;
+set auto_increment_offset = @old_auto_increment_offset;
+set auto_increment_increment = @old_auto_increment_increment;
+set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
+CREATE TABLE `t1` (
+`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+`k` int(10) unsigned NOT NULL DEFAULT '0',
+`c` char(120) NOT NULL DEFAULT '',
+`pad` char(60) NOT NULL DEFAULT '',
+PRIMARY KEY (`id`),
+KEY `k` (`k`)
+) ENGINE=ndbcluster;
+CREATE TABLE `t2` (
+`evend_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+`timestamp` int(11) NOT NULL,
+`server_id` int(11) NOT NULL,
+PRIMARY KEY (`evend_id`)
+) ENGINE=ndbcluster;
+insert into t1 values (null,1,'',''),(null,2,'','');
+CREATE TRIGGER tr1
+AFTER UPDATE ON t1
+FOR EACH ROW
+BEGIN
+insert into t2(timestamp, server_id) values(UNIX_TIMESTAMP(),@@global.server_id);
+end;
+|
+CREATE TRIGGER tr1
+AFTER UPDATE ON t1
+FOR EACH ROW
+BEGIN
+insert into t2(timestamp, server_id) values(UNIX_TIMESTAMP(),@@global.server_id);
+end;
+|
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+update t1 set c='foobar' where id=1;
+select evend_id,server_id from t2 order by evend_id;
+evend_id	server_id
+1	1
+2	2
+3	1
+4	2
+5	1
+6	2
+7	1
+8	2
+drop trigger tr1;
+drop table t1, t2;
+drop trigger if exists tr1;

=== modified file 'mysql-test/suite/ndb/t/ndb_auto_increment.test'
--- a/mysql-test/suite/ndb/t/ndb_auto_increment.test	2007-11-06 09:57:49 +0000
+++ b/mysql-test/suite/ndb/t/ndb_auto_increment.test	2009-09-03 07:49:50 +0000
@@ -6,6 +6,9 @@ connection server1;
 DROP TABLE IF EXISTS t1,t2;
 connection server2;
 DROP TABLE IF EXISTS t1;
+set @old_auto_increment_offset = @@session.auto_increment_offset;
+set @old_auto_increment_increment = @@session.auto_increment_increment;
+set @old_ndb_autoincrement_prefetch_sz = @@session.ndb_autoincrement_prefetch_sz;
 connection server1;
 --enable_warnings
 
@@ -291,3 +294,87 @@ set auto_increment_increment = @old_auto
 set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
 
 drop table t1;
+
+connection server2;
+set auto_increment_offset = @old_auto_increment_offset;
+set auto_increment_increment = @old_auto_increment_increment;
+set ndb_autoincrement_prefetch_sz = @old_ndb_autoincrement_prefetch_sz;
+
+# bug#46712 Auto_increment work incorrectly when using triggers and NDB Cluster
+#
+# Testing that auto_increment values are set correctly when inserting from
+# multiple SQL-nodes
+
+connection server1;
+
+CREATE TABLE `t1` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `k` int(10) unsigned NOT NULL DEFAULT '0',
+ `c` char(120) NOT NULL DEFAULT '',
+ `pad` char(60) NOT NULL DEFAULT '',
+ PRIMARY KEY (`id`),
+ KEY `k` (`k`)
+) ENGINE=ndbcluster;
+
+CREATE TABLE `t2` (
+  `evend_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+  `timestamp` int(11) NOT NULL,
+  `server_id` int(11) NOT NULL,
+   PRIMARY KEY (`evend_id`)
+) ENGINE=ndbcluster;
+
+
+insert into t1 values (null,1,'',''),(null,2,'','');
+
+DELIMITER |;
+
+CREATE TRIGGER tr1
+  AFTER UPDATE ON t1
+  FOR EACH ROW
+  BEGIN
+    insert into t2(timestamp, server_id) values(UNIX_TIMESTAMP(),@@global.server_id);
+  end;
+|
+
+DELIMITER ;|
+
+connection server2;
+
+DELIMITER |;
+
+CREATE TRIGGER tr1
+  AFTER UPDATE ON t1
+  FOR EACH ROW
+  BEGIN
+    insert into t2(timestamp, server_id) values(UNIX_TIMESTAMP(),@@global.server_id);
+  end;
+|
+
+DELIMITER ;|
+
+connection server1;
+update t1 set c='foobar' where id=1;
+connection server2;
+update t1 set c='foobar' where id=1;
+connection server1;
+update t1 set c='foobar' where id=1;
+connection server2;
+update t1 set c='foobar' where id=1;
+connection server1;
+update t1 set c='foobar' where id=1;
+connection server2;
+update t1 set c='foobar' where id=1;
+connection server1;
+update t1 set c='foobar' where id=1;
+connection server2;
+update t1 set c='foobar' where id=1;
+connection server1;
+select evend_id,server_id from t2 order by evend_id;
+
+drop trigger tr1;
+drop table t1, t2;
+
+connection server2;
+--disable_warnings
+drop trigger if exists tr1;
+--enable_warnings

Thread
bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2976) Bug#46712Martin Skold3 Sep