Add test for 10.1 compound statements

The test executes a compound statement through MaxScale and checks that it
is routed correctly to the master.
This commit is contained in:
Markus Mäkelä 2017-12-20 11:57:43 +02:00
parent 2008d08cfc
commit 0e8bdeae13
2 changed files with 42 additions and 0 deletions

View File

@ -628,6 +628,9 @@ add_test_executable(script.cpp script script LABELS maxscale REPL_BACKEND)
# Test 10.3 SEQUENCE objects
add_test_executable(sequence.cpp sequence replication LABELS LIGHT)
# Test 10.1 compound statements
add_test_executable(compound_statement.cpp compound_statement replication LABELS LIGHT)
# Check if 'weightby' parameter works
add_test_executable(server_weight.cpp server_weight galera.weight LABELS readwritesplit readconnroute LIGHT GALERA_BACKEND)

View File

@ -0,0 +1,39 @@
/**
* Test 10.1 compound statements
*/
#include "testconnections.h"
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
const char* sql =
"BEGIN NOT ATOMIC\n"
" DECLARE EXIT HANDLER FOR SQLEXCEPTION\n"
" BEGIN \n"
" ROLLBACK;\n"
" RESIGNAL;\n"
" END;\n"
" START TRANSACTION;\n"
" INSERT INTO test.t1 VALUES (1);\n"
" UPDATE test.t1 SET id = 2 WHERE id = 1;\n"
" COMMIT;\n"
"END\n";
test.maxscales->connect();
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE TABLE test.t1(id INT)");
test.try_query(test.maxscales->conn_rwsplit[0], sql);
// Do the select inside a transacttion so that it gets routed to the master
test.try_query(test.maxscales->conn_rwsplit[0], "BEGIN");
test.assert(execute_query_check_one(test.maxscales->conn_rwsplit[0], "SELECT id FROM test.t1", "2") == 0,
"Table should contain one row with value 2");
test.try_query(test.maxscales->conn_rwsplit[0], "COMMIT");
test.try_query(test.maxscales->conn_rwsplit[0], "DROP TABLE test.t1");
test.maxscales->disconnect();
test.check_maxscale_alive();
return test.global_result;
}