Enable and fix -Wextra warnings
Fixed all warnings that were present with -Wextra.
This commit is contained in:
parent
34f61bc4f2
commit
b98c0841b4
@ -20,7 +20,7 @@ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of
|
||||
build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
|
||||
Release RelWithDebInfo MinSizeRel.")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Wextra -Werror -Wno-format-overflow -Wno-unused-function -Wno-unused-parameter -Werror=format-security")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
|
||||
|
@ -48,7 +48,7 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long
|
||||
create_t1(Test->maxscales->conn_rwsplit[0]);
|
||||
create_insert_string(sql, sql_l, 1);
|
||||
|
||||
if ((execute_query(Test->maxscales->conn_rwsplit[0], sql) != 0) && (report_errors))
|
||||
if ((execute_query(Test->maxscales->conn_rwsplit[0], "%s", sql) != 0) && (report_errors))
|
||||
{
|
||||
Test->add_result(1, "Query %s failed\n", sql);
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ int big_transaction(MYSQL * conn, int N)
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
create_insert_string(sql, 10000, i);
|
||||
local_result += execute_query(conn, sql);
|
||||
local_result += execute_query(conn, "%s", sql);
|
||||
local_result += execute_query(conn, "CREATE TABLE t2(id int);");
|
||||
local_result += execute_query(conn, sql);
|
||||
local_result += execute_query(conn, "%s", sql);
|
||||
local_result += execute_query(conn, "DROP TABLE t2;");
|
||||
local_result += execute_query(conn, sql);
|
||||
local_result += execute_query(conn, "%s", sql);
|
||||
}
|
||||
|
||||
local_result += execute_query(conn, (char *) "COMMIT");
|
||||
|
@ -58,7 +58,7 @@ void *disconnect_thread( void *ptr )
|
||||
while (exit_flag == 0)
|
||||
{
|
||||
sprintf(cmd, "DISCONNECT SERVER %d", i);
|
||||
execute_query(conn, cmd);
|
||||
execute_query(conn, "%s", cmd);
|
||||
i++;
|
||||
if (i > Test->repl->N)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ int transaction(MYSQL * conn, int N)
|
||||
}
|
||||
|
||||
create_insert_string(sql, N_INSERTS, N);
|
||||
local_result += execute_query(conn, sql);
|
||||
local_result += execute_query(conn, "%s", sql);
|
||||
if (local_result != 0)
|
||||
{
|
||||
Test->tprintf("Insert Failed\n");
|
||||
@ -308,7 +308,7 @@ void select_new_master(TestConnections * test)
|
||||
sprintf(str, setup_slave1, test->repl->IP[2], maxscale_log_file_new, "4", test->repl->port[2]);
|
||||
}
|
||||
test->tprintf("change master query: %s\n", str);
|
||||
test->try_query(binlog, str);
|
||||
test->try_query(binlog, "%s", str);
|
||||
test->tprintf("start slave\n");
|
||||
test->try_query(binlog, "start slave");
|
||||
test->tprintf("start slave one more\n");
|
||||
@ -331,7 +331,7 @@ void *disconnect_thread( void *ptr )
|
||||
while (exit_flag == 0)
|
||||
{
|
||||
sprintf(cmd, "DISCONNECT SERVER %d", i);
|
||||
execute_query(conn, cmd);
|
||||
execute_query(conn, "%s", cmd);
|
||||
i++;
|
||||
if (i > Test->repl->N)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ int test_longblob(TestConnections* Test, MYSQL * conn, char * blob_name, unsigne
|
||||
Test->try_query(conn, (char *) "DROP TABLE IF EXISTS long_blob_table");
|
||||
sprintf(sql, "CREATE TABLE long_blob_table(id int NOT NULL AUTO_INCREMENT, x INT, b %s, PRIMARY KEY (id))",
|
||||
blob_name);
|
||||
Test->try_query(conn, sql);
|
||||
Test->try_query(conn, "%s", sql);
|
||||
|
||||
for (int k = 0; k < rows; k++)
|
||||
{
|
||||
|
@ -161,9 +161,9 @@ int main(int argc, char *argv[])
|
||||
master_conn[i] = Test->maxscales->open_readconn_master_connection(0);
|
||||
slave_conn[i] = Test->maxscales->open_readconn_slave_connection(0);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 1);", i);
|
||||
execute_query(rwsplit_conn[i], sql);
|
||||
execute_query(rwsplit_conn[i], "%s", sql);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i);
|
||||
execute_query(master_conn[i], sql);
|
||||
execute_query(master_conn[i], "%s", sql);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
slave_conn[i] = Test->maxscales->open_readconn_slave_connection(0);
|
||||
sprintf(sql, "SELECT * FROM t1");
|
||||
execute_query(slave_conn[i], sql);
|
||||
execute_query(slave_conn[i], "%s", sql);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ void drop(TestConnections& test)
|
||||
string stmt("DROP TABLE IF EXISTS cache_test");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void create(TestConnections& test)
|
||||
@ -40,7 +40,7 @@ void create(TestConnections& test)
|
||||
string stmt("CREATE TABLE cache_test (a INT)");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void insert(TestConnections& test)
|
||||
@ -50,7 +50,7 @@ void insert(TestConnections& test)
|
||||
string stmt("INSERT INTO cache_test VALUES (1)");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void update(TestConnections& test, int value)
|
||||
@ -61,7 +61,7 @@ void update(TestConnections& test, int value)
|
||||
stmt += std::to_string(value);
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void select(TestConnections& test, int* pValue)
|
||||
@ -118,7 +118,7 @@ void set(TestConnections& test, Cache::What what, bool value)
|
||||
stmt += (value ? "true" : "false");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void drop(TestConnections& test)
|
||||
string stmt("DROP TABLE IF EXISTS cache_test");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void create(TestConnections& test)
|
||||
@ -46,7 +46,7 @@ void create(TestConnections& test)
|
||||
string stmt("CREATE TABLE cache_test (a INT, b INT)");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void insert(TestConnections& test)
|
||||
@ -56,7 +56,7 @@ void insert(TestConnections& test)
|
||||
string stmt("INSERT INTO cache_test VALUES (1, 1)");
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void update(TestConnections& test, Column column, int value)
|
||||
@ -68,7 +68,7 @@ void update(TestConnections& test, Column column, int value)
|
||||
stmt += std::to_string(value);
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void select(TestConnections& test, Column column, int* pValue)
|
||||
@ -127,7 +127,7 @@ void set(TestConnections& test, Cache::What what, uint32_t value)
|
||||
stmt += std::to_string(value);
|
||||
|
||||
cout << stmt << endl;
|
||||
test.try_query(pMysql, stmt.c_str());
|
||||
test.try_query(pMysql, "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void *query_thread(void *ptr)
|
||||
char str[256];
|
||||
sprintf(str, "INSERT INTO t1 VALUES (%d, %d)", insert_val, insert_val + 100);
|
||||
insert_val = 0;
|
||||
execute_query(Test->repl->nodes[0], str);
|
||||
execute_query(Test->repl->nodes[0], "%s", str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ struct
|
||||
{ datetime_types, datetime_values },
|
||||
{ date_types, date_values },
|
||||
{ time_types, time_values },
|
||||
{ 0 }
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
void insert_data(TestConnections& test, const char *table, const char* type, const char** values)
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char *argv[])
|
||||
Test->set_timeout(60);
|
||||
sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i);
|
||||
Test->tprintf("Trying: %d\n", i);
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], sql);
|
||||
execute_query(Test->maxscales->conn_rwsplit[0], "%s", sql);
|
||||
}
|
||||
Test->set_timeout(60);
|
||||
Test->tprintf("executing SELECT\n");
|
||||
|
@ -24,7 +24,7 @@ int main(int argc, char** argv)
|
||||
test.maxscales->connect();
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "DROP TABLE IF EXISTS test.t1");
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE TABLE test.t1(id INT)");
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], sql);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", sql);
|
||||
|
||||
// Do the select inside a transacttion so that it gets routed to the master
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "BEGIN");
|
||||
|
@ -47,13 +47,13 @@ void set_max_packet(TestConnections* Test, bool binlog, char * cmd)
|
||||
if (binlog)
|
||||
{
|
||||
Test->repl->connect();
|
||||
Test->try_query(Test->repl->nodes[0], cmd);
|
||||
Test->try_query(Test->repl->nodes[0], "%s", cmd);
|
||||
Test->repl->close_connections();
|
||||
}
|
||||
else
|
||||
{
|
||||
Test->maxscales->connect_maxscale(0);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], cmd);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", cmd);
|
||||
Test->maxscales->close_maxscale_connections(0);
|
||||
}
|
||||
Test->tprintf(".. done\n");
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->tprintf("%s", sql);
|
||||
}
|
||||
int rv = execute_query(Test->maxscales->conn_rwsplit[0], sql);
|
||||
int rv = execute_query(Test->maxscales->conn_rwsplit[0], "%s", sql);
|
||||
Test->add_result(rv, "Query should succeed: %s", sql);
|
||||
local_result += rv;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ int read_and_execute_queries(TestConnections *Test, const char* filename, int ex
|
||||
if (strlen(sql) > 1)
|
||||
{
|
||||
Test->tprintf("%s", sql);
|
||||
if (execute_query(Test->maxscales->conn_rwsplit[0], sql) != expected &&
|
||||
if (execute_query(Test->maxscales->conn_rwsplit[0], "%s", sql) != expected &&
|
||||
(expected == 1 || mysql_errno(Test->maxscales->conn_rwsplit[0]) == 1141))
|
||||
{
|
||||
Test->tprintf("Query %s, but %s expected, MySQL error: %d, %s\n",
|
||||
|
@ -103,7 +103,7 @@ void drop_user(TestConnections& test, const string& user, const string& host)
|
||||
stmt += "'@'";
|
||||
stmt += host;
|
||||
stmt += "'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void create_user(TestConnections& test, const string& user, const string& password, const string& host)
|
||||
@ -119,7 +119,7 @@ void create_user(TestConnections& test, const string& user, const string& passwo
|
||||
stmt += "'";
|
||||
stmt += password;
|
||||
stmt += "'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
}
|
||||
|
||||
void grant_access(TestConnections& test, const string& user, const string& host)
|
||||
@ -131,7 +131,7 @@ void grant_access(TestConnections& test, const string& user, const string& host)
|
||||
stmt += "'@'";
|
||||
stmt += host;
|
||||
stmt += "'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "FLUSH PRIVILEGES");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->set_timeout(20);
|
||||
create_insert_string(sql, 100, i);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", sql);
|
||||
}
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "COMMIT");
|
||||
|
||||
|
@ -267,7 +267,7 @@ void Mariadb_nodes::change_master(int NewMaster, int OldMaster)
|
||||
}
|
||||
|
||||
execute_query(nodes[NewMaster], "RESET SLAVE ALL");
|
||||
execute_query(nodes[NewMaster], create_repl_user);
|
||||
execute_query(nodes[NewMaster], "%s", create_repl_user);
|
||||
|
||||
if (mysql_ping(nodes[OldMaster]) == 0)
|
||||
{
|
||||
@ -284,7 +284,7 @@ void Mariadb_nodes::change_master(int NewMaster, int OldMaster)
|
||||
{
|
||||
char str[1024];
|
||||
sprintf(str, setup_slave, IP[NewMaster], log_file, log_pos, port[NewMaster]);
|
||||
execute_query(nodes[i], str);
|
||||
execute_query(nodes[i], "%s", str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -471,7 +471,7 @@ int Galera_nodes::start_galera()
|
||||
sleep(5);
|
||||
|
||||
local_result += connect();
|
||||
local_result += execute_query(nodes[0], create_repl_user);
|
||||
local_result += execute_query(nodes[0], "%s", create_repl_user);
|
||||
|
||||
close_connections();
|
||||
return local_result;
|
||||
@ -940,7 +940,7 @@ int Mariadb_nodes::set_slave(MYSQL * conn, char master_host[], int master_port,
|
||||
{
|
||||
printf("Setup slave SQL: %s\n", str);
|
||||
}
|
||||
return execute_query(conn, str);
|
||||
return execute_query(conn, "%s", str);
|
||||
}
|
||||
|
||||
int Mariadb_nodes::set_repl_user()
|
||||
@ -949,7 +949,7 @@ int Mariadb_nodes::set_repl_user()
|
||||
global_result += connect();
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
global_result += execute_query(nodes[i], create_repl_user);
|
||||
global_result += execute_query(nodes[i], "%s", create_repl_user);
|
||||
}
|
||||
close_connections();
|
||||
return global_result;
|
||||
@ -1074,7 +1074,7 @@ int Mariadb_nodes::execute_query_all_nodes(const char* sql)
|
||||
connect();
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
local_result += execute_query(nodes[i], sql);
|
||||
local_result += execute_query(nodes[i], "%s", sql);
|
||||
}
|
||||
close_connections();
|
||||
return local_result;
|
||||
@ -1505,6 +1505,6 @@ void Mariadb_nodes::replicate_from(int slave, int master, const char* type)
|
||||
}
|
||||
|
||||
execute_query(nodes[slave], "STOP SLAVE;");
|
||||
execute_query(nodes[slave], change_master.str().c_str());
|
||||
execute_query(nodes[slave], "%s", change_master.str().c_str());
|
||||
execute_query(nodes[slave], "START SLAVE;");
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ int main(int argc, char *argv[])
|
||||
exp_rows[0] = 2;
|
||||
exp_rows[1] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test03_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test03_sql);
|
||||
compare_expected(Test, "CALL multi()", 2, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 4 ****\n");
|
||||
@ -341,7 +341,7 @@ int main(int argc, char *argv[])
|
||||
exp_rows[2] = 1;
|
||||
exp_rows[3] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test04_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test04_sql);
|
||||
compare_expected(Test, "CALL multi()", 4, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 5 ****\n");
|
||||
@ -351,14 +351,14 @@ int main(int argc, char *argv[])
|
||||
exp_rows[3] = 1;
|
||||
exp_rows[4] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test05_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test05_sql);
|
||||
compare_expected(Test, "CALL multi()", 5, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 6 ****\n");
|
||||
exp_rows[0] = 0;
|
||||
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test06_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test06_sql);
|
||||
compare_expected(Test, "CALL multi()", 1, exp_rows);
|
||||
|
||||
|
||||
@ -382,14 +382,14 @@ int main(int argc, char *argv[])
|
||||
exp_rows[7] = 0;
|
||||
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test07_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test07_sql);
|
||||
compare_expected(Test, "CALL multi()", 8, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 8 ****\n");
|
||||
exp_rows[0] = 0;
|
||||
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test08_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test08_sql);
|
||||
compare_expected(Test, "CALL multi()", 1, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 9 ****\n");
|
||||
@ -403,7 +403,7 @@ int main(int argc, char *argv[])
|
||||
exp_rows[1] = 4;
|
||||
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test10_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test10_sql);
|
||||
compare_expected(Test, "CALL multi()", 2, exp_rows);
|
||||
|
||||
err_check(Test, 1096);
|
||||
@ -470,13 +470,13 @@ int main(int argc, char *argv[])
|
||||
exp_rows[2] = 1;
|
||||
exp_rows[3] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test14_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test14_sql);
|
||||
compare_expected(Test, "CALL multi()", 4, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 15 ****\n");
|
||||
exp_rows[0] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test15_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test15_sql);
|
||||
compare_expected(Test, "CALL multi()", 1, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 16 ****\n");
|
||||
@ -490,7 +490,7 @@ int main(int argc, char *argv[])
|
||||
exp_rows[2] = 1;
|
||||
exp_rows[3] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test17_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test17_sql);
|
||||
compare_expected(Test, "CALL multi()", 4, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 18 ****\n");
|
||||
@ -516,14 +516,14 @@ int main(int argc, char *argv[])
|
||||
exp_rows[19] = 1;
|
||||
exp_rows[20] = 0;
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test18_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test18_sql);
|
||||
compare_expected(Test, "CALL multi()", 21, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 19 ****\n");
|
||||
exp_rows[0] = 0;
|
||||
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "DROP PROCEDURE IF EXISTS multi");
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], test19_sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", test19_sql);
|
||||
compare_expected(Test, "CALL multi()", 1, exp_rows);
|
||||
|
||||
Test->tprintf("**** Test 20 ****\n");
|
||||
|
@ -21,7 +21,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
sprintf(sql, "set @test=%d", i);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], sql);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", sql);
|
||||
}
|
||||
Test->tprintf("done!\n");
|
||||
|
||||
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
sprintf(sql, "set @test=%d", i);
|
||||
Test->try_query(Test->maxscales->conn_master[0], sql);
|
||||
Test->try_query(Test->maxscales->conn_master[0], "%s", sql);
|
||||
}
|
||||
Test->tprintf("done!\n");
|
||||
|
||||
@ -39,7 +39,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Test->set_timeout(5);
|
||||
sprintf(sql, "set @test=%d", i);
|
||||
Test->try_query(Test->maxscales->conn_slave[0], sql);
|
||||
Test->try_query(Test->maxscales->conn_slave[0], "%s", sql);
|
||||
}
|
||||
Test->tprintf("done!\n");
|
||||
|
||||
|
@ -19,7 +19,7 @@ void* async_query(void* data)
|
||||
for (int i = 0; i < 50 && running && test->global_result == 0; i++)
|
||||
{
|
||||
const char* query = "SET @a = (SELECT SLEEP(1))";
|
||||
test->try_query(conn, query);
|
||||
test->try_query(conn, "%s", query);
|
||||
}
|
||||
|
||||
mysql_close(conn);
|
||||
@ -38,7 +38,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
ss << "CREATE OR REPLACE TABLE test.t1 (id INT)";
|
||||
test.maxscales->connect_maxscale(0);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], ss.str().c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", ss.str().c_str());
|
||||
|
||||
ss.str("");
|
||||
ss << "INSERT INTO test.t1 VALUES (0)";
|
||||
@ -46,7 +46,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
ss << ",(" << i << ")";
|
||||
}
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], ss.str().c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", ss.str().c_str());
|
||||
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
||||
|
@ -43,9 +43,10 @@ int main(int argc, char** argv)
|
||||
vector<function<void ()>> pre;
|
||||
vector<function<void ()>> post;
|
||||
vector<function<void ()>> check;
|
||||
}
|
||||
tests[] =
|
||||
{
|
||||
};
|
||||
|
||||
std::vector<TrxTest> tests
|
||||
({
|
||||
{
|
||||
"Basic transaction",
|
||||
{
|
||||
@ -56,6 +57,8 @@ int main(int argc, char** argv)
|
||||
bind(ok, "SELECT 2"),
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Transaction with a write",
|
||||
@ -81,6 +84,8 @@ int main(int argc, char** argv)
|
||||
bind(ok, "SELECT 2"),
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Trx started, no queries",
|
||||
@ -91,6 +96,8 @@ int main(int argc, char** argv)
|
||||
bind(ok, "SELECT 1"),
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Trx waiting on commit",
|
||||
@ -101,6 +108,8 @@ int main(int argc, char** argv)
|
||||
{
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Trx with NOW()",
|
||||
@ -111,6 +120,8 @@ int main(int argc, char** argv)
|
||||
{
|
||||
bind(err, "SELECT 1"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Commit trx with NOW()",
|
||||
@ -121,6 +132,8 @@ int main(int argc, char** argv)
|
||||
{
|
||||
bind(err, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"NOW() used after replay",
|
||||
@ -132,6 +145,8 @@ int main(int argc, char** argv)
|
||||
bind(ok, "SELECT NOW()"),
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Exceed transaction length limit",
|
||||
@ -149,6 +164,8 @@ int main(int argc, char** argv)
|
||||
bind(err, "SELECT 7"),
|
||||
bind(err, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Normal trx after hitting limit",
|
||||
@ -183,6 +200,8 @@ int main(int argc, char** argv)
|
||||
bind(check, "SELECT @a", "1"),
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
{
|
||||
}
|
||||
},
|
||||
{
|
||||
"Empty transaction",
|
||||
@ -192,8 +211,10 @@ int main(int argc, char** argv)
|
||||
{
|
||||
bind(ok, "COMMIT"),
|
||||
},
|
||||
},
|
||||
};
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create a table for testing
|
||||
test.maxscales->connect();
|
||||
|
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
filename);
|
||||
test->tprintf("Loading data\n");
|
||||
test->set_timeout(100);
|
||||
test->add_result(execute_query(test->maxscales->conn_rwsplit[0], query), "Loading data failed.");
|
||||
test->add_result(execute_query(test->maxscales->conn_rwsplit[0], "%s", query), "Loading data failed.");
|
||||
test->tprintf("Reading data\n");
|
||||
test->set_timeout(100);
|
||||
test->add_result(execute_query(test->maxscales->conn_rwsplit[0], "SELECT * FROM test.dump"),
|
||||
|
@ -63,7 +63,7 @@ bool found_in_file(TestConnections& test, const string& file, const string& patt
|
||||
command += " ";
|
||||
command += file;
|
||||
|
||||
return test.maxscales->ssh_node_f(0, true, command.c_str()) == 0;
|
||||
return test.maxscales->ssh_node_f(0, true, "%s", command.c_str()) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ int main(int argc, char *argv[])
|
||||
sprintf(str, "SELECT REPEAT('a',%d)", i);
|
||||
|
||||
test.set_timeout(15);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], str);
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", str);
|
||||
}
|
||||
|
||||
test.maxscales->close_maxscale_connections(0);
|
||||
|
@ -255,7 +255,7 @@ void *query_thread_master(void *ptr)
|
||||
{
|
||||
while (data->exit_flag == 0)
|
||||
{
|
||||
data->Test->try_query(data->conn1, sql);
|
||||
data->Test->try_query(data->conn1, "%s", sql);
|
||||
data->i++;
|
||||
}
|
||||
}
|
||||
|
@ -206,14 +206,14 @@ void *query_thread1( void *ptr )
|
||||
|
||||
while (data->exit_flag == 0)
|
||||
{
|
||||
if (data->Test->try_query(data->conn1, sql))
|
||||
if (data->Test->try_query(data->conn1, "%s", sql))
|
||||
{
|
||||
data->Test->add_result(1, "Query to ReadConn Master failed\n");
|
||||
return NULL;
|
||||
}
|
||||
if (data->rwsplit_only == 0)
|
||||
{
|
||||
if (data->Test->try_query(data->conn2, sql))
|
||||
if (data->Test->try_query(data->conn2, "%s", sql))
|
||||
{
|
||||
data->Test->add_result(1, "Query to RWSplit failed\n");
|
||||
return NULL;
|
||||
|
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
||||
Test->try_query(conn, (char *) "CREATE TABLE t2 (x varchar(10));");
|
||||
char sql[256];
|
||||
sprintf(sql, "INSERT INTO t2 VALUES (\"Кот\");");
|
||||
Test->try_query(conn, sql);
|
||||
Test->try_query(conn, "%s", sql);
|
||||
Test->stop_timeout();
|
||||
sleep(5);
|
||||
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char *argv[])
|
||||
sprintf(str, setup_binlog_wrong_passwrd, Test->repl->IP[0], Test->repl->port[0]);
|
||||
Test->tprintf("binlog setup sql: %s\n", str);
|
||||
Test->set_timeout(10);
|
||||
execute_query(binlog, str);
|
||||
execute_query(binlog, "%s", str);
|
||||
Test->tprintf("Error: %s\n", mysql_error(binlog));
|
||||
|
||||
Test->tprintf("'start slave' to binlog\n");
|
||||
|
@ -48,7 +48,7 @@ int main(int argc, char *argv[])
|
||||
for (int i = 0; queries[i]; i++)
|
||||
{
|
||||
Test->set_timeout(30);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], queries[i]);
|
||||
Test->try_query(Test->maxscales->conn_rwsplit[0], "%s", queries[i]);
|
||||
}
|
||||
int rval = Test->global_result;
|
||||
delete Test;
|
||||
|
@ -41,7 +41,7 @@ void replicate_from(TestConnections& test, int server_ind, int target_ind)
|
||||
cout << "Query is '" << change_master.str() << "'" << endl;
|
||||
}
|
||||
test.try_query(test.repl->nodes[server_ind], "STOP SLAVE;");
|
||||
test.try_query(test.repl->nodes[server_ind], change_master.str().c_str());
|
||||
test.try_query(test.repl->nodes[server_ind], "%s", change_master.str().c_str());
|
||||
test.try_query(test.repl->nodes[server_ind], "START SLAVE;");
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void connect_maxscale(TestConnections& test)
|
||||
|
||||
void try_query(TestConnections& test, const char* zQuery)
|
||||
{
|
||||
if (test.try_query(test.maxscales->conn_rwsplit[0], zQuery) != 0)
|
||||
if (test.try_query(test.maxscales->conn_rwsplit[0], "%s", zQuery) != 0)
|
||||
{
|
||||
string s("Could not execute query: ");
|
||||
s += zQuery;
|
||||
|
@ -51,7 +51,7 @@ void insert_data(TestConnections& test)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "INSERT INTO test.t1 VALUES (" << i << ")";
|
||||
test.try_query(pConn, ss.str().c_str());
|
||||
test.try_query(pConn, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
test.try_query(pConn, "COMMIT");
|
||||
|
@ -70,7 +70,7 @@ void insert_data(TestConnections& test)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "INSERT INTO test.t1 VALUES (" << i << ")";
|
||||
test.try_query(pConn, ss.str().c_str());
|
||||
test.try_query(pConn, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
test.try_query(pConn, "COMMIT");
|
||||
|
@ -327,10 +327,10 @@ private:
|
||||
for (size_t i = 0; i < s_nClients; ++i)
|
||||
{
|
||||
string drop = drop_head + std::to_string(i);
|
||||
test.try_query(pConn, drop.c_str());
|
||||
test.try_query(pConn, "%s", drop.c_str());
|
||||
|
||||
string create = create_head + std::to_string(i) + create_tail;
|
||||
test.try_query(pConn, create.c_str());
|
||||
test.try_query(pConn, "%s", create.c_str());
|
||||
}
|
||||
|
||||
return test.ok();
|
||||
@ -360,7 +360,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
test.try_query(pConn, insert.c_str());
|
||||
test.try_query(pConn, "%s", insert.c_str());
|
||||
}
|
||||
|
||||
return test.ok();
|
||||
|
@ -70,7 +70,7 @@ void insert_data(TestConnections& test)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "INSERT INTO test.t1 VALUES (" << i << ")";
|
||||
test.try_query(pConn, ss.str().c_str());
|
||||
test.try_query(pConn, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
test.try_query(pConn, "COMMIT");
|
||||
|
@ -70,7 +70,7 @@ void insert_data(TestConnections& test)
|
||||
{
|
||||
stringstream ss;
|
||||
ss << "INSERT INTO test.t1 VALUES (" << i << ")";
|
||||
test.try_query(pConn, ss.str().c_str());
|
||||
test.try_query(pConn, "%s", ss.str().c_str());
|
||||
}
|
||||
|
||||
test.try_query(pConn, "COMMIT");
|
||||
|
@ -330,10 +330,10 @@ private:
|
||||
for (size_t i = 0; i < s_nClients; ++i)
|
||||
{
|
||||
string drop = drop_head + std::to_string(i);
|
||||
test.try_query(pConn, drop.c_str());
|
||||
test.try_query(pConn, "%s", drop.c_str());
|
||||
|
||||
string create = create_head + std::to_string(i) + create_tail;
|
||||
test.try_query(pConn, create.c_str());
|
||||
test.try_query(pConn, "%s", create.c_str());
|
||||
}
|
||||
|
||||
return test.ok();
|
||||
@ -363,7 +363,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
test.try_query(pConn, insert.c_str());
|
||||
test.try_query(pConn, "%s", insert.c_str());
|
||||
}
|
||||
|
||||
return test.ok();
|
||||
@ -514,7 +514,7 @@ void create_client_user(TestConnections& test)
|
||||
stmt += "'";
|
||||
stmt += CLIENT_USER;
|
||||
stmt += "'@'%%'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
|
||||
// Create user
|
||||
stmt = "CREATE USER ";
|
||||
@ -525,14 +525,14 @@ void create_client_user(TestConnections& test)
|
||||
stmt += "'";
|
||||
stmt += CLIENT_PASSWORD;
|
||||
stmt += "'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
|
||||
// Grant access
|
||||
stmt = "GRANT SELECT, INSERT, UPDATE ON *.* TO ";
|
||||
stmt += "'";
|
||||
stmt += CLIENT_USER;
|
||||
stmt += "'@'%%'";
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], stmt.c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", stmt.c_str());
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "FLUSH PRIVILEGES");
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
||||
test.maxscales->connect_maxscale(0);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], std::string("set @test=" + std::to_string(i)).c_str());
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", std::string("set @test=" + std::to_string(i)).c_str());
|
||||
}
|
||||
|
||||
test.tprintf("Execute one more session command and expect message in error log");
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
test.set_timeout(15);
|
||||
conn = test.maxscales->open_rwsplit_connection(0);
|
||||
execute_query(conn, sql);
|
||||
execute_query(conn, "%s", sql);
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ int insert_into_t1(MYSQL *conn, int N)
|
||||
printf("INSERT: rwsplitter\n");
|
||||
printf("Trying INSERT, len=%d\n", x);
|
||||
fflush(stdout);
|
||||
result += execute_query(conn, sqlstr);
|
||||
result += execute_query(conn, "%s", sqlstr);
|
||||
fflush(stdout);
|
||||
x *= 16;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ void TestConnections::process_template(int m, const char *template_name, const c
|
||||
}
|
||||
|
||||
mdn[j]->connect();
|
||||
execute_query(mdn[j]->nodes[0], (char *) "CREATE DATABASE IF NOT EXISTS test");
|
||||
execute_query(mdn[j]->nodes[0], "CREATE DATABASE IF NOT EXISTS test");
|
||||
mdn[j]->close_connections();
|
||||
}
|
||||
|
||||
@ -889,8 +889,8 @@ int TestConnections::start_binlog(int m)
|
||||
repl->stop_nodes();
|
||||
|
||||
binlog = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl);
|
||||
execute_query(binlog, (char *) "stop slave");
|
||||
execute_query(binlog, (char *) "reset slave all");
|
||||
execute_query(binlog, "stop slave");
|
||||
execute_query(binlog, "reset slave all");
|
||||
mysql_close(binlog);
|
||||
|
||||
tprintf("Stopping maxscale\n");
|
||||
@ -1068,7 +1068,7 @@ bool TestConnections::replicate_from_master(int m)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void TestConnections::revert_replicate_from_master(int m)
|
||||
void TestConnections::revert_replicate_from_master()
|
||||
{
|
||||
char log_file[256] = "";
|
||||
|
||||
@ -1106,11 +1106,11 @@ int TestConnections::start_mm(int m)
|
||||
repl->connect();
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
execute_query(repl->nodes[i], (char *) "stop slave");
|
||||
execute_query(repl->nodes[i], (char *) "reset master");
|
||||
execute_query(repl->nodes[i], "stop slave");
|
||||
execute_query(repl->nodes[i], "reset master");
|
||||
}
|
||||
|
||||
execute_query(repl->nodes[0], (char *) "SET GLOBAL READ_ONLY=ON");
|
||||
execute_query(repl->nodes[0], "SET GLOBAL READ_ONLY=ON");
|
||||
|
||||
find_field(repl->nodes[0], (char *) "show master status", (char *) "File", log_file1);
|
||||
find_field(repl->nodes[0], (char *) "show master status", (char *) "Position", log_pos1);
|
||||
@ -1573,7 +1573,7 @@ int TestConnections::get_client_ip(int m, char * ip)
|
||||
|
||||
maxscales->connect_rwsplit(m);
|
||||
if (execute_query(maxscales->conn_rwsplit[m],
|
||||
(char *) "CREATE DATABASE IF NOT EXISTS db_to_check_client_ip") != 0 )
|
||||
"CREATE DATABASE IF NOT EXISTS db_to_check_client_ip") != 0 )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
@ -1746,15 +1746,15 @@ int TestConnections::use_db(int m, char * db)
|
||||
sprintf(sql, "USE %s;", db);
|
||||
set_timeout(20);
|
||||
tprintf("selecting DB '%s' for rwsplit\n", db);
|
||||
local_result += execute_query(maxscales->conn_rwsplit[m], sql);
|
||||
local_result += execute_query(maxscales->conn_rwsplit[m], "%s", sql);
|
||||
tprintf("selecting DB '%s' for readconn master\n", db);
|
||||
local_result += execute_query(maxscales->conn_slave[m], sql);
|
||||
local_result += execute_query(maxscales->conn_slave[m], "%s", sql);
|
||||
tprintf("selecting DB '%s' for readconn slave\n", db);
|
||||
local_result += execute_query(maxscales->conn_master[m], sql);
|
||||
local_result += execute_query(maxscales->conn_master[m], "%s", sql);
|
||||
for (int i = 0; i < repl->N; i++)
|
||||
{
|
||||
tprintf("selecting DB '%s' for direct connection to node %d\n", db, i);
|
||||
local_result += execute_query(repl->nodes[i], sql);
|
||||
local_result += execute_query(repl->nodes[i], "%s", sql);
|
||||
}
|
||||
return local_result;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public:
|
||||
/**
|
||||
* @brief Stop binlogrouter replication from master
|
||||
*/
|
||||
void revert_replicate_from_master(int m = 0);
|
||||
void revert_replicate_from_master();
|
||||
|
||||
/**
|
||||
* @brief prepare_binlog clean up binlog directory, set proper access rights to it
|
||||
|
Loading…
x
Reference in New Issue
Block a user