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:
parent
2008d08cfc
commit
0e8bdeae13
@ -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)
|
||||
|
||||
|
39
maxscale-system-test/compound_statement.cpp
Normal file
39
maxscale-system-test/compound_statement.cpp
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user