List:Commits« Previous MessageNext Message »
From:Craig L Russell Date:April 21 2011 9:50pm
Subject:bzr push into mysql-5.1-telco-7.1-coord branch (Craig.Russell:4039 to 4040)
View as plain text  
 4040 Craig L Russell	2011-04-21
      Add test case for coordinated transactions updating the same row

    added:
      mysql-test/suite/ndb/r/ndb_coord4.result
      mysql-test/suite/ndb/t/ndb_coord4.test
 4039 Craig L Russell	2011-04-19
      Add mtr test cases for coordinated transaction visibility

    added:
      mysql-test/suite/ndb/r/ndb_coord2.result
      mysql-test/suite/ndb/r/ndb_coord3.result
      mysql-test/suite/ndb/t/ndb_coord2.test
      mysql-test/suite/ndb/t/ndb_coord3.test
=== added file 'mysql-test/suite/ndb/r/ndb_coord4.result'
--- a/mysql-test/suite/ndb/r/ndb_coord4.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/r/ndb_coord4.result	2011-04-21 21:50:20 +0000
@@ -0,0 +1,59 @@
+CREATE TABLE t1 (
+pk INT NOT NULL PRIMARY KEY,
+attr1 INT NOT NULL,
+attr2 INT,
+attr3 VARCHAR(10),
+unique(attr2)
+) ENGINE=ndbcluster;
+insert into t1 values(1,1,1,'1');
+begin;
+insert into t1 values(2,2,2,'2');
+begin;
+set ndb_join_transaction_id='<tid>';
+update t1 set attr1 = 3 where pk = 2;
+select * from t1 where pk = 2;
+pk	attr1	attr2	attr3
+2	3	2	2
+commit;
+commit;
+select * from t1 where pk = 2;
+pk	attr1	attr2	attr3
+2	3	2	2
+begin;
+insert into t1 values(3,3,3,'3');
+begin;
+set ndb_join_transaction_id='<tid>';
+update t1 set attr1 = 4 where pk = 3;
+select * from t1 where pk = 3;
+pk	attr1	attr2	attr3
+3	4	3	3
+commit;
+commit;
+select * from t1 where pk = 3;
+pk	attr1	attr2	attr3
+3	4	3	3
+begin;
+insert into t1 values(4,4,4,'4');
+begin;
+set ndb_join_transaction_id='<tid>';
+update t1 set attr1 = 5 where pk = 4;
+select * from t1 where pk = 4;
+pk	attr1	attr2	attr3
+4	5	4	4
+rollback;
+rollback;
+select * from t1 where pk = 4;
+pk	attr1	attr2	attr3
+begin;
+insert into t1 values(5,5,5,'5');
+begin;
+set ndb_join_transaction_id='<tid>';
+update t1 set attr1 = 6 where pk = 5;
+select * from t1 where pk = 5;
+pk	attr1	attr2	attr3
+5	6	5	5
+rollback;
+rollback;
+select * from t1 where pk = 5;
+pk	attr1	attr2	attr3
+drop table t1;

=== added file 'mysql-test/suite/ndb/t/ndb_coord4.test'
--- a/mysql-test/suite/ndb/t/ndb_coord4.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/ndb_coord4.test	2011-04-21 21:50:20 +0000
@@ -0,0 +1,147 @@
+-- source include/have_ndb.inc
+
+#
+# Create a normal table with primary key
+#
+CREATE TABLE t1 (
+  pk INT NOT NULL PRIMARY KEY,
+  attr1 INT NOT NULL,
+  attr2 INT,
+  attr3 VARCHAR(10),
+  unique(attr2)
+) ENGINE=ndbcluster;
+insert into t1 values(1,1,1,'1');
+
+connect (con1,localhost,root,,test);
+connect (con2,localhost,root,,test);
+
+# A. insert original, update joined, commit original, commit joined
+
+# insert in original transaction
+
+connection con1;
+begin;
+insert into t1 values(2,2,2,'2');
+let $tid = `select @@ndb_transaction_id`;
+
+# update in joined transaction
+
+connection con2;
+begin;
+--replace_result $tid <tid>
+eval set ndb_join_transaction_id='$tid';
+update t1 set attr1 = 3 where pk = 2;
+select * from t1 where pk = 2;
+
+# commit original transaction
+
+connection con1;
+commit;
+
+# commit joined transaction
+
+connection con2;
+commit;
+
+# select in new transaction
+
+select * from t1 where pk = 2;
+
+# B. insert original, update joined, commit joined, commit original
+
+# insert in original transaction
+
+connection con1;
+begin;
+insert into t1 values(3,3,3,'3');
+let $tid = `select @@ndb_transaction_id`;
+
+# update in joined transaction
+
+connection con2;
+begin;
+--replace_result $tid <tid>
+eval set ndb_join_transaction_id='$tid';
+update t1 set attr1 = 4 where pk = 3;
+select * from t1 where pk = 3;
+
+# commit joined transaction
+
+connection con2;
+commit;
+
+# commit original transaction
+
+connection con1;
+commit;
+
+# select in new transaction
+
+select * from t1 where pk = 3;
+
+# C. insert original, update joined, roll back original, roll back joined
+
+# insert in original transaction
+
+connection con1;
+begin;
+insert into t1 values(4,4,4,'4');
+let $tid = `select @@ndb_transaction_id`;
+
+# update in joined transaction
+
+connection con2;
+begin;
+--replace_result $tid <tid>
+eval set ndb_join_transaction_id='$tid';
+update t1 set attr1 = 5 where pk = 4;
+select * from t1 where pk = 4;
+
+# roll back original transaction
+
+connection con1;
+rollback;
+
+# roll back joined transaction
+
+connection con2;
+rollback;
+
+# select in new transaction no results because insert row 4 was rolled back
+
+select * from t1 where pk = 4;
+
+# D. insert original, update joined, roll back joined, roll back original
+
+# insert in original transaction
+
+connection con1;
+begin;
+insert into t1 values(5,5,5,'5');
+let $tid = `select @@ndb_transaction_id`;
+
+# update in joined transaction
+
+connection con2;
+begin;
+--replace_result $tid <tid>
+eval set ndb_join_transaction_id='$tid';
+update t1 set attr1 = 6 where pk = 5;
+select * from t1 where pk = 5;
+
+# roll back joined transaction
+
+connection con2;
+rollback;
+
+# roll back original transaction
+
+connection con1;
+rollback;
+
+# select in new transaction no results because insert row 5 was rolled back
+
+select * from t1 where pk = 5;
+
+drop table t1;
+


Attachment: [text/bzr-bundle] bzr/craig.russell@oracle.com-20110421215020-xizlwp99pniyy5hy.bundle
Thread
bzr push into mysql-5.1-telco-7.1-coord branch (Craig.Russell:4039 to 4040)Craig L Russell21 Apr