diff --git a/Documentation/Debug And Diagnostic Support.pdf b/Documentation/Debug And Diagnostic Support.pdf index 07a584780..6a9697372 100644 Binary files a/Documentation/Debug And Diagnostic Support.pdf and b/Documentation/Debug And Diagnostic Support.pdf differ diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index 54a9e5968..022523488 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -674,7 +674,7 @@ static int logmanager_write_log( if (use_valist) { vsnprintf(wp+timestamp_len, safe_str_len, str, valist); } else { - snprintf(wp+timestamp_len, safe_str_len, str); + snprintf(wp+timestamp_len, safe_str_len, "%s", str); } /** write to syslog */ @@ -682,11 +682,11 @@ static int logmanager_write_log( { switch(id) { case LOGFILE_ERROR: - syslog(LOG_ERR, wp+timestamp_len); + syslog(LOG_ERR, "%s", wp+timestamp_len); break; case LOGFILE_MESSAGE: - syslog(LOG_NOTICE, wp+timestamp_len); + syslog(LOG_NOTICE, "%s", wp+timestamp_len); break; default: @@ -742,7 +742,7 @@ static int logmanager_write_log( * Copy original string from block buffer to * other logs' block buffers. */ - snprintf(wp_c, timestamp_len+str_len, wp); + snprintf(wp_c, timestamp_len+str_len, "%s", wp); /** remove double line feed */ if (wp_c[timestamp_len-1+str_len-2] == '\n') diff --git a/makefile.inc b/makefile.inc index a0615b797..657ebf849 100644 --- a/makefile.inc +++ b/makefile.inc @@ -22,6 +22,7 @@ ifdef DYNLIB LIB := libmysqld.so.18 endif +# -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fPIC CFLAGS := $(CFLAGS) -Wall LDLIBS := $(LDLIBS) -pthread @@ -32,7 +33,7 @@ CPP_LDLIBS := -lstdc++ # Compiler flags, httpd arguments and debugger options # ifdef DEBUG - DEBUG_FLAGS := -DSS_DEBUG +DEBUG_FLAGS := -DSS_DEBUG -pipe -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4 -fPIC CFLAGS := $(CFLAGS) -ggdb -O0 -pthread $(DEBUG_FLAGS) endif diff --git a/maxscale.conf b/maxscale.conf new file mode 100644 index 000000000..a381124f4 --- /dev/null +++ b/maxscale.conf @@ -0,0 +1,2 @@ +/usr/local/sbin/MaxScale/modules +/usr/local/sbin/lib diff --git a/maxscale.spec b/maxscale.spec index b1a42d1ff..c8d12ba2f 100644 --- a/maxscale.spec +++ b/maxscale.spec @@ -2,7 +2,6 @@ %define name maxscale %define release ##RELEASE_TAG## %define version ##VERSION_TAG## -%define buildroot %{_topdir}/%{name}-%{version}-%{release}root %define install_path /usr/local/sbin/ BuildRoot: %{buildroot} @@ -15,7 +14,7 @@ Source: %{name}-%{version}-%{release}.tar.gz Prefix: / Group: Development/Tools #Requires: -BuildRequires: gcc gcc-c++ ncurses-devel bison glibc-devel cmake libgcc perl make libtool openssl-devel +BuildRequires: gcc gcc-c++ ncurses-devel bison glibc-devel cmake libgcc perl make libtool openssl-devel libaio MariaDB-devel MariaDB-server %description MaxScale @@ -25,22 +24,27 @@ MaxScale %setup -q %build -MARIADB_SRC_PATH=/home/ec2-user/.jenkins/jobs/MariaDB_for_MaxScale/workspace -make ROOT_PATH=`pwd` MARIADB_SRC_PATH=$MARIADB_SRC_PATH depend -make ROOT_PATH=`pwd` MARIADB_SRC_PATH=$MARIADB_SRC_PATH -make DEST=`pwd`/binaries ROOT_PATH=`pwd` MARIADB_SRC_PATH=$MARIADB_SRC_PATH install +ln -s /lib64/libaio.so.1 /lib64/libaio.so +make ROOT_PATH=`pwd` HOME="" clean +make ROOT_PATH=`pwd` HOME="" depend +make ROOT_PATH=`pwd` HOME="" +make DEST=`pwd`/binaries ROOT_PATH=`pwd` HOME="" ERRMSG="/usr/share/mysql/english" install %post +ln -s /lib64/libaio.so.1 /lib64/libaio.so +/sbin/ldconfig %install +mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d/ mkdir -p $RPM_BUILD_ROOT%{install_path} cp -r binaries/* $RPM_BUILD_ROOT%{install_path} +cp maxscale.conf $RPM_BUILD_ROOT/etc/ld.so.conf.d/ %clean %files %defattr(-,root,root) %{install_path} +/etc/ld.so.conf.d/maxscale.conf %changelog - diff --git a/query_classifier/query_classifier.cc b/query_classifier/query_classifier.cc index 24cacd53c..1976bd6b2 100644 --- a/query_classifier/query_classifier.cc +++ b/query_classifier/query_classifier.cc @@ -73,6 +73,9 @@ static bool create_parse_tree( static skygw_query_type_t resolve_query_type( THD* thd); +static bool skygw_stmt_causes_implicit_commit( + LEX* lex, + uint mask); /** * @node (write brief function description here) @@ -393,6 +396,44 @@ static skygw_query_type_t resolve_query_type( type = QUERY_TYPE_SESSION_WRITE; goto return_qtype; } + + if (skygw_stmt_causes_implicit_commit(lex, CF_AUTO_COMMIT_TRANS)) + { + if (LOG_IS_ENABLED(LOGFILE_TRACE)) + { + if (sql_command_flags[lex->sql_command] & + CF_IMPLICT_COMMIT_BEGIN) + { + skygw_log_write( + LOGFILE_TRACE, + "Implicit COMMIT before executing the " + "next command."); + } + else if (sql_command_flags[lex->sql_command] & + CF_IMPLICIT_COMMIT_END) + { + skygw_log_write( + LOGFILE_TRACE, + "Implicit COMMIT after executing the " + "next command."); + } + } + type |= QUERY_TYPE_COMMIT; + } + /** + * REVOKE ALL, ASSIGN_TO_KEYCACHE, + * PRELOAD_KEYS, FLUSH, RESET, CREATE|ALTER|DROP SERVER + */ + if (lex->option_type == OPT_GLOBAL) + { + type |= QUERY_TYPE_GLOBAL_WRITE; + goto return_qtype; + } + else if (lex->option_type == OPT_SESSION) + { + type |= QUERY_TYPE_SESSION_WRITE; + goto return_qtype; + } /** * 1:ALTER TABLE, TRUNCATE, REPAIR, OPTIMIZE, ANALYZE, CHECK. * 2:CREATE|ALTER|DROP|TRUNCATE|RENAME TABLE, LOAD, CREATE|DROP|ALTER DB, @@ -415,26 +456,10 @@ static skygw_query_type_t resolve_query_type( goto return_qtype; } - - /** - * REVOKE ALL, ASSIGN_TO_KEYCACHE, - * PRELOAD_KEYS, FLUSH, RESET, CREATE|ALTER|DROP SERVER - */ - if (sql_command_flags[lex->sql_command] & CF_AUTO_COMMIT_TRANS) { - if (lex->option_type == OPT_GLOBAL) - { - type |= (QUERY_TYPE_GLOBAL_WRITE|QUERY_TYPE_COMMIT); - } - else - { - type |= (QUERY_TYPE_SESSION_WRITE|QUERY_TYPE_COMMIT); - } - goto return_qtype; - } /** Try to catch session modifications here */ switch (lex->sql_command) { - case SQLCOM_SET_OPTION: + case SQLCOM_SET_OPTION: /*< SET commands. */ if (lex->option_type == OPT_GLOBAL) { type |= QUERY_TYPE_GLOBAL_WRITE; @@ -622,3 +647,34 @@ return_qtype: qtype = (skygw_query_type_t)type; return qtype; } + +static bool skygw_stmt_causes_implicit_commit(LEX* lex, uint mask) +{ + bool succp; + + if (!(sql_command_flags[lex->sql_command] & mask)) + { + succp = false; + goto return_succp; + } + + switch (lex->sql_command) { + case SQLCOM_DROP_TABLE: + succp = !(lex->drop_temporary); + break; + case SQLCOM_ALTER_TABLE: + case SQLCOM_CREATE_TABLE: + /* If CREATE TABLE of non-temporary table, do implicit commit */ + succp = !(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE); + break; + case SQLCOM_SET_OPTION: + succp = lex->autocommit ? true : false; + break; + default: + succp = true; + break; + } + +return_succp: + return succp; +} diff --git a/script/make-binary-tarball.sh b/script/make-binary-tarball.sh index 33644169b..416a10675 100755 --- a/script/make-binary-tarball.sh +++ b/script/make-binary-tarball.sh @@ -22,7 +22,7 @@ else exit 1 fi -MAXSCALE_BINARY_TARFILE=maxscale.preview.${MAXSCALE_VERSION}.tar +MAXSCALE_BINARY_TARFILE=maxscale.${MAXSCALE_VERSION}.tar TARFILE_BASEDIR=maxscale-${MAXSCALE_VERSION} TARFILE_BASEDIR_SUBST='s,^\.,'${TARFILE_BASEDIR}',' diff --git a/script/make-source-tarball.sh b/script/make-source-tarball.sh index 564aba441..a7ad4c41a 100755 --- a/script/make-source-tarball.sh +++ b/script/make-source-tarball.sh @@ -39,7 +39,7 @@ else exit 1 fi -MAXSCALE_SOURCE_TARFILE=maxscale.src.preview.${MAXSCALE_VERSION}.tar +MAXSCALE_SOURCE_TARFILE=maxscale.src.${MAXSCALE_VERSION}.tar TARFILE_BASEDIR=maxscale-${MAXSCALE_VERSION} TARFILE_BASEDIR_SUBST='s,^\.,'${TARFILE_BASEDIR}',' diff --git a/server/MaxScale_template.cnf b/server/MaxScale_template.cnf index bbda5451e..e89c2516a 100644 --- a/server/MaxScale_template.cnf +++ b/server/MaxScale_template.cnf @@ -72,24 +72,29 @@ router=debugcli # service= # protocol= # port= +# address=
+# socket= [RW Split Listener] type=listener service=RW Split Router protocol=MySQLClient port=4006 +#socket=/tmp/rwsplit.sock [Read Connection Listener] type=listener service=Read Connection Router protocol=MySQLClient port=4008 +#socket=/tmp/readconn.sock [Debug Listener] type=listener service=Debug Interface protocol=telnetd port=4442 +#address=127.0.0.1 [HTTPD Listener] type=listener diff --git a/server/core/dbusers.c b/server/core/dbusers.c index 66e972c08..e5289a3a0 100644 --- a/server/core/dbusers.c +++ b/server/core/dbusers.c @@ -304,7 +304,7 @@ getUsers(SERVICE *service, struct users *users) } num_fields = mysql_num_fields(result); - users_data = (char *)malloc(nusers * (users_data_row_len * sizeof(char)) + 1); + users_data = (char *)calloc(nusers, (users_data_row_len * sizeof(char)) + 1); if(users_data == NULL) return -1; @@ -571,7 +571,7 @@ char *mysql_format_user_entry(void *data) if (entry->ipv4.sin_addr.s_addr == INADDR_ANY) { snprintf(mysql_user, mysql_user_len, "%s@%%", entry->user); } else { - snprintf(mysql_user, MYSQL_USER_MAXLEN, entry->user); + strncpy(mysql_user, entry->user, MYSQL_USER_MAXLEN); strcat(mysql_user, "@"); inet_ntop(AF_INET, &(entry->ipv4).sin_addr, mysql_user+strlen(mysql_user), INET_ADDRSTRLEN); } diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 15b1295af..5383c1eb6 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -670,6 +670,13 @@ static int routeQuery( "Packet type\t%s", STRPACKETTYPE(packet_type)))); + if (QUERY_IS_TYPE(qtype,QUERY_TYPE_COMMIT) && + transaction_active) + { + transaction_active = false; + } + + switch (qtype) { case QUERY_TYPE_WRITE: LOGIF(LT, (skygw_log_write( @@ -724,12 +731,6 @@ static int routeQuery( break; case QUERY_TYPE_SESSION_WRITE: - case (QUERY_TYPE_SESSION_WRITE|QUERY_TYPE_COMMIT): - if (QUERY_IS_TYPE(qtype,QUERY_TYPE_COMMIT) && - transaction_active) - { - transaction_active = false; - } /** * Execute in backends used by current router session. * Save session variable commands to router session property diff --git a/server/modules/routing/readwritesplit/test/makefile b/server/modules/routing/readwritesplit/test/makefile new file mode 100644 index 000000000..096e28fe7 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/makefile @@ -0,0 +1,41 @@ +# cleantests - clean local and subdirectories' tests +# buildtests - build all local and subdirectories' tests +# runtests - run all local tests +# testall - clean, build and run local and subdirectories' tests + +include ../../../../../build_gateway.inc +include $(ROOT_PATH)/makefile.inc +include $(ROOT_PATH)/test.inc + +CC=cc +TESTLOG := $(shell pwd)/testrouters.log +RET := -1 + +cleantests: + - $(DEL) *.o + - $(DEL) *~ + + +testall: + -$(MAKE) cleantests + -$(MAKE) DEBUG=Y buildtests + -$(MAKE) runtests + +buildtests: + + +runtests: + @echo "" >> $(TESTLOG) + @echo "-------------------------------" >> $(TESTLOG) + @echo $(shell date) >> $(TESTLOG) + @echo "Test MaxScale R/W Split" >> $(TESTLOG) + @echo "-------------------------------" >> $(TESTLOG) + ./rwsplit.sh $(TESTLOG) $(THOST) $(TPORT_RW) $(TMASTER_ID) $(TUSER) $(TPWD) + @echo "" >> $(TESTLOG) + + +pesce: + @echo "fine" + + + \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh new file mode 100755 index 000000000..4755e4526 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -0,0 +1,115 @@ +#!/bin/sh +NARGS=6 +TLOG=$1 +THOST=$2 +TPORT=$3 +TMASTER_ID=$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 " +echo "" +exit 1 +fi + + +RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent + +TINPUT=test_transaction_routing2.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 + +TINPUT=test_transaction_routing3.sql +TRETVAL=2 +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 + +a=`$RUNCMD < ./$TINPUT` +if [ "$a" != "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit1.sql +TRETVAL=$TMASTER_ID + +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit2.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit3.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit4.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" != "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when $TRETVAL was expected">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit5.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit6.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi + +TINPUT=test_implicit_commit7.sql +TRETVAL=$TMASTER_ID +a=`$RUNCMD < ./$TINPUT` +if [ "$a" == "$TRETVAL" ]; then + echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG; +else + echo "$TINPUT PASSED">>$TLOG ; +fi diff --git a/server/modules/routing/readwritesplit/test/select_for_var_set.sql b/server/modules/routing/readwritesplit/test/select_for_var_set.sql new file mode 100644 index 000000000..ecf484f51 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/select_for_var_set.sql @@ -0,0 +1,5 @@ +-- simple read with variable from master +BEGIN; +SELECT (@@server_id) INTO @a; +SELECT @a; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit1.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit1.sql new file mode 100644 index 000000000..663c32efa --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit1.sql @@ -0,0 +1,8 @@ +DROP DATABASE If EXISTS FOO; +SET autocommit=0; +BEGIN; +CREATE DATABASE FOO; -- implicit commit +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP DATABASE If EXISTS FOO; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit2.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit2.sql new file mode 100644 index 000000000..80f0ebad1 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit2.sql @@ -0,0 +1,15 @@ +USE test; +DROP TABLE IF EXISTS T1; +DROP EVENT IF EXISTS myevent; +SET autocommit=0; +BEGIN; +CREATE TABLE T1 (id integer); +CREATE EVENT myevent +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR +DO +UPDATE t1 SET id = id + 1; +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP TABLE IF EXISTS T1; +DROP EVENT IF EXISTS myevent; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit3.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit3.sql new file mode 100644 index 000000000..4db36fdd5 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit3.sql @@ -0,0 +1,9 @@ +USE test; +DROP TABLE IF EXISTS T1; +SET autocommit=0; +BEGIN; +CREATE TABLE T1 (id integer); -- implicit commit +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP TABLE IF EXISTS T1; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit4.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit4.sql new file mode 100644 index 000000000..f7fe048be --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit4.sql @@ -0,0 +1,9 @@ +USE test; +DROP TABLE IF EXISTS T1; +SET autocommit=0; +BEGIN; +CREATE TEMPORARY TABLE T1 (id integer); -- NO implicit commit +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from master +DROP TABLE IF EXISTS T1; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit5.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit5.sql new file mode 100644 index 000000000..3656f1af8 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit5.sql @@ -0,0 +1,14 @@ +USE test; +DROP PROCEDURE IF EXISTS simpleproc; +SET autocommit=0; +BEGIN; +DELIMITER // +CREATE PROCEDURE simpleproc (OUT param1 INT) +BEGIN + SELECT COUNT(*) INTO param1 FROM t; +END // +DELIMITER ; +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP PROCEDURE IF EXISTS simpleproc; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit6.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit6.sql new file mode 100644 index 000000000..ba896966d --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit6.sql @@ -0,0 +1,11 @@ +USE test; +DROP FUNCTION IF EXISTS hello; +SET autocommit=0; +BEGIN; +CREATE FUNCTION hello (s CHAR(20)) +RETURNS CHAR(50) DETERMINISTIC +RETURN CONCAT('Hello, ',s,'!'); -- implicit COMMIT +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP FUNCTION IF EXISTS hello; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_implicit_commit7.sql b/server/modules/routing/readwritesplit/test/test_implicit_commit7.sql new file mode 100644 index 000000000..9b3c5bac7 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_implicit_commit7.sql @@ -0,0 +1,10 @@ +USE test; +DROP TABLE IF EXISTS T1; +CREATE TABLE T1 (id integer); -- implicit commit +SET autocommit=0; +BEGIN; +CREATE INDEX foo_t1 on T1 (id); -- implicit commit +SELECT (@@server_id) INTO @a; +SELECT @a; --should read from slave +DROP TABLE IF EXISTS T1; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing1.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing1.sql new file mode 100644 index 000000000..af17eb3d5 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing1.sql @@ -0,0 +1,19 @@ +USE test; +SET autocommit = 0; +SET @a= -1; +SET @b= -2; +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; +SET @a = (SELECT COUNT(*) FROM myCity); +ROLLBACK; +START TRANSACTION; +SET @b = (SELECT COUNT(*) FROM myCity); +START TRANSACTION; +DROP TABLE myCity; +SELECT (@a+@b) AS res; +COMMIT; diff --git a/server/modules/routing/readwritesplit/test/test_transaction_routing2.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing2.sql new file mode 100644 index 000000000..92c7f2ed6 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing2.sql @@ -0,0 +1,11 @@ +USE test; +SET autocommit = 0; +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_routing3.sql b/server/modules/routing/readwritesplit/test/test_transaction_routing3.sql new file mode 100644 index 000000000..895a88d80 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_transaction_routing3.sql @@ -0,0 +1,10 @@ +USE test; +SET autocommit = 0; +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; +DELETE FROM myCity; +SELECT COUNT(*) FROM myCity; -- read transaction's modifications from slave +COMMIT; \ No newline at end of file diff --git a/test.inc b/test.inc new file mode 100644 index 000000000..241772b0b --- /dev/null +++ b/test.inc @@ -0,0 +1,35 @@ +# +# This file includes parameters needed for running tests and may be included +# in makefiles in test directories if seen useful. +# +# hostname or IP address of MaxScale's host, for example: +# +# THOST := 127.0.0.1 +# +THOST := + +# +# port of read connection router module, for example: +# TPORT_RCONN := 4008 +# +TPORT_RCONN := +# +# port of read/write split router module, for example: +# TPORT_RW := 4006 +# +TPORT_RW := +# +# username of MaxScale user, for example: +# TUSER := maxuser +# +TUSER := +# +# password of MaxScale user, for example: +# TPWD := maxpwd +# +TPWD := +# +# master's server_id, for example: +# TMASTER_ID := 2 +# +TMASTER_ID := \ No newline at end of file