diff --git a/server/modules/routing/readwritesplit/test/test_autocommit_disabled1b.sql b/server/modules/routing/readwritesplit/test/test_autocommit_disabled1b.sql new file mode 100644 index 000000000..fb3ff8d59 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_autocommit_disabled1b.sql @@ -0,0 +1,7 @@ +use test; +drop table if exists t1; +create table t1 (id integer); +set autocommit=OFF; -- open transaction +insert into t1 values(1); -- write to master +select count(*) from t1; -- read from master +drop table t1; diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing2b.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing2b.sql new file mode 100644 index 000000000..4e8c65d35 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing2b.sql @@ -0,0 +1,11 @@ +USE test; +SET autocommit = Off; +START TRANSACTION; +CREATE TABLE IF NOT EXISTS myCity (a int, b char(20)); +INSERT INTO myCity VALUES (1, 'Milan'); +INSERT INTO myCity VALUES (2, 'London'); +COMMIT; +START TRANSACTION; +DELETE FROM myCity; +SELECT COUNT(*) FROM myCity; -- read transaction's modifications from master +COMMIT; \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing3b.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing3b.sql new file mode 100644 index 000000000..aa59f17ef --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing3b.sql @@ -0,0 +1,7 @@ +-- Read from slave after implicit COMMIT +USE test; +START TRANSACTION; +CREATE TABLE IF NOT EXISTS T2 (id integer); +INSERT INTO T2 VALUES (@@server_id); +SET AUTOCOMMIT=oN; +SELECT id from T2; -- read transaction's modifications from slave diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing4b.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing4b.sql new file mode 100644 index 000000000..6190ff224 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing4b.sql @@ -0,0 +1,9 @@ +USE test; +SET autocommit = oFf; +CREATE TABLE IF NOT EXISTS myCity (a int, b char(20)); +INSERT INTO myCity VALUES (1, 'Milan'); +INSERT INTO myCity VALUES (2, 'London'); +COMMIT; +DELETE FROM myCity; -- implicit transaction started +SELECT COUNT(*) FROM myCity; -- read transaction's modifications from master +COMMIT;