From c86e25eeb8e1b5e5dfec458363f70933fc0c2da2 Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Mon, 7 Apr 2014 17:00:31 +0300 Subject: [PATCH] Added a test for implicitly started trasnaction. --- server/modules/routing/readwritesplit/test/rwsplit.sh | 10 ++++++++++ .../readwritesplit/test/test_transaction_routing4.sql | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 server/modules/routing/readwritesplit/test/test_transaction_routing4.sql diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh index 4755e4526..a4ffa7cde 100755 --- a/server/modules/routing/readwritesplit/test/rwsplit.sh +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -39,6 +39,16 @@ else echo "$TINPUT PASSED">>$TLOG ; fi +# test implicit transaction, that is, not started explicitly, autocommit=0 +TINPUT=test_transaction_routing4.sql +TRETVAL=0 +a=`$RUNCMD < ./$TINPUT` +if [ "$a" != "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + # set a var via SELECT INTO @, get data from master, returning server-id: put master server-id value in TRETVAL TINPUT=select_for_var_set.sql TRETVAL=$TMASTER_ID diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing4.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing4.sql new file mode 100644 index 000000000..6ba4ccc04 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing4.sql @@ -0,0 +1,9 @@ +USE test; +SET autocommit = 0; +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;