Changed how query classifier determines which statements trigger implicit commit.

Changed test makefile and rwsplit.sh script and added two example sql scripts.
This commit is contained in:
VilhoRaatikka
2014-03-26 19:10:35 +02:00
parent df02926321
commit f49df89a0c
5 changed files with 86 additions and 28 deletions

View File

@ -14,12 +14,14 @@ cleantests:
- $(DEL) *.o
- $(DEL) *~
testall:
$(MAKE) cleantests
$(MAKE) DEBUG=Y buildtests
$(MAKE) runtests
buildtests :
testall:
-$(MAKE) cleantests
-$(MAKE) DEBUG=Y buildtests
-$(MAKE) runtests
buildtests:
runtests:
@echo "" >> $(TESTLOG)
@ -27,13 +29,14 @@ runtests:
@echo $(shell date) >> $(TESTLOG)
@echo "Test MaxScale R/W Split" >> $(TESTLOG)
@echo "-------------------------------" >> $(TESTLOG)
ifeq ($(shell ./rwsplit.sh $(TESTLOG) 127.0.0.1 4006 maxuser maxpwd ; echo $$?), 0)
@echo "MaxScale core PASSED" >> $(TESTLOG)
else
@echo "MaxScale core FAILED" >> $(TESTLOG) ; exit 1
endif
./rwsplit.sh $(TESTLOG) test_transaction_routing1.sql 127.0.0.1 4006 maxuser maxpwd
./rwsplit.sh $(TESTLOG) test_transaction_routing2.sql 127.0.0.1 4006 maxuser maxpwd
./rwsplit.sh $(TESTLOG) test_transaction_routing3.sql 127.0.0.1 4006 maxuser maxpwd
@echo "" >> $(TESTLOG)
pesce:
@echo "fine"

View File

@ -1,14 +1,30 @@
#!/bin/sh
NARGS=6
TLOG=$1
THOST=$2
TPORT=$3
TUSER=$4
TPWD=$5
TINPUT=$2
THOST=$3
TPORT=$4
TUSER=$5
TPWD=$6
if [ $# != $NARGS ] ;
then
echo""
echo "Wrong number of arguments, gave "$#" but "$NARGS" is required"
echo ""
echo "Usage :"
echo " rwsplit.sh <log filename> <test input> <host> <port> <user> <password>"
echo ""
exit 1
fi
RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent
INPUT=test_transaction_routing1.sql
a=`$RUNCMD < ./$INPUT`
if [ "$a" != "2" ]; then echo "$INPUT FAILED">>$TLOG; exit 1 ;
else echo "$INPUT PASSED">>$TLOG ; fi
a=`$RUNCMD < ./$TINPUT`
if [ "$a" != "2" ]; then
echo "$TINPUT FAILED">>$TLOG;
else
echo "$TINPUT PASSED">>$TLOG ;
fi

View File

@ -6,16 +6,14 @@ 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;
-- Now there are two values
COMMIT;
START TRANSACTION;
DELETE FROM myCity;
-- Now there are zero values
SET @a = (SELECT COUNT(1) FROM myCity); -- implicit COMMIT for DELETE operation
ROLLBACK; -- nothing to roll back
SET @a = (SELECT COUNT(1) FROM myCity);
ROLLBACK;
START TRANSACTION;
SET @b = (SELECT COUNT(*) FROM myCity); -- implicit COMMIT for empty trx
SET @b = (SELECT COUNT(*) FROM myCity);
START TRANSACTION;
DROP TABLE myCity;
SELECT (@a+@b) AS res; -- counts 0+0 ans sets the result to 'res'
SELECT (@a+@b) AS res;
COMMIT;

View File

@ -0,0 +1,7 @@
SET autocommit = 1;
SELECT @@server_id INTO @a;
START TRANSACTION;
SELECT @@server_id INTO @b;
COMMIT;
SELECT (@a-@b) INTO @c;
SELECT @a, @b, @c;