diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 7e4c19024..2dc71682e 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -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") diff --git a/maxscale-system-test/big_load.cpp b/maxscale-system-test/big_load.cpp index a6412750b..da3f2c245 100644 --- a/maxscale-system-test/big_load.cpp +++ b/maxscale-system-test/big_load.cpp @@ -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); } diff --git a/maxscale-system-test/big_transaction.cpp b/maxscale-system-test/big_transaction.cpp index 2539aedb0..15305f84c 100644 --- a/maxscale-system-test/big_transaction.cpp +++ b/maxscale-system-test/big_transaction.cpp @@ -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"); diff --git a/maxscale-system-test/binlog_big_transaction.cpp b/maxscale-system-test/binlog_big_transaction.cpp index 72bc6dcda..aab774738 100644 --- a/maxscale-system-test/binlog_big_transaction.cpp +++ b/maxscale-system-test/binlog_big_transaction.cpp @@ -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) { diff --git a/maxscale-system-test/binlog_change_master.cpp b/maxscale-system-test/binlog_change_master.cpp index 0a8632e08..8eb92bd73 100644 --- a/maxscale-system-test/binlog_change_master.cpp +++ b/maxscale-system-test/binlog_change_master.cpp @@ -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) { diff --git a/maxscale-system-test/blob_test.cpp b/maxscale-system-test/blob_test.cpp index 6bb3f85a9..157149df9 100644 --- a/maxscale-system-test/blob_test.cpp +++ b/maxscale-system-test/blob_test.cpp @@ -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++) { diff --git a/maxscale-system-test/bug529.cpp b/maxscale-system-test/bug529.cpp index 9b217b0c5..8a0cb4729 100644 --- a/maxscale-system-test/bug529.cpp +++ b/maxscale-system-test/bug529.cpp @@ -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); } diff --git a/maxscale-system-test/cache_runtime.cpp b/maxscale-system-test/cache_runtime.cpp index 7f5b775b3..dc954b27c 100644 --- a/maxscale-system-test/cache_runtime.cpp +++ b/maxscale-system-test/cache_runtime.cpp @@ -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()); } } diff --git a/maxscale-system-test/cache_runtime_ttl.cpp b/maxscale-system-test/cache_runtime_ttl.cpp index d1f7cc68d..bf3cd16c7 100644 --- a/maxscale-system-test/cache_runtime_ttl.cpp +++ b/maxscale-system-test/cache_runtime_ttl.cpp @@ -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()); } } diff --git a/maxscale-system-test/cdc_client.cpp b/maxscale-system-test/cdc_client.cpp index 034321264..6e68cb374 100644 --- a/maxscale-system-test/cdc_client.cpp +++ b/maxscale-system-test/cdc_client.cpp @@ -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); } } diff --git a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp index ec0044f28..49debf91a 100644 --- a/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp +++ b/maxscale-system-test/cdc_datatypes/cdc_datatypes.cpp @@ -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) diff --git a/maxscale-system-test/change_master_during_session.cpp b/maxscale-system-test/change_master_during_session.cpp index 1c53c07f1..e7e5949f8 100644 --- a/maxscale-system-test/change_master_during_session.cpp +++ b/maxscale-system-test/change_master_during_session.cpp @@ -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"); diff --git a/maxscale-system-test/compound_statement.cpp b/maxscale-system-test/compound_statement.cpp index e2f0f24ba..1a37c51fc 100644 --- a/maxscale-system-test/compound_statement.cpp +++ b/maxscale-system-test/compound_statement.cpp @@ -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"); diff --git a/maxscale-system-test/different_size.cpp b/maxscale-system-test/different_size.cpp index ead4c9a79..09e7135db 100644 --- a/maxscale-system-test/different_size.cpp +++ b/maxscale-system-test/different_size.cpp @@ -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"); diff --git a/maxscale-system-test/fwf.cpp b/maxscale-system-test/fwf.cpp index 487bd80ca..eb40980a3 100644 --- a/maxscale-system-test/fwf.cpp +++ b/maxscale-system-test/fwf.cpp @@ -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; } diff --git a/maxscale-system-test/fwf2.cpp b/maxscale-system-test/fwf2.cpp index bd0e1dbd9..6967e079f 100644 --- a/maxscale-system-test/fwf2.cpp +++ b/maxscale-system-test/fwf2.cpp @@ -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", diff --git a/maxscale-system-test/local_address.cpp b/maxscale-system-test/local_address.cpp index cceef3cc6..38e98de47 100644 --- a/maxscale-system-test/local_address.cpp +++ b/maxscale-system-test/local_address.cpp @@ -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"); } diff --git a/maxscale-system-test/lots_of_rows.cpp b/maxscale-system-test/lots_of_rows.cpp index 0debd5384..19e270df3 100644 --- a/maxscale-system-test/lots_of_rows.cpp +++ b/maxscale-system-test/lots_of_rows.cpp @@ -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"); diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index 6a76b8ea0..df73d0b33 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -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;"); } diff --git a/maxscale-system-test/mxs1071_maxrows.cpp b/maxscale-system-test/mxs1071_maxrows.cpp index 7aaa84dc7..d96aaeadb 100644 --- a/maxscale-system-test/mxs1071_maxrows.cpp +++ b/maxscale-system-test/mxs1071_maxrows.cpp @@ -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"); diff --git a/maxscale-system-test/mxs127.cpp b/maxscale-system-test/mxs127.cpp index 9ffe061ed..e8a206d7e 100644 --- a/maxscale-system-test/mxs127.cpp +++ b/maxscale-system-test/mxs127.cpp @@ -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"); diff --git a/maxscale-system-test/mxs1323_stress.cpp b/maxscale-system-test/mxs1323_stress.cpp index 8f62d13f8..cc3b76247 100644 --- a/maxscale-system-test/mxs1323_stress.cpp +++ b/maxscale-system-test/mxs1323_stress.cpp @@ -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); diff --git a/maxscale-system-test/mxs1507_trx_replay.cpp b/maxscale-system-test/mxs1507_trx_replay.cpp index 8abe2f2e0..8aefded32 100644 --- a/maxscale-system-test/mxs1507_trx_replay.cpp +++ b/maxscale-system-test/mxs1507_trx_replay.cpp @@ -43,9 +43,10 @@ int main(int argc, char** argv) vector> pre; vector> post; vector> check; - } - tests[] = - { + }; + + std::vector 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(); diff --git a/maxscale-system-test/mxs365.cpp b/maxscale-system-test/mxs365.cpp index 162b4c149..46f4662a4 100644 --- a/maxscale-system-test/mxs365.cpp +++ b/maxscale-system-test/mxs365.cpp @@ -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"), diff --git a/maxscale-system-test/mxs421_events.cpp b/maxscale-system-test/mxs421_events.cpp index ccd39b2b4..9cd64429c 100644 --- a/maxscale-system-test/mxs421_events.cpp +++ b/maxscale-system-test/mxs421_events.cpp @@ -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; } } diff --git a/maxscale-system-test/mxs47.cpp b/maxscale-system-test/mxs47.cpp index 7878205ba..8c89e3a9a 100644 --- a/maxscale-system-test/mxs47.cpp +++ b/maxscale-system-test/mxs47.cpp @@ -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); diff --git a/maxscale-system-test/mxs548_short_session_change_user.cpp b/maxscale-system-test/mxs548_short_session_change_user.cpp index 208575fcc..421193cff 100644 --- a/maxscale-system-test/mxs548_short_session_change_user.cpp +++ b/maxscale-system-test/mxs548_short_session_change_user.cpp @@ -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++; } } diff --git a/maxscale-system-test/mxs564_big_dump.cpp b/maxscale-system-test/mxs564_big_dump.cpp index f7e3a087c..657650c34 100644 --- a/maxscale-system-test/mxs564_big_dump.cpp +++ b/maxscale-system-test/mxs564_big_dump.cpp @@ -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; diff --git a/maxscale-system-test/mxs682_cyrillic.cpp b/maxscale-system-test/mxs682_cyrillic.cpp index f0ae95c33..326907c00 100644 --- a/maxscale-system-test/mxs682_cyrillic.cpp +++ b/maxscale-system-test/mxs682_cyrillic.cpp @@ -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); diff --git a/maxscale-system-test/mxs781_binlog_wrong_passwrd.cpp b/maxscale-system-test/mxs781_binlog_wrong_passwrd.cpp index 95a77c18a..db71988cd 100644 --- a/maxscale-system-test/mxs781_binlog_wrong_passwrd.cpp +++ b/maxscale-system-test/mxs781_binlog_wrong_passwrd.cpp @@ -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"); diff --git a/maxscale-system-test/mxs957.cpp b/maxscale-system-test/mxs957.cpp index b9f6b40af..28a9cf231 100644 --- a/maxscale-system-test/mxs957.cpp +++ b/maxscale-system-test/mxs957.cpp @@ -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; diff --git a/maxscale-system-test/mysqlmon_detect_standalone_master.cpp b/maxscale-system-test/mysqlmon_detect_standalone_master.cpp index a7927b2f1..0307cbf74 100644 --- a/maxscale-system-test/mysqlmon_detect_standalone_master.cpp +++ b/maxscale-system-test/mysqlmon_detect_standalone_master.cpp @@ -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;"); } diff --git a/maxscale-system-test/mysqlmon_failover_manual2.cpp b/maxscale-system-test/mysqlmon_failover_manual2.cpp index 702c2f9a7..6d2fbd509 100644 --- a/maxscale-system-test/mysqlmon_failover_manual2.cpp +++ b/maxscale-system-test/mysqlmon_failover_manual2.cpp @@ -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; diff --git a/maxscale-system-test/mysqlmon_failover_rejoin_old_slave.cpp b/maxscale-system-test/mysqlmon_failover_rejoin_old_slave.cpp index e9ba67a92..806dbfb81 100644 --- a/maxscale-system-test/mysqlmon_failover_rejoin_old_slave.cpp +++ b/maxscale-system-test/mysqlmon_failover_rejoin_old_slave.cpp @@ -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"); diff --git a/maxscale-system-test/mysqlmon_failover_rolling_restart_slaves.cpp b/maxscale-system-test/mysqlmon_failover_rolling_restart_slaves.cpp index b404a60d3..6ef0c61ea 100644 --- a/maxscale-system-test/mysqlmon_failover_rolling_restart_slaves.cpp +++ b/maxscale-system-test/mysqlmon_failover_rolling_restart_slaves.cpp @@ -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"); diff --git a/maxscale-system-test/mysqlmon_failover_stress.cpp b/maxscale-system-test/mysqlmon_failover_stress.cpp index 20a180fa6..0c3c8ec73 100755 --- a/maxscale-system-test/mysqlmon_failover_stress.cpp +++ b/maxscale-system-test/mysqlmon_failover_stress.cpp @@ -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(); diff --git a/maxscale-system-test/mysqlmon_switchover.cpp b/maxscale-system-test/mysqlmon_switchover.cpp index 17ffba528..b193b9a60 100644 --- a/maxscale-system-test/mysqlmon_switchover.cpp +++ b/maxscale-system-test/mysqlmon_switchover.cpp @@ -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"); diff --git a/maxscale-system-test/mysqlmon_switchover_bad_master.cpp b/maxscale-system-test/mysqlmon_switchover_bad_master.cpp index 9d8c46451..d4c3b054a 100644 --- a/maxscale-system-test/mysqlmon_switchover_bad_master.cpp +++ b/maxscale-system-test/mysqlmon_switchover_bad_master.cpp @@ -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"); diff --git a/maxscale-system-test/mysqlmon_switchover_stress.cpp b/maxscale-system-test/mysqlmon_switchover_stress.cpp index 1f65bf0e5..10919987c 100644 --- a/maxscale-system-test/mysqlmon_switchover_stress.cpp +++ b/maxscale-system-test/mysqlmon_switchover_stress.cpp @@ -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"); } diff --git a/maxscale-system-test/session_limits.cpp b/maxscale-system-test/session_limits.cpp index 84c75972a..1cfe0ab5b 100644 --- a/maxscale-system-test/session_limits.cpp +++ b/maxscale-system-test/session_limits.cpp @@ -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"); diff --git a/maxscale-system-test/short_sessions.cpp b/maxscale-system-test/short_sessions.cpp index cf698899c..8f59960cd 100644 --- a/maxscale-system-test/short_sessions.cpp +++ b/maxscale-system-test/short_sessions.cpp @@ -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); } diff --git a/maxscale-system-test/sql_t1.cpp b/maxscale-system-test/sql_t1.cpp index 6bfe3cec0..a1bae7ff3 100644 --- a/maxscale-system-test/sql_t1.cpp +++ b/maxscale-system-test/sql_t1.cpp @@ -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; } diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index b69371831..6ef5948ed 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -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; } diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 807bc3f92..d571272da 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -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