forked from mariadb-corporation/MaxScale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrash_on_bad_sescmd.cc
84 lines (74 loc) · 2.17 KB
/
crash_on_bad_sescmd.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright (c) 2016 MariaDB Corporation Ab
* Copyright (c) 2023 MariaDB plc, Finnish Branch
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2027-04-10
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
/**
* Double-close on bad session command result
*/
#include <maxtest/testconnections.hh>
void run_test(TestConnections& test)
{
Connection conn = test.maxscale->rwsplit();
conn.connect();
for (int i = 0; i <= 300 && test.global_result == 0; i++)
{
if (conn.query("SET @a = 1")
&& conn.query("USE test")
&& conn.query("SET SQL_MODE=''")
&& conn.query("USE test")
&& conn.query("SELECT @@last_insert_id")
&& conn.query("SELECT 1")
&& conn.query("USE test")
&& conn.query("SELECT 1")
&& conn.query("SET @a = 123")
&& conn.query("BEGIN")
&& conn.query("SELECT @a")
&& conn.query("COMMIT")
&& conn.query("SET @a = 321")
&& conn.query("SELECT @a")
&& conn.query("SET @a = 456")
&& conn.query("START TRANSACTION READ ONLY")
&& conn.query("SELECT @a")
&& conn.query("COMMIT")
&& conn.query("PREPARE ps FROM 'SELECT 1'")
&& conn.query("EXECUTE ps")
&& conn.query("DEALLOCATE PREPARE ps"))
{
conn.reset_connection();
}
else
{
break;
}
}
}
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
std::vector<std::thread> threads;
for (int i = 0; i < 5; i++)
{
threads.emplace_back(run_test, std::ref(test));
}
for (int i = 0; i < 5; i++)
{
test.repl->stop_node(1 + i % 3);
test.maxscale->wait_for_monitor();
test.repl->start_node(1 + i % 3);
test.maxscale->wait_for_monitor();
}
for (auto& a : threads)
{
a.join();
}
return test.global_result;
}