diff --git a/avro/maxavro.c b/avro/maxavro.c index 2c1347e54..53c890775 100644 --- a/avro/maxavro.c +++ b/avro/maxavro.c @@ -338,9 +338,9 @@ MAXAVRO_MAP* maxavro_read_map_from_file(MAXAVRO_FILE* file) size_t size; MAXAVRO_MAP* val = calloc(1, sizeof(MAXAVRO_MAP)); if (val - && (val->key - = maxavro_read_string_from_file(file, - &size)) + && (val->key = + maxavro_read_string_from_file(file, + &size)) && (val->value = maxavro_read_string_from_file(file, &size))) { val->next = rval; diff --git a/connectors/cdc-connector/cdc_connector.cpp b/connectors/cdc-connector/cdc_connector.cpp index 794f4249c..da20c8e7b 100644 --- a/connectors/cdc-connector/cdc_connector.cpp +++ b/connectors/cdc-connector/cdc_connector.cpp @@ -338,8 +338,8 @@ void Connection::process_schema(json_t* json) type = json_object_get(v, "type"); } std::string nameval = name ? json_string_value(name) : ""; - std::string typeval - = type ? (json_is_string(type) ? json_string_value(type) : "varchar(50)") : "undefined"; + std::string typeval = + type ? (json_is_string(type) ? json_string_value(type) : "varchar(50)") : "undefined"; if (json_is_integer(length)) { diff --git a/maxscale-system-test/bug529.cpp b/maxscale-system-test/bug529.cpp index 7bbe419c9..0728015bb 100644 --- a/maxscale-system-test/bug529.cpp +++ b/maxscale-system-test/bug529.cpp @@ -181,11 +181,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { @@ -203,11 +203,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { @@ -221,11 +221,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn > 2 * conn_N)) { @@ -240,11 +240,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); printf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn != 0)) { @@ -261,11 +261,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn != 0)) { @@ -286,11 +286,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn != 0)) { @@ -309,11 +309,11 @@ int main(int argc, char* argv[]) for (i = 0; i < Test->repl->N; i++) { Test->set_timeout(60); - num_conn - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->IP[0], - Test->maxscales->hostname[0], - (char*) "test"); + num_conn = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->IP[0], + Test->maxscales->hostname[0], + (char*) "test"); Test->tprintf("Connections to node %d (%s): %d\n", i, Test->repl->IP[i], num_conn); if ((i == 0) && (num_conn != 0)) { diff --git a/maxscale-system-test/compound_statement.cpp b/maxscale-system-test/compound_statement.cpp index df4aeffbc..a9b2c0108 100644 --- a/maxscale-system-test/compound_statement.cpp +++ b/maxscale-system-test/compound_statement.cpp @@ -8,18 +8,18 @@ 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"; + 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], "DROP TABLE IF EXISTS test.t1"); diff --git a/maxscale-system-test/encrypted_passwords.cpp b/maxscale-system-test/encrypted_passwords.cpp index 3a5cf036c..52cc8c4db 100644 --- a/maxscale-system-test/encrypted_passwords.cpp +++ b/maxscale-system-test/encrypted_passwords.cpp @@ -45,8 +45,8 @@ int hash_password(TestConnections* test) int exit_code; test->tprintf("Creating a new encrypted password\n"); - char* enc_pw - = test->maxscales->ssh_node_output(0, "maxpasswd /var/lib/maxscale/ skysql", true, &exit_code); + char* enc_pw = + test->maxscales->ssh_node_output(0, "maxpasswd /var/lib/maxscale/ skysql", true, &exit_code); char* ptr = strchr(enc_pw, '\n'); if (ptr) diff --git a/maxscale-system-test/mariadb_func.cpp b/maxscale-system-test/mariadb_func.cpp index 6ea1ba6f1..b00943e2a 100644 --- a/maxscale-system-test/mariadb_func.cpp +++ b/maxscale-system-test/mariadb_func.cpp @@ -565,8 +565,8 @@ Result get_result(MYSQL* conn, std::string sql) Row get_row(MYSQL* conn, std::string sql) { Result res = get_result(conn, sql); - return res.empty() ? Row {} - : res[0]; + return res.empty() ? Row {} : + res[0]; } int get_int_version(std::string version) diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index 49d7f7954..cea0d5683 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -413,9 +413,9 @@ int Mariadb_nodes::start_replication() "%s", IP_private[0], port[0], - g_require_gtid - ? "MASTER_USE_GTID=slave_pos" - : "MASTER_LOG_FILE='mar-bin.000001', MASTER_LOG_POS=4"); + g_require_gtid ? + "MASTER_USE_GTID=slave_pos" : + "MASTER_LOG_FILE='mar-bin.000001', MASTER_LOG_POS=4"); execute_query(nodes[i], "START SLAVE"); } diff --git a/maxscale-system-test/maxinfo.cpp b/maxscale-system-test/maxinfo.cpp index b236a97bd..8fc6bf01f 100644 --- a/maxscale-system-test/maxinfo.cpp +++ b/maxscale-system-test/maxinfo.cpp @@ -18,8 +18,8 @@ using namespace std; // const char * resources[N] = {"variables", "status", "services", "listeners", "modules", "sessions", // "clients", "servers", "eventTimes"}; const int N = 8; -const char* resources[N] - = {"variables", "status", "services", "listeners", "modules", "sessions", "clients", "servers"}; +const char* resources[N] = +{"variables", "status", "services", "listeners", "modules", "sessions", "clients", "servers"}; bool exit_flag = false; diff --git a/maxscale-system-test/mxs1071_maxrows.cpp b/maxscale-system-test/mxs1071_maxrows.cpp index 5399ad7cb..6c5c2130d 100644 --- a/maxscale-system-test/mxs1071_maxrows.cpp +++ b/maxscale-system-test/mxs1071_maxrows.cpp @@ -50,147 +50,147 @@ using namespace std; -const char* test03_sql - = " CREATE PROCEDURE multi()\n" - "BEGIN\n" - "SELECT x1 FROM t1 LIMIT 2;\n" - "END"; +const char* test03_sql = + " CREATE PROCEDURE multi()\n" + "BEGIN\n" + "SELECT x1 FROM t1 LIMIT 2;\n" + "END"; -const char* test04_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1;\n" - "SELECT x1 FROM t1 LIMIT 2;\n" - "SELECT 1,2,3; \n" - "END"; +const char* test04_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1;\n" + "SELECT x1 FROM t1 LIMIT 2;\n" + "SELECT 1,2,3; \n" + "END"; -const char* test05_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1;\n" - "SELECT x1 FROM t1 LIMIT 8;\n" - "SELECT 1,2,3; \n" - "SELECT 1;" - "END"; +const char* test05_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1;\n" + "SELECT x1 FROM t1 LIMIT 8;\n" + "SELECT 1,2,3; \n" + "SELECT 1;" + "END"; -const char* test06_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1;\n" - "SELECT x1 FROM t1 LIMIT 18;\n" - "SELECT 2; \n" - "SELECT 2;" - "END"; +const char* test06_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1;\n" + "SELECT x1 FROM t1 LIMIT 18;\n" + "SELECT 2; \n" + "SELECT 2;" + "END"; -const char* test07_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1,2,3,4;\n" - "SELECT id, b from long_blob_table order by id desc limit 1;\n" - "SELECT id, b from long_blob_table order by id desc limit 4;\n" - "SELECT id, b from long_blob_table order by id desc limit 1;\n" - "SELECT id, b from long_blob_table order by id desc;\n" - "SELECT id, b from long_blob_table order by id desc;\n" - "SELECT 1;\n" - "END"; +const char* test07_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1,2,3,4;\n" + "SELECT id, b from long_blob_table order by id desc limit 1;\n" + "SELECT id, b from long_blob_table order by id desc limit 4;\n" + "SELECT id, b from long_blob_table order by id desc limit 1;\n" + "SELECT id, b from long_blob_table order by id desc;\n" + "SELECT id, b from long_blob_table order by id desc;\n" + "SELECT 1;\n" + "END"; -const char* test08_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1,2,3;\n" - "SELECT id, b, b from long_blob_table order by id desc limit 1;\n" - "SELECT 2;\n" - "SELECT id, b from long_blob_table order by id desc limit 4;\n" - "SELECT id, b from long_blob_table order by id desc limit 2;\n" - "SELECT 1;\n" - "SELECT 1;\n" - "SELECT x1 FROM t1 LIMIT 8;\n" - "SELECT 1;\n" - "SELECT 1,2,3,4;\n" - "END"; +const char* test08_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1,2,3;\n" + "SELECT id, b, b from long_blob_table order by id desc limit 1;\n" + "SELECT 2;\n" + "SELECT id, b from long_blob_table order by id desc limit 4;\n" + "SELECT id, b from long_blob_table order by id desc limit 2;\n" + "SELECT 1;\n" + "SELECT 1;\n" + "SELECT x1 FROM t1 LIMIT 8;\n" + "SELECT 1;\n" + "SELECT 1,2,3,4;\n" + "END"; -const char* test10_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1;\n" - "SELECT x1 FROM t1 limit 4;\n" - "select * from dual;\n" - "set @a=4;\n" - "SELECT 2;\n" - "SELECT * FROM t1;\n" - "END"; +const char* test10_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1;\n" + "SELECT x1 FROM t1 limit 4;\n" + "select * from dual;\n" + "set @a=4;\n" + "SELECT 2;\n" + "SELECT * FROM t1;\n" + "END"; -const char* test14_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1,3;\n" - "SET @table = 't1';\n" - "SET @s = CONCAT('SELECT * FROM ', @table, ' LIMIT 18');\n" - "PREPARE stmt1 FROM @s;\n" - "EXECUTE stmt1;\n" - "DEALLOCATE PREPARE stmt1;\n" - "SELECT 2,4,5;\n" - "END"; +const char* test14_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1,3;\n" + "SET @table = 't1';\n" + "SET @s = CONCAT('SELECT * FROM ', @table, ' LIMIT 18');\n" + "PREPARE stmt1 FROM @s;\n" + "EXECUTE stmt1;\n" + "DEALLOCATE PREPARE stmt1;\n" + "SELECT 2,4,5;\n" + "END"; -const char* test15_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT 1,3;\n" - "SET @table = 't1';\n" - "SET @s = CONCAT('SELECT * FROM ', @table, ' LIMIT 100');\n" - "PREPARE stmt1 FROM @s;\n" - "EXECUTE stmt1;\n" - "DEALLOCATE PREPARE stmt1;\n" - "SELECT 2,4,5;\n" - "END"; +const char* test15_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT 1,3;\n" + "SET @table = 't1';\n" + "SET @s = CONCAT('SELECT * FROM ', @table, ' LIMIT 100');\n" + "PREPARE stmt1 FROM @s;\n" + "EXECUTE stmt1;\n" + "DEALLOCATE PREPARE stmt1;\n" + "SELECT 2,4,5;\n" + "END"; -const char* test17_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT '' as 'A' limit 1;\n" - "SELECT '' as 'A' limit 10;\n" - "SELECT '' as 'A';\n" - "END"; +const char* test17_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT '' as 'A' limit 1;\n" + "SELECT '' as 'A' limit 10;\n" + "SELECT '' as 'A';\n" + "END"; -const char* test18_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT '' as 'A' limit 1;\n" - "SELECT '' as 'A' limit 10;\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A' limit 1;\n" - "SELECT '' as 'A' limit 10;\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "END"; +const char* test18_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT '' as 'A' limit 1;\n" + "SELECT '' as 'A' limit 10;\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A' limit 1;\n" + "SELECT '' as 'A' limit 10;\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "END"; -const char* test19_sql - = "CREATE PROCEDURE multi() BEGIN\n" - "SELECT '' as 'A' limit 1;\n" - "SELECT '' as 'A' limit 10;\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A' limit 1;\n" - "SELECT '' as 'A' limit 10;\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "SELECT '' as 'A';\n" - "END"; +const char* test19_sql = + "CREATE PROCEDURE multi() BEGIN\n" + "SELECT '' as 'A' limit 1;\n" + "SELECT '' as 'A' limit 10;\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A' limit 1;\n" + "SELECT '' as 'A' limit 10;\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "SELECT '' as 'A';\n" + "END"; /** * @brief compare_expected Execute sql and compare number of rows in every result set with expected values diff --git a/maxscale-system-test/mxs1295_sp_call.cpp b/maxscale-system-test/mxs1295_sp_call.cpp index a3cc730bb..0515bf1c3 100644 --- a/maxscale-system-test/mxs1295_sp_call.cpp +++ b/maxscale-system-test/mxs1295_sp_call.cpp @@ -3,12 +3,12 @@ */ #include "testconnections.h" -const char sp_sql[] - = "DROP PROCEDURE IF EXISTS multi;" - "CREATE PROCEDURE multi()" - "BEGIN" - " SELECT @@server_id;" - "END"; +const char sp_sql[] = + "DROP PROCEDURE IF EXISTS multi;" + "CREATE PROCEDURE multi()" + "BEGIN" + " SELECT @@server_id;" + "END"; int get_server_id(MYSQL* conn) { diff --git a/maxscale-system-test/mxs1743_rconn_bitmask.cpp b/maxscale-system-test/mxs1743_rconn_bitmask.cpp index 1413e2b50..ab0bf4d3e 100644 --- a/maxscale-system-test/mxs1743_rconn_bitmask.cpp +++ b/maxscale-system-test/mxs1743_rconn_bitmask.cpp @@ -61,8 +61,8 @@ int main(int argc, char** argv) // Give the connections a few seconds to establish sleep(5); - std::string query - = "SELECT COUNT(*) AS connections FROM information_schema.processlist WHERE user = 'mxs1743'"; + std::string query = + "SELECT COUNT(*) AS connections FROM information_schema.processlist WHERE user = 'mxs1743'"; char master_connections[1024]; char slave_connections[1024]; find_field(test.repl->nodes[0], query.c_str(), "connections", master_connections); diff --git a/maxscale-system-test/mxs872_roles.cpp b/maxscale-system-test/mxs872_roles.cpp index 1aa205e13..88aeb52b2 100644 --- a/maxscale-system-test/mxs872_roles.cpp +++ b/maxscale-system-test/mxs872_roles.cpp @@ -34,8 +34,8 @@ int main(int argc, char** argv) test.repl->sync_slaves(); test.tprintf("Connect with a user that has a default role"); - MYSQL* conn - = open_conn_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], "my_db", "test", "test"); + MYSQL* conn = + open_conn_db(test.maxscales->rwsplit_port[0], test.maxscales->IP[0], "my_db", "test", "test"); test.expect(mysql_errno(conn) == 0, "Connection failed: %s", mysql_error(conn)); char value[100] {}; find_field(conn, "SELECT CURRENT_ROLE() AS role", "role", value); diff --git a/maxscale-system-test/mxs922_bad_server.cpp b/maxscale-system-test/mxs922_bad_server.cpp index dfb542115..852c564a3 100644 --- a/maxscale-system-test/mxs922_bad_server.cpp +++ b/maxscale-system-test/mxs922_bad_server.cpp @@ -55,9 +55,9 @@ void do_query(TestConnections* test, bool should_fail) bool failed = execute_query(test->maxscales->conn_rwsplit[0], "select @@server_id") == 0; - const char* msg = should_fail - ? "Query was successful when failure was expected." - : "Query failed when success was expected."; + const char* msg = should_fail ? + "Query was successful when failure was expected." : + "Query failed when success was expected."; test->add_result(failed == should_fail, "%s", msg); test->maxscales->close_maxscale_connections(0); diff --git a/maxscale-system-test/mxs922_restart.cpp b/maxscale-system-test/mxs922_restart.cpp index d68d39106..c0c8ebc08 100644 --- a/maxscale-system-test/mxs922_restart.cpp +++ b/maxscale-system-test/mxs922_restart.cpp @@ -34,9 +34,9 @@ void do_query(TestConnections* test, bool should_fail) bool failed = execute_query(test->maxscales->conn_rwsplit[0], "select @@server_id") == 0; - const char* msg = should_fail - ? "Query was successful when failure was expected." - : "Query failed when success was expected."; + const char* msg = should_fail ? + "Query was successful when failure was expected." : + "Query failed when success was expected."; test->add_result(failed == should_fail, "%s", msg); test->maxscales->close_maxscale_connections(0); diff --git a/maxscale-system-test/mysqlmon_failover_stress.cpp b/maxscale-system-test/mysqlmon_failover_stress.cpp index 33e8ae36d..27369927e 100644 --- a/maxscale-system-test/mysqlmon_failover_stress.cpp +++ b/maxscale-system-test/mysqlmon_failover_stress.cpp @@ -446,11 +446,11 @@ bool check_server_status(TestConnections& test, int id) char result[1024]; if (find_field(pConn, "SHOW SLAVE STATUS", "Last_IO_Error", result) == 0) { - const char needle[] - = ", which is not in the master's binlog. " - "Since the master's binlog contains GTIDs with higher sequence numbers, " - "it probably means that the slave has diverged due to executing extra " - "erroneous transactions"; + const char needle[] = + ", which is not in the master's binlog. " + "Since the master's binlog contains GTIDs with higher sequence numbers, " + "it probably means that the slave has diverged due to executing extra " + "erroneous transactions"; if (strstr(result, needle)) { diff --git a/maxscale-system-test/rds_vpc.cpp b/maxscale-system-test/rds_vpc.cpp index b1d59fd9a..06071b9ca 100644 --- a/maxscale-system-test/rds_vpc.cpp +++ b/maxscale-system-test/rds_vpc.cpp @@ -394,8 +394,8 @@ int RDS::create_gw(const char** gw_id) return -1; } - *gw_id - = json_string_value(json_object_get(json_object_get(root, "InternetGateway"), "InternetGatewayId")); + *gw_id = + json_string_value(json_object_get(json_object_get(root, "InternetGateway"), "InternetGatewayId")); if (*gw_id == NULL) { fprintf(stderr, "error: can not parse output of create-internet-gateway command\n"); diff --git a/maxscale-system-test/readconnrouter_master.cpp b/maxscale-system-test/readconnrouter_master.cpp index c279aacf4..2216f0c3a 100644 --- a/maxscale-system-test/readconnrouter_master.cpp +++ b/maxscale-system-test/readconnrouter_master.cpp @@ -31,11 +31,11 @@ int check_connnections_only_to_master(TestConnections* Test, int master) printf("Checking number of connections to each node\n"); for (int i = 0; i < Test->repl->N; i++) { - conn_num - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->ip(0), - Test->maxscales->hostname[0], - (char*) "test"); + conn_num = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->ip(0), + Test->maxscales->hostname[0], + (char*) "test"); printf("Connections to node %d (%s):\t%d\n", i, Test->repl->IP[i], conn_num); if (((i == master) && (conn_num != 1)) || ((i != master) && (conn_num != 0))) { diff --git a/maxscale-system-test/readconnrouter_slave.cpp b/maxscale-system-test/readconnrouter_slave.cpp index 4aa6fbd31..5e1fd0259 100644 --- a/maxscale-system-test/readconnrouter_slave.cpp +++ b/maxscale-system-test/readconnrouter_slave.cpp @@ -46,11 +46,11 @@ int main(int argc, char* argv[]) Test->tprintf("Checking connections to each node\n"); for (int i = 1; i < Test->repl->N; i++) { - conn_num - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->ip(0), - Test->maxscales->hostname[0], - (char*) "test"); + conn_num = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->ip(0), + Test->maxscales->hostname[0], + (char*) "test"); TotalConn += conn_num; printf("Connections to node %d (%s):\t%d\n", i, Test->repl->IP[i], conn_num); if ((conn_num > ConnCell) || (conn_num < ConnFloor)) diff --git a/maxscale-system-test/rwsplit_conn_num.cpp b/maxscale-system-test/rwsplit_conn_num.cpp index 8ad6eb31d..8df9d385c 100644 --- a/maxscale-system-test/rwsplit_conn_num.cpp +++ b/maxscale-system-test/rwsplit_conn_num.cpp @@ -61,11 +61,11 @@ int main(int argc, char* argv[]) Test->tprintf("Checking connections to each node\n"); for (int i = 1; i < Test->repl->N; i++) { - conn_num - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->ip(0), - Test->maxscales->hostname[0], - (char*) "test"); + conn_num = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->ip(0), + Test->maxscales->hostname[0], + (char*) "test"); TotalConn += conn_num; Test->tprintf("Connections to node %d (%s):\t%d\n", i, Test->repl->IP[i], conn_num); if ((conn_num > ConnCell) || (conn_num < ConnFloor)) diff --git a/maxscale-system-test/rwsplit_connect.cpp b/maxscale-system-test/rwsplit_connect.cpp index cb17f5c9d..047e41627 100644 --- a/maxscale-system-test/rwsplit_connect.cpp +++ b/maxscale-system-test/rwsplit_connect.cpp @@ -22,11 +22,11 @@ int main(int argc, char* argv[]) Test->tprintf("Checking number of connections ot backend servers\n"); for (int i = 0; i < Test->repl->N; i++) { - conn_num - = get_conn_num(Test->repl->nodes[i], - Test->maxscales->ip(0), - Test->maxscales->hostname[0], - (char*) "test"); + conn_num = + get_conn_num(Test->repl->nodes[i], + Test->maxscales->ip(0), + Test->maxscales->hostname[0], + (char*) "test"); Test->tprintf("connections: %u\n", conn_num); if ((i == 0) && (conn_num != 1)) { diff --git a/maxscale-system-test/sql_const.h b/maxscale-system-test/sql_const.h index d64e397b1..215f58d22 100644 --- a/maxscale-system-test/sql_const.h +++ b/maxscale-system-test/sql_const.h @@ -1,25 +1,25 @@ #ifndef SQL_CONST_H #define SQL_CONST_H -const char* create_repl_user - = "grant replication slave on *.* to repl@'%%' identified by 'repl'; " - "FLUSH PRIVILEGES"; -const char* setup_slave - = "change master to MASTER_HOST='%s', " - "MASTER_USER='repl', " - "MASTER_PASSWORD='repl', " - "MASTER_LOG_FILE='%s', " - "MASTER_LOG_POS=%s, " - "MASTER_PORT=%d; " - "start slave;"; +const char* create_repl_user = + "grant replication slave on *.* to repl@'%%' identified by 'repl'; " + "FLUSH PRIVILEGES"; +const char* setup_slave = + "change master to MASTER_HOST='%s', " + "MASTER_USER='repl', " + "MASTER_PASSWORD='repl', " + "MASTER_LOG_FILE='%s', " + "MASTER_LOG_POS=%s, " + "MASTER_PORT=%d; " + "start slave;"; -const char* setup_slave_no_pos - = "change master to MASTER_HOST='%s', " - "MASTER_USER='repl', " - "MASTER_PASSWORD='repl', " - "MASTER_LOG_FILE='mar-bin.000001', " - "MASTER_LOG_POS=4, " - "MASTER_PORT=%d"; +const char* setup_slave_no_pos = + "change master to MASTER_HOST='%s', " + "MASTER_USER='repl', " + "MASTER_PASSWORD='repl', " + "MASTER_LOG_FILE='mar-bin.000001', " + "MASTER_LOG_POS=4, " + "MASTER_PORT=%d"; #endif // SQL_CONST_H diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 8f1840fbe..0478a5160 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -948,8 +948,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); + binlog = + open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl); execute_query(binlog, "stop slave"); execute_query(binlog, "reset slave all"); mysql_close(binlog); @@ -1015,8 +1015,8 @@ int TestConnections::start_binlog(int m) add_result(maxscales->start_maxscale(m), "Maxscale start failed\n"); tprintf("Connecting to MaxScale binlog router (with any DB)\n"); - binlog - = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl); + binlog = + open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl); add_result(mysql_errno(binlog), "Error connection to binlog router %s\n", mysql_error(binlog)); @@ -1562,8 +1562,8 @@ int TestConnections::create_connections(int m, printf("Galera \n"); } - galera_conn[i] - = open_conn(4016, maxscales->IP[m], maxscales->user_name, maxscales->password, ssl); + galera_conn[i] = + open_conn(4016, maxscales->IP[m], maxscales->user_name, maxscales->password, ssl); if (mysql_errno(galera_conn[i]) != 0) { local_result++; diff --git a/maxutils/maxbase/src/log.cc b/maxutils/maxbase/src/log.cc index 0e6475c4e..77d5ea7ce 100644 --- a/maxutils/maxbase/src/log.cc +++ b/maxutils/maxbase/src/log.cc @@ -719,8 +719,8 @@ int mxb_log_message(int priority, int modname_len = modname ? strlen(modname) + 3 : 0; // +3 due to "[...] " - static const char SUPPRESSION[] - = " (subsequent similar messages suppressed for %lu milliseconds)"; + static const char SUPPRESSION[] = + " (subsequent similar messages suppressed for %lu milliseconds)"; int suppression_len = 0; size_t suppress_ms = this_unit.throttling.suppress_ms; diff --git a/maxutils/maxbase/src/maxbase.cc b/maxutils/maxbase/src/maxbase.cc index 55eac2945..b8bd4cea2 100644 --- a/maxutils/maxbase/src/maxbase.cc +++ b/maxutils/maxbase/src/maxbase.cc @@ -103,9 +103,9 @@ MaxBase::MaxBase(const char* zIdent, if (!m_log_inited) { - zMessage - = "The initialization of the MaxScale base library succeeded, but the " - "initialization of the MaxScale log failed."; + zMessage = + "The initialization of the MaxScale base library succeeded, but the " + "initialization of the MaxScale log failed."; } } else diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index 02450d78d..3e29a3373 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -2479,9 +2479,9 @@ static QC_FUNCTION_INFO* get_function_info(parsing_info_t* info, const char* nam if (info->function_infos_len == info->function_infos_capacity) { size_t capacity = info->function_infos_capacity ? 2 * info->function_infos_capacity : 8; - QC_FUNCTION_INFO* function_infos - = (QC_FUNCTION_INFO*)realloc(info->function_infos, - capacity * sizeof(QC_FUNCTION_INFO)); + QC_FUNCTION_INFO* function_infos = + (QC_FUNCTION_INFO*)realloc(info->function_infos, + capacity * sizeof(QC_FUNCTION_INFO)); assert(function_infos); info->function_infos = function_infos; @@ -2977,8 +2977,8 @@ static void update_field_infos(parsing_info_t* pi, case Item_subselect::EXISTS_SUBS: { - Item_exists_subselect* exists_subselect_item - = static_cast(item); + Item_exists_subselect* exists_subselect_item = + static_cast(item); st_select_lex* ssl = exists_subselect_item->get_select_lex(); if (ssl) diff --git a/query_classifier/qc_sqlite/builtin_functions.c b/query_classifier/qc_sqlite/builtin_functions.c index 7c2f185bc..84960fdc3 100644 --- a/query_classifier/qc_sqlite/builtin_functions.c +++ b/query_classifier/qc_sqlite/builtin_functions.c @@ -441,8 +441,8 @@ static const char* BUILTIN_10_2_3_FUNCTIONS[] = "row_number", }; -const size_t N_BUILTIN_10_2_3_FUNCTIONS - = sizeof(BUILTIN_10_2_3_FUNCTIONS) / sizeof(BUILTIN_10_2_3_FUNCTIONS[0]); +const size_t N_BUILTIN_10_2_3_FUNCTIONS = + sizeof(BUILTIN_10_2_3_FUNCTIONS) / sizeof(BUILTIN_10_2_3_FUNCTIONS[0]); static const char* ORACLE_FUNCTIONS[] = { diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index 6fcf32e04..ded76edbe 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -3393,17 +3393,17 @@ static void parse_query_string(const char* query, int len, bool suppress_logging { if (qc_info_was_tokenized(this_thread.pInfo->m_status)) { - format - = "Statement was classified only based on keywords " - "(Sqlite3 error: %s, %s): \"%.*s%s\""; + format = + "Statement was classified only based on keywords " + "(Sqlite3 error: %s, %s): \"%.*s%s\""; } else { if (qc_info_was_parsed(this_thread.pInfo->m_status)) { - format - = "Statement was only partially parsed " - "(Sqlite3 error: %s, %s): \"%.*s%s\""; + format = + "Statement was only partially parsed " + "(Sqlite3 error: %s, %s): \"%.*s%s\""; // The status was set to QC_QUERY_PARSED, but sqlite3 returned an // error. Most likely, query contains some excess unrecognized stuff. @@ -3411,9 +3411,9 @@ static void parse_query_string(const char* query, int len, bool suppress_logging } else { - format - = "Statement was neither parsed nor recognized from keywords " - "(Sqlite3 error: %s, %s): \"%.*s%s\""; + format = + "Statement was neither parsed nor recognized from keywords " + "(Sqlite3 error: %s, %s): \"%.*s%s\""; } } @@ -3461,9 +3461,9 @@ static void parse_query_string(const char* query, int len, bool suppress_logging if (qc_info_was_tokenized(this_thread.pInfo->m_status)) { // This suggests a callback from the parser into this module is not made. - format - = "Statement was classified only based on keywords, " - "even though the statement was parsed: \"%.*s%s\""; + format = + "Statement was classified only based on keywords, " + "even though the statement was parsed: \"%.*s%s\""; MXS_WARNING(format, l, query, suffix); } @@ -3503,8 +3503,8 @@ static bool parse_query(GWBUF* query, uint32_t collect) { bool suppress_logging = false; - QcSqliteInfo* pInfo - = (QcSqliteInfo*) gwbuf_get_buffer_object_data(query, GWBUF_PARSING_INFO); + QcSqliteInfo* pInfo = + (QcSqliteInfo*) gwbuf_get_buffer_object_data(query, GWBUF_PARSING_INFO); if (pInfo) { diff --git a/query_classifier/test/compare.cc b/query_classifier/test/compare.cc index f5e1fef33..c6ec919d7 100644 --- a/query_classifier/test/compare.cc +++ b/query_classifier/test/compare.cc @@ -47,24 +47,24 @@ using std::stringstream; namespace { -char USAGE[] - = "usage: compare [-r count] [-d] [-1 classfier1] [-2 classifier2] " - "[-A args] [-B args] [-C args] [-m [default|oracle]] [-v [0..2]] [-s statement]|[file]]\n\n" - "-r redo the test the specified number of times; 0 means forever, default is 1\n" - "-d don't stop after first failed query\n" - "-1 the first classifier, default 'qc_mysqlembedded'\n" - "-2 the second classifier, default 'qc_sqlite'\n" - "-A arguments for the first classifier\n" - "-B arguments for the second classifier\n" - "-C arguments for both classifiers\n" - "-m initial sql mode, 'default' or 'oracle', default is 'default'\n" - "-s compare single statement\n" - "-S strict, also require that the parse result is identical\n" - "-R strict reporting, report if parse result is different\n" - "-v 0, only return code\n" - " 1, query and result for failed cases\n" - " 2, all queries, and result for failed cases\n" - " 3, all queries and all results\n"; +char USAGE[] = + "usage: compare [-r count] [-d] [-1 classfier1] [-2 classifier2] " + "[-A args] [-B args] [-C args] [-m [default|oracle]] [-v [0..2]] [-s statement]|[file]]\n\n" + "-r redo the test the specified number of times; 0 means forever, default is 1\n" + "-d don't stop after first failed query\n" + "-1 the first classifier, default 'qc_mysqlembedded'\n" + "-2 the second classifier, default 'qc_sqlite'\n" + "-A arguments for the first classifier\n" + "-B arguments for the second classifier\n" + "-C arguments for both classifiers\n" + "-m initial sql mode, 'default' or 'oracle', default is 'default'\n" + "-s compare single statement\n" + "-S strict, also require that the parse result is identical\n" + "-R strict reporting, report if parse result is different\n" + "-v 0, only return code\n" + " 1, query and result for failed cases\n" + " 2, all queries, and result for failed cases\n" + " 3, all queries and all results\n"; enum verbosity_t diff --git a/rabbitmq_consumer/consumer.c b/rabbitmq_consumer/consumer.c index 35547a703..a78d23fd2 100644 --- a/rabbitmq_consumer/consumer.c +++ b/rabbitmq_consumer/consumer.c @@ -49,8 +49,8 @@ static char* DB_TABLE "CREATE TABLE IF NOT EXISTS pairs (tag VARCHAR(64) PRIMARY KEY NOT NULL, query VARCHAR(2048), reply VARCHAR(2048), date_in DATETIME NOT NULL, date_out DATETIME DEFAULT NULL, counter INT DEFAULT 1)"; static char* DB_INSERT = "INSERT INTO pairs(tag, query, date_in) VALUES ('%s','%s',FROM_UNIXTIME(%s))"; static char* DB_UPDATE = "UPDATE pairs SET reply='%s', date_out=FROM_UNIXTIME(%s) WHERE tag='%s'"; -static char* DB_INCREMENT - = "UPDATE pairs SET counter = counter+1, date_out=FROM_UNIXTIME(%s) WHERE query='%s'"; +static char* DB_INCREMENT = + "UPDATE pairs SET counter = counter+1, date_out=FROM_UNIXTIME(%s) WHERE query='%s'"; void sighndl(int signum) { @@ -125,9 +125,9 @@ int handler(void* user, int isPair(amqp_message_t* a, amqp_message_t* b) { int keylen = a->properties.correlation_id.len - >= b->properties.correlation_id.len - ? a->properties.correlation_id.len - : b->properties.correlation_id.len; + >= b->properties.correlation_id.len ? + a->properties.correlation_id.len : + b->properties.correlation_id.len; return strncmp(a->properties.correlation_id.bytes, b->properties.correlation_id.bytes, diff --git a/server/core/admin.cc b/server/core/admin.cc index ae67e4bad..167ae193a 100644 --- a/server/core/admin.cc +++ b/server/core/admin.cc @@ -81,10 +81,10 @@ static bool modifies_data(MHD_Connection* connection, string method) static void send_auth_error(MHD_Connection* connection) { static char error_resp[] = "{\"errors\": [ { \"detail\": \"Access denied\" } ] }"; - MHD_Response* resp - = MHD_create_response_from_buffer(sizeof(error_resp) - 1, - error_resp, - MHD_RESPMEM_PERSISTENT); + MHD_Response* resp = + MHD_create_response_from_buffer(sizeof(error_resp) - 1, + error_resp, + MHD_RESPMEM_PERSISTENT); MHD_queue_basic_auth_fail_response(connection, "maxscale", resp); MHD_destroy_response(resp); @@ -148,10 +148,10 @@ int Client::process(string url, string method, const char* upload_data, size_t* data = mxs::json_dump(js, flags); } - MHD_Response* response - = MHD_create_response_from_buffer(data.size(), - (void*)data.c_str(), - MHD_RESPMEM_MUST_COPY); + MHD_Response* response = + MHD_create_response_from_buffer(data.size(), + (void*)data.c_str(), + MHD_RESPMEM_MUST_COPY); const Headers& headers = reply.get_headers(); @@ -413,8 +413,8 @@ bool mxs_admin_init() NULL, MHD_OPTION_SOCK_ADDR, &addr, - !using_ssl ? MHD_OPTION_END - : MHD_OPTION_HTTPS_MEM_KEY, + !using_ssl ? MHD_OPTION_END : + MHD_OPTION_HTTPS_MEM_KEY, admin_ssl_key, MHD_OPTION_HTTPS_MEM_CERT, admin_ssl_cert, diff --git a/server/core/config.cc b/server/core/config.cc index b263b3c82..12c524df7 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -4626,13 +4626,13 @@ static pcre2_code* compile_regex_string(const char* regex_string, int errorcode = -1; PCRE2_SIZE error_offset = -1; uint32_t capcount = 0; - pcre2_code* machine - = pcre2_compile((PCRE2_SPTR) regex_string, - PCRE2_ZERO_TERMINATED, - options, - &errorcode, - &error_offset, - NULL); + pcre2_code* machine = + pcre2_compile((PCRE2_SPTR) regex_string, + PCRE2_ZERO_TERMINATED, + options, + &errorcode, + &error_offset, + NULL); if (machine) { if (jit_enabled) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 23dd709d8..892214420 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -934,14 +934,14 @@ bool runtime_create_listener(Service* service, SSL_LISTENER* ssl = NULL; if (ssl_key && ssl_cert && ssl_ca - && (ssl - = create_ssl(name, - ssl_key, - ssl_cert, - ssl_ca, - ssl_version, - ssl_depth, - verify_ssl)) == NULL) + && (ssl = + create_ssl(name, + ssl_key, + ssl_cert, + ssl_ca, + ssl_version, + ssl_depth, + verify_ssl)) == NULL) { MXS_ERROR("SSL initialization for listener '%s' failed.", name); config_runtime_error("SSL initialization for listener '%s' failed.", name); @@ -2564,14 +2564,14 @@ bool runtime_create_listener_from_json(Service* service, json_t* json) const char* address = get_string_or_null(json, MXS_JSON_PTR_PARAM_ADDRESS); const char* protocol = get_string_or_null(json, MXS_JSON_PTR_PARAM_PROTOCOL); const char* authenticator = get_string_or_null(json, MXS_JSON_PTR_PARAM_AUTHENTICATOR); - const char* authenticator_options - = get_string_or_null(json, MXS_JSON_PTR_PARAM_AUTHENTICATOR_OPTIONS); + const char* authenticator_options = + get_string_or_null(json, MXS_JSON_PTR_PARAM_AUTHENTICATOR_OPTIONS); const char* ssl_key = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_KEY); const char* ssl_cert = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_CERT); const char* ssl_ca_cert = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_CA_CERT); const char* ssl_version = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_VERSION); - const char* ssl_cert_verify_depth - = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_CERT_VERIFY_DEPTH); + const char* ssl_cert_verify_depth = + get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_CERT_VERIFY_DEPTH); const char* ssl_verify_peer_certificate = get_string_or_null(json, MXS_JSON_PTR_PARAM_SSL_VERIFY_PEER_CERT); @@ -2708,15 +2708,15 @@ bool runtime_create_user_from_json(json_t* json) bool runtime_remove_user(const char* id, enum user_type type) { bool rval = false; - const char* err = type == USER_TYPE_INET - ? admin_remove_inet_user(id) - : admin_disable_linux_account(id); + const char* err = type == USER_TYPE_INET ? + admin_remove_inet_user(id) : + admin_disable_linux_account(id); if (err == ADMIN_SUCCESS) { MXS_NOTICE("%s '%s'", - type == USER_TYPE_INET - ? "Deleted network user" : "Disabled account", + type == USER_TYPE_INET ? + "Deleted network user" : "Disabled account", id); rval = true; } diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 59809eb31..9f4fec11e 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -430,9 +430,9 @@ DCB* dcb_connect(SERVER* server, MXS_SESSION* session, const char* protocol) dcb->remote = MXS_STRDUP_A(session->client_dcb->remote); } - const char* authenticator = server->authenticator - ? server->authenticator : dcb->func.auth_default - ? dcb->func.auth_default() : "NullAuthDeny"; + const char* authenticator = server->authenticator ? + server->authenticator : dcb->func.auth_default ? + dcb->func.auth_default() : "NullAuthDeny"; MXS_AUTHENTICATOR* authfuncs = (MXS_AUTHENTICATOR*)load_module(authenticator, MODULE_AUTHENTICATOR); @@ -1601,8 +1601,8 @@ static bool dlist_clients_cb(DCB* dcb, void* data) " %-15s | %16p | %-20s | %10p\n", (dcb->remote ? dcb->remote : ""), dcb, - (dcb->session->service - ? dcb->session->service->name : ""), + (dcb->session->service ? + dcb->session->service->name : ""), dcb->session); } @@ -2495,8 +2495,8 @@ DCB* dcb_accept(DCB* dcb) /** Allocate DCB specific authentication data */ if (client_dcb->authfunc.create - && (client_dcb->authenticator_data - = client_dcb->authfunc.create(client_dcb->listener->auth_instance)) == NULL) + && (client_dcb->authenticator_data = + client_dcb->authfunc.create(client_dcb->listener->auth_instance)) == NULL) { MXS_ERROR("Failed to create authenticator for client DCB"); dcb_close(client_dcb); @@ -3138,9 +3138,9 @@ static uint32_t dcb_process_poll_events(DCB* dcb, uint32_t events) * until it return 1 for success or -1 for error */ if (dcb->ssl_state == SSL_HANDSHAKE_REQUIRED) { - return_code = (DCB_ROLE_CLIENT_HANDLER == dcb->dcb_role) - ? dcb_accept_SSL(dcb) - : dcb_connect_SSL(dcb); + return_code = (DCB_ROLE_CLIENT_HANDLER == dcb->dcb_role) ? + dcb_accept_SSL(dcb) : + dcb_connect_SSL(dcb); } if (1 == return_code) { diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 321a3c0ee..08a31b940 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -265,8 +265,8 @@ struct CRYPTO_dynlock_value */ static struct CRYPTO_dynlock_value* ssl_create_dynlock(const char* file, int line) { - struct CRYPTO_dynlock_value* lock - = (struct CRYPTO_dynlock_value*) MXS_MALLOC(sizeof(struct CRYPTO_dynlock_value)); + struct CRYPTO_dynlock_value* lock = + (struct CRYPTO_dynlock_value*) MXS_MALLOC(sizeof(struct CRYPTO_dynlock_value)); if (lock) { spinlock_init(&lock->lock); @@ -335,11 +335,11 @@ static void sigusr1_handler(int i) } static const char shutdown_msg[] = "\n\nShutting down MaxScale\n\n"; -static const char patience_msg[] - = "\n" - "Patience is a virtue...\n" - "Shutdown in progress, but one more Ctrl-C or SIGTERM and MaxScale goes down,\n" - "no questions asked.\n"; +static const char patience_msg[] = + "\n" + "Patience is a virtue...\n" + "Shutdown in progress, but one more Ctrl-C or SIGTERM and MaxScale goes down,\n" + "no questions asked.\n"; static void sigterm_handler(int i) { @@ -1450,12 +1450,12 @@ int main(int argc, char** argv) } if (cnf_file_arg == NULL) { - const char* logerr - = "Configuration file argument " - "identifier \'-f\' was specified but " - "the argument didn't specify\n a valid " - "configuration file or the argument " - "was missing."; + const char* logerr = + "Configuration file argument " + "identifier \'-f\' was specified but " + "the argument didn't specify\n a valid " + "configuration file or the argument " + "was missing."; print_log_n_stderr(true, true, logerr, logerr, 0); usage(); succp = false; @@ -1503,12 +1503,12 @@ int main(int argc, char** argv) } else { - const char* logerr - = "Configuration file argument " - "identifier \'-l\' was specified but " - "the argument didn't specify\n a valid " - "configuration file or the argument " - "was missing."; + const char* logerr = + "Configuration file argument " + "identifier \'-l\' was specified but " + "the argument didn't specify\n a valid " + "configuration file or the argument " + "was missing."; print_log_n_stderr(true, true, logerr, logerr, 0); usage(); succp = false; @@ -2119,9 +2119,9 @@ int main(int argc, char** argv) if (!config_load(cnf_file_path)) { - const char* fprerr - = "Failed to open, read or process the MaxScale configuration " - "file. Exiting. See the error log for details."; + const char* fprerr = + "Failed to open, read or process the MaxScale configuration " + "file. Exiting. See the error log for details."; print_log_n_stderr(false, true, fprerr, fprerr, 0); MXS_ERROR("Failed to open, read or process the MaxScale configuration file %s. " "Exiting.", @@ -2421,10 +2421,10 @@ bool pid_file_exists() else if (b == 0) { /** Empty file */ - const char* logerr - = "PID file read from '%s'. File was empty.\n" - "If the file is the correct PID file and no other MaxScale processes " - "are running, please remove it manually and start MaxScale again."; + const char* logerr = + "PID file read from '%s'. File was empty.\n" + "If the file is the correct PID file and no other MaxScale processes " + "are running, please remove it manually and start MaxScale again."; snprintf(logbuf, sizeof(logbuf), logerr, pathbuf); print_log_n_stderr(true, true, logbuf, logbuf, errno); unlock_pidfile(); @@ -2437,10 +2437,10 @@ bool pid_file_exists() if (pid < 1) { /** Bad PID */ - const char* logerr - = "PID file read from '%s'. File contents not valid.\n" - "If the file is the correct PID file and no other MaxScale processes " - "are running, please remove it manually and start MaxScale again."; + const char* logerr = + "PID file read from '%s'. File contents not valid.\n" + "If the file is the correct PID file and no other MaxScale processes " + "are running, please remove it manually and start MaxScale again."; snprintf(logbuf, sizeof(logbuf), logerr, pathbuf); print_log_n_stderr(true, true, logbuf, logbuf, errno); unlock_pidfile(); @@ -2449,10 +2449,10 @@ bool pid_file_exists() if (pid_is_maxscale(pid)) { - const char* logerr - = "MaxScale is already running. Process id: %d. " - "Use another location for the PID file to run multiple " - "instances of MaxScale on the same machine."; + const char* logerr = + "MaxScale is already running. Process id: %d. " + "Use another location for the PID file to run multiple " + "instances of MaxScale on the same machine."; snprintf(logbuf, sizeof(logbuf), logerr, pid); print_log_n_stderr(true, true, logbuf, logbuf, 0); unlock_pidfile(); @@ -2462,10 +2462,10 @@ bool pid_file_exists() /** no such process, old PID file */ if (lock_failed) { - const char* logerr - = "Locking the PID file '%s' failed. " - "Read PID from file and no process found with PID %d. " - "Confirm that no other process holds the lock on the PID file."; + const char* logerr = + "Locking the PID file '%s' failed. " + "Read PID from file and no process found with PID %d. " + "Confirm that no other process holds the lock on the PID file."; snprintf(logbuf, sizeof(logbuf), logerr, pathbuf, pid); print_log_n_stderr(true, true, logbuf, logbuf, 0); close(fd); @@ -2475,9 +2475,9 @@ bool pid_file_exists() } else { - const char* logerr - = "Cannot open PID file '%s', no read permissions. " - "Please confirm that the user running MaxScale has read permissions on the file."; + const char* logerr = + "Cannot open PID file '%s', no read permissions. " + "Please confirm that the user running MaxScale has read permissions on the file."; snprintf(logbuf, sizeof(logbuf), logerr, pathbuf); print_log_n_stderr(true, true, logbuf, logbuf, errno); } @@ -3020,14 +3020,14 @@ static bool sniff_configuration(const char* filepath) if (rv != 0) { - const char FORMAT_CUSTOM[] - = "Failed to pre-parse configuration file %s. Error on line %d. %s"; - const char FORMAT_SYNTAX[] - = "Failed to pre-parse configuration file %s. Error on line %d."; - const char FORMAT_OPEN[] - = "Failed to pre-parse configuration file %s. Failed to open file."; - const char FORMAT_MALLOC[] - = "Failed to pre-parse configuration file %s. Memory allocation failed."; + const char FORMAT_CUSTOM[] = + "Failed to pre-parse configuration file %s. Error on line %d. %s"; + const char FORMAT_SYNTAX[] = + "Failed to pre-parse configuration file %s. Error on line %d."; + const char FORMAT_OPEN[] = + "Failed to pre-parse configuration file %s. Failed to open file."; + const char FORMAT_MALLOC[] = + "Failed to pre-parse configuration file %s. Memory allocation failed."; size_t extra = strlen(filepath) + UINTLEN(abs(rv)) + (s ? strlen(s) : 0); // We just use the largest one. @@ -3223,10 +3223,10 @@ static bool handle_debug_args(char* args) strcat(arglist, ", "); } } - const char DEBUG_ERROR_P1[] - = "Debug argument identifier '-g' or '--debug' was specified " - "but no arguments were found or one of them was invalid. Supported " - "arguments are: "; + const char DEBUG_ERROR_P1[] = + "Debug argument identifier '-g' or '--debug' was specified " + "but no arguments were found or one of them was invalid. Supported " + "arguments are: "; const char DEBUG_ERROR_P2[] = "."; size_t arg_error_msg_len = sizeof(DEBUG_ERROR_P1) + total_len + sizeof(DEBUG_ERROR_P2); char arg_error_msg[arg_error_msg_len]; diff --git a/server/core/load_utils.cc b/server/core/load_utils.cc index c68eac65e..db026eb2c 100644 --- a/server/core/load_utils.cc +++ b/server/core/load_utils.cc @@ -435,16 +435,16 @@ void dprintAllModules(DCB* dcb) ptr->info->api_version.major, ptr->info->api_version.minor, ptr->info->api_version.patch, - ptr->info->status == MXS_MODULE_IN_DEVELOPMENT - ? "In Development" - : (ptr->info->status == MXS_MODULE_ALPHA_RELEASE - ? "Alpha" - : (ptr->info->status == MXS_MODULE_BETA_RELEASE - ? "Beta" - : (ptr->info->status == MXS_MODULE_GA - ? "GA" - : (ptr->info->status == MXS_MODULE_EXPERIMENTAL - ? "Experimental" : "Unknown"))))); + ptr->info->status == MXS_MODULE_IN_DEVELOPMENT ? + "In Development" : + (ptr->info->status == MXS_MODULE_ALPHA_RELEASE ? + "Alpha" : + (ptr->info->status == MXS_MODULE_BETA_RELEASE ? + "Beta" : + (ptr->info->status == MXS_MODULE_GA ? + "GA" : + (ptr->info->status == MXS_MODULE_EXPERIMENTAL ? + "Experimental" : "Unknown"))))); } dcb_printf(dcb, "\n"); ptr = ptr->next; diff --git a/server/core/modulecmd.cc b/server/core/modulecmd.cc index 69c708210..1032b6ec4 100644 --- a/server/core/modulecmd.cc +++ b/server/core/modulecmd.cc @@ -646,17 +646,17 @@ bool modulecmd_foreach(const char* domain_re, for (MODULECMD_DOMAIN* domain = modulecmd_domains; domain && rval && !stop; domain = domain->next) { int err; - mxs_pcre2_result_t d_res = domain_re - ? mxs_pcre2_simple_match(domain_re, domain->domain, PCRE2_CASELESS, &err) - : MXS_PCRE2_MATCH; + mxs_pcre2_result_t d_res = domain_re ? + mxs_pcre2_simple_match(domain_re, domain->domain, PCRE2_CASELESS, &err) : + MXS_PCRE2_MATCH; if (d_res == MXS_PCRE2_MATCH) { for (MODULECMD* cmd = domain->commands; cmd && rval; cmd = cmd->next) { - mxs_pcre2_result_t i_res = ident_re - ? mxs_pcre2_simple_match(ident_re, cmd->identifier, PCRE2_CASELESS, &err) - : MXS_PCRE2_MATCH; + mxs_pcre2_result_t i_res = ident_re ? + mxs_pcre2_simple_match(ident_re, cmd->identifier, PCRE2_CASELESS, &err) : + MXS_PCRE2_MATCH; if (i_res == MXS_PCRE2_MATCH) { diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 84ae4b408..5c084c847 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -597,8 +597,8 @@ void monitor_list(DCB* dcb) dcb_printf(dcb, "%-20s | %s\n", ptr->name, - ptr->state & MONITOR_STATE_RUNNING - ? "Running" : "Stopped"); + ptr->state & MONITOR_STATE_RUNNING ? + "Running" : "Stopped"); } ptr = ptr->next; } @@ -1028,48 +1028,48 @@ static mxs_monitor_event_t mon_get_event_type(MXS_MONITORED_SERVER* node) switch (event_type) { case UP_EVENT: - rval = (present & SERVER_MASTER) ? MASTER_UP_EVENT - : (present & SERVER_SLAVE) ? SLAVE_UP_EVENT - : (present - & SERVER_JOINED) ? SYNCED_UP_EVENT - : (present - & SERVER_NDB) - ? NDB_UP_EVENT - : + rval = (present & SERVER_MASTER) ? MASTER_UP_EVENT : + (present & SERVER_SLAVE) ? SLAVE_UP_EVENT : + (present + & SERVER_JOINED) ? SYNCED_UP_EVENT : + (present + & SERVER_NDB) ? + NDB_UP_EVENT + : SERVER_UP_EVENT; break; case DOWN_EVENT: - rval = (prev & SERVER_MASTER) ? MASTER_DOWN_EVENT - : (prev & SERVER_SLAVE) ? SLAVE_DOWN_EVENT - : (prev & SERVER_JOINED) ? SYNCED_DOWN_EVENT - : (prev - & SERVER_NDB) - ? NDB_DOWN_EVENT - : + rval = (prev & SERVER_MASTER) ? MASTER_DOWN_EVENT : + (prev & SERVER_SLAVE) ? SLAVE_DOWN_EVENT : + (prev & SERVER_JOINED) ? SYNCED_DOWN_EVENT : + (prev + & SERVER_NDB) ? + NDB_DOWN_EVENT + : SERVER_DOWN_EVENT; break; case LOSS_EVENT: - rval = (prev & SERVER_MASTER) ? LOST_MASTER_EVENT - : (prev & SERVER_SLAVE) ? LOST_SLAVE_EVENT - : (prev & SERVER_JOINED) ? LOST_SYNCED_EVENT - : (prev - & SERVER_NDB) - ? LOST_NDB_EVENT - : + rval = (prev & SERVER_MASTER) ? LOST_MASTER_EVENT : + (prev & SERVER_SLAVE) ? LOST_SLAVE_EVENT : + (prev & SERVER_JOINED) ? LOST_SYNCED_EVENT : + (prev + & SERVER_NDB) ? + LOST_NDB_EVENT + : UNDEFINED_EVENT; break; case NEW_EVENT: - rval = (present & SERVER_MASTER) ? NEW_MASTER_EVENT - : (present & SERVER_SLAVE) ? NEW_SLAVE_EVENT - : (present - & SERVER_JOINED) ? NEW_SYNCED_EVENT - : (present - & SERVER_NDB) - ? NEW_NDB_EVENT - : + rval = (present & SERVER_MASTER) ? NEW_MASTER_EVENT : + (present & SERVER_SLAVE) ? NEW_SLAVE_EVENT : + (present + & SERVER_JOINED) ? NEW_SYNCED_EVENT : + (present + & SERVER_NDB) ? + NEW_NDB_EVENT + : UNDEFINED_EVENT; break; @@ -2430,8 +2430,8 @@ int mon_config_get_servers(const MXS_CONFIG_PARAMETER* params, // All servers in the array must be monitored by the given monitor. if (servers_size > 0) { - MXS_MONITORED_SERVER** monitored_array - = (MXS_MONITORED_SERVER**)MXS_CALLOC(servers_size, sizeof(MXS_MONITORED_SERVER*)); + MXS_MONITORED_SERVER** monitored_array = + (MXS_MONITORED_SERVER**)MXS_CALLOC(servers_size, sizeof(MXS_MONITORED_SERVER*)); for (int i = 0; i < servers_size; i++) { MXS_MONITORED_SERVER* mon_serv = mon_get_monitored_server(mon, servers[i]); @@ -2660,9 +2660,9 @@ void MonitorInstance::update_disk_space_status(MXS_MONITORED_SERVER* pMs) { bool disk_space_exhausted = false; - MxsDiskSpaceThreshold* pDst - = pMs->server->disk_space_threshold - ? pMs->server->disk_space_threshold : m_monitor->disk_space_threshold; + MxsDiskSpaceThreshold* pDst = + pMs->server->disk_space_threshold ? + pMs->server->disk_space_threshold : m_monitor->disk_space_threshold; mxb_assert(pDst); int32_t star_max_percentage = -1; @@ -2924,8 +2924,8 @@ bool MonitorInstance::call_run_one_tick(Worker::Call::action_t action) int64_t ms_to_next_call = m_monitor->interval - (now - m_loop_called); // ms_to_next_call will be negative, if the run_one_tick() call took // longer than one monitor interval. - int64_t delay = ((ms_to_next_call <= 0) || (ms_to_next_call >= MXS_MON_BASE_INTERVAL_MS)) - ? MXS_MON_BASE_INTERVAL_MS : ms_to_next_call; + int64_t delay = ((ms_to_next_call <= 0) || (ms_to_next_call >= MXS_MON_BASE_INTERVAL_MS)) ? + MXS_MON_BASE_INTERVAL_MS : ms_to_next_call; delayed_call(delay, &MonitorInstance::call_run_one_tick, this); } diff --git a/server/core/queryclassifier.cc b/server/core/queryclassifier.cc index c25ef1491..00f649f6b 100644 --- a/server/core/queryclassifier.cc +++ b/server/core/queryclassifier.cc @@ -870,9 +870,9 @@ QueryClassifier::RouteInfo QueryClassifier::update_route_info( // TODO: It may be sufficient to simply check whether we are in a read-only // TODO: transaction. - bool in_read_only_trx - = (current_target != QueryClassifier::CURRENT_TARGET_UNDEFINED) - && session_trx_is_read_only(session()); + bool in_read_only_trx = + (current_target != QueryClassifier::CURRENT_TARGET_UNDEFINED) + && session_trx_is_read_only(session()); if (gwbuf_length(pBuffer) > MYSQL_HEADER_LEN) { diff --git a/server/core/server.cc b/server/core/server.cc index d3c65c866..5a978818e 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -987,8 +987,8 @@ size_t server_get_parameter(const SERVER* server, const char* name, char* out, s */ std::unique_ptr serverGetList() { - std::unique_ptr set - = ResultSet::create({"Server", "Address", "Port", "Connections", "Status"}); + std::unique_ptr set = + ResultSet::create({"Server", "Address", "Port", "Connections", "Status"}); Guard guard(server_lock); for (Server* server : all_servers) diff --git a/server/core/service.cc b/server/core/service.cc index 17073e083..7260fd07f 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -349,8 +349,8 @@ static int serviceStartPort(Service* service, SERV_LISTENER* port) const size_t ANY_IPV4_ADDRESS_LEN = 7; // strlen("0:0:0:0"); int listeners = 0; - size_t config_bind_len - = (port->address ? strlen(port->address) : ANY_IPV4_ADDRESS_LEN) + 1 + UINTLEN(port->port); + size_t config_bind_len = + (port->address ? strlen(port->address) : ANY_IPV4_ADDRESS_LEN) + 1 + UINTLEN(port->port); char config_bind[config_bind_len + 1]; // +1 for NULL MXS_PROTOCOL* funcs; diff --git a/server/core/session.cc b/server/core/session.cc index 1a1562b13..fc0f6bdcf 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -520,10 +520,10 @@ bool dListSessions_cb(DCB* dcb, void* data) dcb_printf(out_dcb, "%-16" PRIu64 " | %-15s | %-14s | %s\n", session->ses_id, - session->client_dcb && session->client_dcb->remote - ? session->client_dcb->remote : "", - session->service && session->service->name - ? session->service->name : "", + session->client_dcb && session->client_dcb->remote ? + session->client_dcb->remote : "", + session->service && session->service->name ? + session->service->name : "", session_state(session->state)); } diff --git a/server/core/test/test_json.cc b/server/core/test/test_json.cc index 84c9ee634..65064a4cc 100644 --- a/server/core/test/test_json.cc +++ b/server/core/test/test_json.cc @@ -20,238 +20,238 @@ using std::string; -const char* test1_json - = "{" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/servers/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"server1\"," - " \"type\": \"servers\"," - " \"relationships\": {" - " \"services\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/services/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"RW-Split-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"SchemaRouter-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"RW-Split-Hint-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"Read-Connection-Router\"," - " \"type\": \"services\"" - " }" - " ]" - " }," - " \"monitors\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/monitors/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"MySQL-Monitor\"," - " \"type\": \"monitors\"" - " }" - " ]" - " }" - " }," - " \"attributes\": {" - " \"parameters\": {" - " \"address\": \"127.0.0.1\"," - " \"port\": 3000," - " \"protocol\": \"MySQLBackend\"" - " }," - " \"status\": \"Master, Running\"," - " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," - " \"node_id\": 3000," - " \"master_id\": -1," - " \"replication_depth\": 0," - " \"slaves\": [" - " 3001," - " 3002," - " 3003" - " ]," - " \"statistics\": {" - " \"connections\": 0," - " \"total_connections\": 0," - " \"active_operations\": 0" - " }" - " }" - " }," - " {" - " \"id\": \"server2\"," - " \"type\": \"servers\"," - " \"relationships\": {" - " \"services\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/services/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"RW-Split-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"SchemaRouter-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"RW-Split-Hint-Router\"," - " \"type\": \"services\"" - " }" - " ]" - " }," - " \"monitors\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/monitors/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"MySQL-Monitor\"," - " \"type\": \"monitors\"" - " }" - " ]" - " }" - " }," - " \"attributes\": {" - " \"parameters\": {" - " \"address\": \"127.0.0.1\"," - " \"port\": 3001," - " \"protocol\": \"MySQLBackend\"" - " }," - " \"status\": \"Slave, Running\"," - " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," - " \"node_id\": 3001," - " \"master_id\": 3000," - " \"replication_depth\": 1," - " \"slaves\": []," - " \"statistics\": {" - " \"connections\": 0," - " \"total_connections\": 0," - " \"active_operations\": 0" - " }" - " }" - " }," - " {" - " \"id\": \"server3\"," - " \"type\": \"servers\"," - " \"relationships\": {" - " \"services\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/services/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"RW-Split-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"SchemaRouter-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"RW-Split-Hint-Router\"," - " \"type\": \"services\"" - " }" - " ]" - " }," - " \"monitors\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/monitors/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"MySQL-Monitor\"," - " \"type\": \"monitors\"" - " }" - " ]" - " }" - " }," - " \"attributes\": {" - " \"parameters\": {" - " \"address\": \"127.0.0.1\"," - " \"port\": 3002," - " \"protocol\": \"MySQLBackend\"" - " }," - " \"status\": \"Slave, Running\"," - " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," - " \"node_id\": 3002," - " \"master_id\": 3000," - " \"replication_depth\": 1," - " \"slaves\": []," - " \"statistics\": {" - " \"connections\": 0," - " \"total_connections\": 0," - " \"active_operations\": 0" - " }" - " }" - " }," - " {" - " \"id\": \"server4\"," - " \"type\": \"servers\"," - " \"relationships\": {" - " \"services\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/services/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"RW-Split-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"SchemaRouter-Router\"," - " \"type\": \"services\"" - " }," - " {" - " \"id\": \"RW-Split-Hint-Router\"," - " \"type\": \"services\"" - " }" - " ]" - " }," - " \"monitors\": {" - " \"links\": {" - " \"self\": \"http://localhost:8989/v1/monitors/\"" - " }," - " \"data\": [" - " {" - " \"id\": \"MySQL-Monitor\"," - " \"type\": \"monitors\"" - " }" - " ]" - " }" - " }," - " \"attributes\": {" - " \"parameters\": {" - " \"address\": \"127.0.0.1\"," - " \"port\": 3003," - " \"protocol\": \"MySQLBackend\"" - " }," - " \"status\": \"Slave, Running\"," - " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," - " \"node_id\": 3003," - " \"master_id\": 3000," - " \"replication_depth\": 1," - " \"slaves\": []," - " \"statistics\": {" - " \"connections\": 0," - " \"total_connections\": 0," - " \"active_operations\": 0" - " }" - " }" - " }" - " ]" - "}"; +const char* test1_json = + "{" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/servers/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"server1\"," + " \"type\": \"servers\"," + " \"relationships\": {" + " \"services\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/services/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"RW-Split-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"SchemaRouter-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"RW-Split-Hint-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"Read-Connection-Router\"," + " \"type\": \"services\"" + " }" + " ]" + " }," + " \"monitors\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/monitors/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"MySQL-Monitor\"," + " \"type\": \"monitors\"" + " }" + " ]" + " }" + " }," + " \"attributes\": {" + " \"parameters\": {" + " \"address\": \"127.0.0.1\"," + " \"port\": 3000," + " \"protocol\": \"MySQLBackend\"" + " }," + " \"status\": \"Master, Running\"," + " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," + " \"node_id\": 3000," + " \"master_id\": -1," + " \"replication_depth\": 0," + " \"slaves\": [" + " 3001," + " 3002," + " 3003" + " ]," + " \"statistics\": {" + " \"connections\": 0," + " \"total_connections\": 0," + " \"active_operations\": 0" + " }" + " }" + " }," + " {" + " \"id\": \"server2\"," + " \"type\": \"servers\"," + " \"relationships\": {" + " \"services\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/services/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"RW-Split-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"SchemaRouter-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"RW-Split-Hint-Router\"," + " \"type\": \"services\"" + " }" + " ]" + " }," + " \"monitors\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/monitors/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"MySQL-Monitor\"," + " \"type\": \"monitors\"" + " }" + " ]" + " }" + " }," + " \"attributes\": {" + " \"parameters\": {" + " \"address\": \"127.0.0.1\"," + " \"port\": 3001," + " \"protocol\": \"MySQLBackend\"" + " }," + " \"status\": \"Slave, Running\"," + " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," + " \"node_id\": 3001," + " \"master_id\": 3000," + " \"replication_depth\": 1," + " \"slaves\": []," + " \"statistics\": {" + " \"connections\": 0," + " \"total_connections\": 0," + " \"active_operations\": 0" + " }" + " }" + " }," + " {" + " \"id\": \"server3\"," + " \"type\": \"servers\"," + " \"relationships\": {" + " \"services\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/services/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"RW-Split-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"SchemaRouter-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"RW-Split-Hint-Router\"," + " \"type\": \"services\"" + " }" + " ]" + " }," + " \"monitors\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/monitors/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"MySQL-Monitor\"," + " \"type\": \"monitors\"" + " }" + " ]" + " }" + " }," + " \"attributes\": {" + " \"parameters\": {" + " \"address\": \"127.0.0.1\"," + " \"port\": 3002," + " \"protocol\": \"MySQLBackend\"" + " }," + " \"status\": \"Slave, Running\"," + " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," + " \"node_id\": 3002," + " \"master_id\": 3000," + " \"replication_depth\": 1," + " \"slaves\": []," + " \"statistics\": {" + " \"connections\": 0," + " \"total_connections\": 0," + " \"active_operations\": 0" + " }" + " }" + " }," + " {" + " \"id\": \"server4\"," + " \"type\": \"servers\"," + " \"relationships\": {" + " \"services\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/services/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"RW-Split-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"SchemaRouter-Router\"," + " \"type\": \"services\"" + " }," + " {" + " \"id\": \"RW-Split-Hint-Router\"," + " \"type\": \"services\"" + " }" + " ]" + " }," + " \"monitors\": {" + " \"links\": {" + " \"self\": \"http://localhost:8989/v1/monitors/\"" + " }," + " \"data\": [" + " {" + " \"id\": \"MySQL-Monitor\"," + " \"type\": \"monitors\"" + " }" + " ]" + " }" + " }," + " \"attributes\": {" + " \"parameters\": {" + " \"address\": \"127.0.0.1\"," + " \"port\": 3003," + " \"protocol\": \"MySQLBackend\"" + " }," + " \"status\": \"Slave, Running\"," + " \"version_string\": \"10.1.19-MariaDB-1~jessie\"," + " \"node_id\": 3003," + " \"master_id\": 3000," + " \"replication_depth\": 1," + " \"slaves\": []," + " \"statistics\": {" + " \"connections\": 0," + " \"total_connections\": 0," + " \"active_operations\": 0" + " }" + " }" + " }" + " ]" + "}"; int test1() { diff --git a/server/core/test/test_local_address.cc b/server/core/test/test_local_address.cc index 31d92654f..a0e3b5bcc 100644 --- a/server/core/test/test_local_address.cc +++ b/server/core/test/test_local_address.cc @@ -19,54 +19,54 @@ using namespace std; -char USAGE[] - = "usage: test_local_address -u user [-p password] [-a address] [-h host] [-s success]\n" - "\n" - "user : The user to connect as.\n" - "password: The password of the user, default none.\n" - "address : The address to connect from, default none specified.\n" - "host : The address of the host to connect to, default 127.0.0.1.\n" - "success : (0|1), whether the connection attempt is expected to succeed or not, defaul 1.\n" - "\n" - "Example:\n" - "\n" - "MariaDB [(none)]> create user 'l1'@'192.168.1.254';\n" - "MariaDB [(none)]> create user 'l2'@'127.0.0.1';\n" - "\n" - "$ ./test_local_address -s 1 -u l1 -a 192.168.1.254\n" - "User : l1\n" - "Password: (none)\n" - "Server : 127.0.0.1\n" - "Address : 192.168.1.254\n" - "Success : 1\n" - "\n" - "Could connect, as expected.\n" - "$ ./test_local_address -s 0 -u l1 -a 127.0.0.1\n" - "User : l1\n" - "Password: (none)\n" - "Server : 127.0.0.1\n" - "Address : 127.0.0.1\n" - "Success : 0\n" - "\n" - "Could not connect, as expected. " - "Reported error: Access denied for user 'l1'@'localhost' (using password: NO)\n" - "$ ./test_local_address -s 1 -u l2 -a 127.0.0.1\n" - "User : l2\n" - "Password: (none)\n" - "Server : 127.0.0.1\n" - "Address : 127.0.0.1\n" - "Success : 1\n" - "\n" - "Could connect, as expected.\n" - "$ ./test_local_address -s 0 -u l2 -a 192.168.1.254\n" - "User : l2\n" - "Password: (none)\n" - "Server : 127.0.0.1\n" - "Address : 192.168.1.254\n" - "Success : 0\n" - "\n" - "Could not connect, as expected. " - "Reported error: Access denied for user 'l2'@'192.168.1.254' (using password: NO)\n"; +char USAGE[] = + "usage: test_local_address -u user [-p password] [-a address] [-h host] [-s success]\n" + "\n" + "user : The user to connect as.\n" + "password: The password of the user, default none.\n" + "address : The address to connect from, default none specified.\n" + "host : The address of the host to connect to, default 127.0.0.1.\n" + "success : (0|1), whether the connection attempt is expected to succeed or not, defaul 1.\n" + "\n" + "Example:\n" + "\n" + "MariaDB [(none)]> create user 'l1'@'192.168.1.254';\n" + "MariaDB [(none)]> create user 'l2'@'127.0.0.1';\n" + "\n" + "$ ./test_local_address -s 1 -u l1 -a 192.168.1.254\n" + "User : l1\n" + "Password: (none)\n" + "Server : 127.0.0.1\n" + "Address : 192.168.1.254\n" + "Success : 1\n" + "\n" + "Could connect, as expected.\n" + "$ ./test_local_address -s 0 -u l1 -a 127.0.0.1\n" + "User : l1\n" + "Password: (none)\n" + "Server : 127.0.0.1\n" + "Address : 127.0.0.1\n" + "Success : 0\n" + "\n" + "Could not connect, as expected. " + "Reported error: Access denied for user 'l1'@'localhost' (using password: NO)\n" + "$ ./test_local_address -s 1 -u l2 -a 127.0.0.1\n" + "User : l2\n" + "Password: (none)\n" + "Server : 127.0.0.1\n" + "Address : 127.0.0.1\n" + "Success : 1\n" + "\n" + "Could connect, as expected.\n" + "$ ./test_local_address -s 0 -u l2 -a 192.168.1.254\n" + "User : l2\n" + "Password: (none)\n" + "Server : 127.0.0.1\n" + "Address : 192.168.1.254\n" + "Success : 0\n" + "\n" + "Could not connect, as expected. " + "Reported error: Access denied for user 'l2'@'192.168.1.254' (using password: NO)\n"; namespace { diff --git a/server/core/test/test_trxcompare.cc b/server/core/test/test_trxcompare.cc index 01ff0415b..79c9c1949 100644 --- a/server/core/test/test_trxcompare.cc +++ b/server/core/test/test_trxcompare.cc @@ -27,15 +27,15 @@ using namespace std; namespace { -char USAGE[] - = "test_trxcompare [-v] (-s stmt)|[file]" - "\n" - "-s test single statement\n" - "-v 0, only return code\n" - " 1, failed cases (default)\n" - " 2, successful transactional cases\n" - " 4, successful cases\n" - " 7, all cases\n"; +char USAGE[] = + "test_trxcompare [-v] (-s stmt)|[file]" + "\n" + "-s test single statement\n" + "-v 0, only return code\n" + " 1, failed cases (default)\n" + " 2, successful transactional cases\n" + " 4, successful cases\n" + " 7, all cases\n"; enum verbosity_t { diff --git a/server/core/test/test_trxtracking.cc b/server/core/test/test_trxtracking.cc index 337d54fec..8632e1170 100644 --- a/server/core/test/test_trxtracking.cc +++ b/server/core/test/test_trxtracking.cc @@ -391,15 +391,15 @@ bool test(uint32_t (* getter)(GWBUF*), bool dont_bail_out) namespace { -char USAGE[] - = "usage: test_trxtracking [-p] [-q] [-r] [-d]\n" - "\n" - "-p : Test using custom parser\n" - "-q : Test using query classifier\n" - "-r : Test using regex matching\n" - "-d : Don't bail out at first error\n" - "\n" - "If neither -p, -q or -r has been specified, then all will be tested.\n"; +char USAGE[] = + "usage: test_trxtracking [-p] [-q] [-r] [-d]\n" + "\n" + "-p : Test using custom parser\n" + "-q : Test using query classifier\n" + "-r : Test using regex matching\n" + "-d : Don't bail out at first error\n" + "\n" + "If neither -p, -q or -r has been specified, then all will be tested.\n"; } int main(int argc, char* argv[]) diff --git a/server/core/utils.cc b/server/core/utils.cc index 31d77c336..f541cf761 100644 --- a/server/core/utils.cc +++ b/server/core/utils.cc @@ -1281,8 +1281,8 @@ size_t write_callback(char* ptr, size_t size, size_t nmemb, void* userdata) size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata) { - std::unordered_map* map - = static_cast*>(userdata); + std::unordered_map* map = + static_cast*>(userdata); if (nmemb > 0) { diff --git a/server/modules/authenticator/CDCPlainAuth/cdc_plain_auth.cc b/server/modules/authenticator/CDCPlainAuth/cdc_plain_auth.cc index f4323796a..47a641e36 100644 --- a/server/modules/authenticator/CDCPlainAuth/cdc_plain_auth.cc +++ b/server/modules/authenticator/CDCPlainAuth/cdc_plain_auth.cc @@ -259,8 +259,8 @@ static int cdc_auth_authenticate(DCB* dcb) MXS_DEBUG("Receiving connection from '%s'", client_data->user); - auth_ret - = cdc_auth_check(dcb, protocol, client_data->user, client_data->auth_data, client_data->flags); + auth_ret = + cdc_auth_check(dcb, protocol, client_data->user, client_data->auth_data, client_data->flags); /* On failed authentication try to reload users and authenticate again */ if (CDC_STATE_AUTH_OK != auth_ret && cdc_replace_users(dcb->listener) == MXS_AUTH_LOADUSERS_OK) diff --git a/server/modules/authenticator/GSSAPI/GSSAPIAuth/gssapi_auth.cc b/server/modules/authenticator/GSSAPI/GSSAPIAuth/gssapi_auth.cc index 831d7e2c6..cabdf616a 100644 --- a/server/modules/authenticator/GSSAPI/GSSAPIAuth/gssapi_auth.cc +++ b/server/modules/authenticator/GSSAPI/GSSAPIAuth/gssapi_auth.cc @@ -33,15 +33,15 @@ */ /** Query that gets all users that authenticate via the gssapi plugin */ -const char* gssapi_users_query - = "SELECT u.user, u.host, d.db, u.select_priv, u.authentication_string FROM " - "mysql.user AS u LEFT JOIN mysql.db AS d " - "ON (u.user = d.user AND u.host = d.host) WHERE u.plugin = 'gssapi' " - "UNION " - "SELECT u.user, u.host, t.db, u.select_priv, u.authentication_string FROM " - "mysql.user AS u LEFT JOIN mysql.tables_priv AS t " - "ON (u.user = t.user AND u.host = t.host) WHERE u.plugin = 'gssapi' " - "ORDER BY user"; +const char* gssapi_users_query = + "SELECT u.user, u.host, d.db, u.select_priv, u.authentication_string FROM " + "mysql.user AS u LEFT JOIN mysql.db AS d " + "ON (u.user = d.user AND u.host = d.host) WHERE u.plugin = 'gssapi' " + "UNION " + "SELECT u.user, u.host, t.db, u.select_priv, u.authentication_string FROM " + "mysql.user AS u LEFT JOIN mysql.tables_priv AS t " + "ON (u.user = t.user AND u.host = t.host) WHERE u.plugin = 'gssapi' " + "ORDER BY user"; #define GSSAPI_USERS_QUERY_NUM_FIELDS 5 @@ -56,15 +56,15 @@ const char* gssapi_users_query #define GSSAPI_TABLE_NAME "gssapi_users" /** CREATE TABLE statement for the in-memory table */ -const char create_sql[] - = "CREATE TABLE IF NOT EXISTS " GSSAPI_TABLE_NAME - "(user varchar(255), host varchar(255), db varchar(255), anydb boolean, princ text)"; +const char create_sql[] = + "CREATE TABLE IF NOT EXISTS " GSSAPI_TABLE_NAME + "(user varchar(255), host varchar(255), db varchar(255), anydb boolean, princ text)"; /** The query that is executed when a user is authenticated */ -static const char gssapi_auth_query[] - = "SELECT * FROM " GSSAPI_TABLE_NAME - " WHERE user = '%s' AND '%s' LIKE host AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" - " AND ('%s' = '%s' OR princ = '%s') LIMIT 1"; +static const char gssapi_auth_query[] = + "SELECT * FROM " GSSAPI_TABLE_NAME + " WHERE user = '%s' AND '%s' LIKE host AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" + " AND ('%s' = '%s' OR princ = '%s') LIMIT 1"; /** Delete query used to clean up the database before loading new users */ static const char delete_query[] = "DELETE FROM " GSSAPI_TABLE_NAME; @@ -75,8 +75,8 @@ static const char delete_query[] = "DELETE FROM " GSSAPI_TABLE_NAME; * Note that the last two values are strings that can be NULL and thus they have * no quoted around them. The quotes for strings are added in add_gssapi_user(). */ -static const char insert_sql_pattern[] - = "INSERT INTO " GSSAPI_TABLE_NAME " VALUES ('%s', '%s', %s, %s, %s)"; +static const char insert_sql_pattern[] = + "INSERT INTO " GSSAPI_TABLE_NAME " VALUES ('%s', '%s', %s, %s, %s)"; /** Used for NULL value creation in the INSERT query */ static const char null_token[] = "NULL"; diff --git a/server/modules/authenticator/GSSAPI/GSSAPIBackendAuth/gssapi_backend_auth.cc b/server/modules/authenticator/GSSAPI/GSSAPIBackendAuth/gssapi_backend_auth.cc index c78f10468..122b703b2 100644 --- a/server/modules/authenticator/GSSAPI/GSSAPIBackendAuth/gssapi_backend_auth.cc +++ b/server/modules/authenticator/GSSAPI/GSSAPIBackendAuth/gssapi_backend_auth.cc @@ -160,9 +160,9 @@ bool extract_principal_name(DCB* dcb, GWBUF* buffer) * means that the server is not secure. */ MXS_ERROR("Server '%s' returned an unexpected authentication response.%s", dcb->server->name, - databuf[0] == MYSQL_REPLY_OK - ? " Authentication was complete before it even started, " - "anonymous users might not be disabled." : ""); + databuf[0] == MYSQL_REPLY_OK ? + " Authentication was complete before it even started, " + "anonymous users might not be disabled." : ""); return false; } diff --git a/server/modules/authenticator/MySQLAuth/dbusers.cc b/server/modules/authenticator/MySQLAuth/dbusers.cc index 19f5982c2..d2fd2a30a 100644 --- a/server/modules/authenticator/MySQLAuth/dbusers.cc +++ b/server/modules/authenticator/MySQLAuth/dbusers.cc @@ -157,14 +157,14 @@ static char* get_users_query(const char* server_version, int version, bool inclu { if (is_mariadb) // 10.1.1 or newer, supports default roles { - return version >= 100202 - ? get_mariadb_102_users_query(include_root) - : get_mariadb_users_query(include_root); + return version >= 100202 ? + get_mariadb_102_users_query(include_root) : + get_mariadb_users_query(include_root); } // Either an older MariaDB version or a MySQL variant, use the legacy query - const char* password = strstr(server_version, "5.7.") || strstr(server_version, "8.0.") - ? MYSQL57_PASSWORD : MYSQL_PASSWORD; + const char* password = strstr(server_version, "5.7.") || strstr(server_version, "8.0.") ? + MYSQL57_PASSWORD : MYSQL_PASSWORD; const char* with_root = include_root ? "" : " AND u.user NOT IN ('root')"; size_t n_bytes = snprintf(NULL, 0, NEW_LOAD_DBUSERS_QUERY, password, with_root, password, with_root); @@ -297,9 +297,9 @@ int validate_mysql_user(MYSQL_AUTH* instance, size_t scramble_len) { sqlite3* handle = get_handle(instance); - const char* validate_query = instance->lower_case_table_names - ? mysqlauth_validate_user_query_lower - : mysqlauth_validate_user_query; + const char* validate_query = instance->lower_case_table_names ? + mysqlauth_validate_user_query_lower : + mysqlauth_validate_user_query; size_t len = strlen(validate_query) + 1 + strlen(session->user) * 2 + strlen(session->db) * 2 + MYSQL_HOST_MAXLEN + session->auth_token_len * 4 + 1; char sql[len + 1]; @@ -686,8 +686,8 @@ static bool check_server_permissions(SERVICE* service, } const char* format = "SELECT user, host, %s, Select_priv FROM mysql.user limit 1"; - const char* query_pw = strstr(server->version_string, "5.7.") - ? MYSQL57_PASSWORD : MYSQL_PASSWORD; + const char* query_pw = strstr(server->version_string, "5.7.") ? + MYSQL57_PASSWORD : MYSQL_PASSWORD; char query[strlen(format) + strlen(query_pw) + 1]; bool rval = true; sprintf(query, format, query_pw); diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.h b/server/modules/authenticator/MySQLAuth/mysql_auth.h index c442d6df6..0588b26d6 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.h +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.h @@ -49,38 +49,38 @@ static const char DBUSERS_FILE[] = "dbusers.db"; #define MYSQLAUTH_DATABASES_TABLE_NAME "mysqlauth_databases" /** CREATE TABLE statement for the in-memory users table */ -static const char users_create_sql[] - = "CREATE TABLE IF NOT EXISTS " MYSQLAUTH_USERS_TABLE_NAME - "(user varchar(255), host varchar(255), db varchar(255), anydb boolean, password text)"; +static const char users_create_sql[] = + "CREATE TABLE IF NOT EXISTS " MYSQLAUTH_USERS_TABLE_NAME + "(user varchar(255), host varchar(255), db varchar(255), anydb boolean, password text)"; /** CREATE TABLE statement for the in-memory databases table */ -static const char databases_create_sql[] - = "CREATE TABLE IF NOT EXISTS " MYSQLAUTH_DATABASES_TABLE_NAME "(db varchar(255))"; +static const char databases_create_sql[] = + "CREATE TABLE IF NOT EXISTS " MYSQLAUTH_DATABASES_TABLE_NAME "(db varchar(255))"; /** PRAGMA configuration options for SQLite */ static const char pragma_sql[] = "PRAGMA JOURNAL_MODE=NONE"; /** Query that checks if there's a grant for the user being authenticated */ -static const char mysqlauth_validate_user_query[] - = "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME - " WHERE user = '%s' AND ( '%s' = host OR '%s' LIKE host) AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" - " LIMIT 1"; +static const char mysqlauth_validate_user_query[] = + "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME + " WHERE user = '%s' AND ( '%s' = host OR '%s' LIKE host) AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" + " LIMIT 1"; /** Query that checks if there's a grant for the user being authenticated */ -static const char mysqlauth_validate_user_query_lower[] - = "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME - " WHERE user = '%s' AND ( '%s' = host OR '%s' LIKE host) AND (anydb = '1' OR '%s' = '' OR LOWER('%s') LIKE LOWER(db))" - " LIMIT 1"; +static const char mysqlauth_validate_user_query_lower[] = + "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME + " WHERE user = '%s' AND ( '%s' = host OR '%s' LIKE host) AND (anydb = '1' OR '%s' = '' OR LOWER('%s') LIKE LOWER(db))" + " LIMIT 1"; /** Query that only checks if there's a matching user */ -static const char mysqlauth_skip_auth_query[] - = "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME - " WHERE user = '%s' AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" - " LIMIT 1"; +static const char mysqlauth_skip_auth_query[] = + "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME + " WHERE user = '%s' AND (anydb = '1' OR '%s' = '' OR '%s' LIKE db)" + " LIMIT 1"; /** Query that checks that the database exists */ -static const char mysqlauth_validate_database_query[] - = "SELECT * FROM " MYSQLAUTH_DATABASES_TABLE_NAME " WHERE db = '%s' LIMIT 1"; +static const char mysqlauth_validate_database_query[] = + "SELECT * FROM " MYSQLAUTH_DATABASES_TABLE_NAME " WHERE db = '%s' LIMIT 1"; /** Delete query used to clean up the database before loading new users */ static const char delete_users_query[] = "DELETE FROM " MYSQLAUTH_USERS_TABLE_NAME; @@ -89,18 +89,18 @@ static const char delete_users_query[] = "DELETE FROM " MYSQLAUTH_USERS_TABLE_NA static const char delete_databases_query[] = "DELETE FROM " MYSQLAUTH_DATABASES_TABLE_NAME; /** The insert query template which adds users to the mysqlauth_users table */ -static const char insert_user_query[] - = "INSERT OR REPLACE INTO " MYSQLAUTH_USERS_TABLE_NAME " VALUES ('%s', '%s', %s, %s, %s)"; +static const char insert_user_query[] = + "INSERT OR REPLACE INTO " MYSQLAUTH_USERS_TABLE_NAME " VALUES ('%s', '%s', %s, %s, %s)"; /** The insert query template which adds the databases to the table */ -static const char insert_database_query[] - = "INSERT OR REPLACE INTO " MYSQLAUTH_DATABASES_TABLE_NAME " VALUES ('%s')"; +static const char insert_database_query[] = + "INSERT OR REPLACE INTO " MYSQLAUTH_DATABASES_TABLE_NAME " VALUES ('%s')"; -static const char dump_users_query[] - = "SELECT user, host, db, anydb, password FROM " MYSQLAUTH_USERS_TABLE_NAME; +static const char dump_users_query[] = + "SELECT user, host, db, anydb, password FROM " MYSQLAUTH_USERS_TABLE_NAME; -static const char dump_databases_query[] - = "SELECT db FROM " MYSQLAUTH_DATABASES_TABLE_NAME; +static const char dump_databases_query[] = + "SELECT db FROM " MYSQLAUTH_DATABASES_TABLE_NAME; /** Used for NULL value creation in the INSERT query */ static const char null_token[] = "NULL"; diff --git a/server/modules/authenticator/PAM/PAMAuth/pam_instance.cc b/server/modules/authenticator/PAM/PAMAuth/pam_instance.cc index 05fbe656f..85f58f97f 100644 --- a/server/modules/authenticator/PAM/PAMAuth/pam_instance.cc +++ b/server/modules/authenticator/PAM/PAMAuth/pam_instance.cc @@ -109,8 +109,8 @@ void PamInstance::add_pam_user(const char* user, * Note that 'db' and 'pam_service' are strings that can be NULL and thus they have * no quotes around them. The quotes for strings are added in this function. */ - const string insert_sql_template - = "INSERT INTO " + m_tablename + " VALUES ('%s', '%s', %s, '%s', %s)"; + const string insert_sql_template = + "INSERT INTO " + m_tablename + " VALUES ('%s', '%s', %s, '%s', %s)"; /** Used for NULL value creation in the INSERT query */ const char NULL_TOKEN[] = "NULL"; @@ -180,15 +180,15 @@ void PamInstance::delete_old_users() int PamInstance::load_users(SERVICE* service) { /** Query that gets all users that authenticate via the pam plugin */ - const char PAM_USERS_QUERY[] - = "SELECT u.user, u.host, d.db, u.select_priv, u.authentication_string FROM " - "mysql.user AS u LEFT JOIN mysql.db AS d ON (u.user = d.user AND u.host = d.host) WHERE " - "(u.plugin = 'pam' AND (d.db IS NOT NULL OR u.select_priv = 'Y')) " - "UNION " - "SELECT u.user, u.host, t.db, u.select_priv, u.authentication_string FROM " - "mysql.user AS u LEFT JOIN mysql.tables_priv AS t ON (u.user = t.user AND u.host = t.host) WHERE " - "(u.plugin = 'pam' AND t.db IS NOT NULL AND u.select_priv = 'N') " - "ORDER BY user"; + const char PAM_USERS_QUERY[] = + "SELECT u.user, u.host, d.db, u.select_priv, u.authentication_string FROM " + "mysql.user AS u LEFT JOIN mysql.db AS d ON (u.user = d.user AND u.host = d.host) WHERE " + "(u.plugin = 'pam' AND (d.db IS NOT NULL OR u.select_priv = 'Y')) " + "UNION " + "SELECT u.user, u.host, t.db, u.select_priv, u.authentication_string FROM " + "mysql.user AS u LEFT JOIN mysql.tables_priv AS t ON (u.user = t.user AND u.host = t.host) WHERE " + "(u.plugin = 'pam' AND t.db IS NOT NULL AND u.select_priv = 'N') " + "ORDER BY user"; #if defined (SS_DEBUG) const unsigned int PAM_USERS_QUERY_NUM_FIELDS = 5; #endif diff --git a/server/modules/authenticator/PAM/PAMBackendAuth/pam_backend_session.cc b/server/modules/authenticator/PAM/PAMBackendAuth/pam_backend_session.cc index 302b26267..5cef02baa 100644 --- a/server/modules/authenticator/PAM/PAMBackendAuth/pam_backend_session.cc +++ b/server/modules/authenticator/PAM/PAMBackendAuth/pam_backend_session.cc @@ -49,9 +49,9 @@ bool check_auth_switch_request(DCB* dcb, GWBUF* buffer) && data[MYSQL_HEADER_LEN + 1] == MYSQL_REPLY_OK; MXS_ERROR("Server '%s' returned an unexpected authentication response.%s", dcb->server->name, - was_ok_packet - ? " Authentication was complete before it even started, " - "anonymous users might not be disabled." : ""); + was_ok_packet ? + " Authentication was complete before it even started, " + "anonymous users might not be disabled." : ""); return false; } unsigned int buflen = gwbuf_length(buffer); diff --git a/server/modules/filter/binlogfilter/binlogfiltersession.cc b/server/modules/filter/binlogfilter/binlogfiltersession.cc index 2f9f55bd9..88af9fea8 100644 --- a/server/modules/filter/binlogfilter/binlogfiltersession.cc +++ b/server/modules/filter/binlogfilter/binlogfiltersession.cc @@ -372,8 +372,8 @@ bool BinlogFilterSession::checkEvent(GWBUF* buffer, fixEvent(event + MYSQL_HEADER_LEN + 1, hdr.event_size); MXS_INFO("Skipped events: Setting next_pos = 0 in %s", - event[4] == XID_EVENT - ? "XID_EVENT" : "COMMIT"); + event[4] == XID_EVENT ? + "XID_EVENT" : "COMMIT"); } break; diff --git a/server/modules/filter/cache/cachefiltersession.cc b/server/modules/filter/cache/cachefiltersession.cc index 4cb4969f0..8e2cbad1e 100644 --- a/server/modules/filter/cache/cachefiltersession.cc +++ b/server/modules/filter/cache/cachefiltersession.cc @@ -869,9 +869,9 @@ CacheFilterSession::cache_action_t CacheFilterSession::get_cache_action(GWBUF* p if (log_decisions()) { - zPrimary_reason - = "populating but not using cache inside transaction that is not " - "explicitly read-only, but that has used only SELECTs sofar"; + zPrimary_reason = + "populating but not using cache inside transaction that is not " + "explicitly read-only, but that has used only SELECTs sofar"; } action = CACHE_POPULATE; } diff --git a/server/modules/filter/cache/rules.cc b/server/modules/filter/cache/rules.cc index c0348f48e..fcd0af1e3 100644 --- a/server/modules/filter/cache/rules.cc +++ b/server/modules/filter/cache/rules.cc @@ -1394,8 +1394,8 @@ static bool cache_rule_matches_column_simple(CACHE_RULE* self, const char* defau { if (rule_database) { - const char* check_database - = info->database ? info->database : default_database; + const char* check_database = + info->database ? info->database : default_database; if (check_database) { @@ -1741,9 +1741,9 @@ static bool cache_rule_matches_table_simple(CACHE_RULE* self, const char* defaul if (database) { - matches - = (strcasecmp(self->simple.database, database) == 0) - && (strcasecmp(self->simple.table, table) == 0); + matches = + (strcasecmp(self->simple.database, database) == 0) + && (strcasecmp(self->simple.table, table) == 0); } } else diff --git a/server/modules/filter/cache/test/test_cacheoptions.cc b/server/modules/filter/cache/test/test_cacheoptions.cc index 8467c6c15..7668c0e45 100644 --- a/server/modules/filter/cache/test/test_cacheoptions.cc +++ b/server/modules/filter/cache/test/test_cacheoptions.cc @@ -393,10 +393,10 @@ int run() namespace { -char USAGE[] - = "usage: test_dbfwfilter [-d]\n" - "\n" - "-d don't stop at first error\n"; +char USAGE[] = + "usage: test_dbfwfilter [-d]\n" + "\n" + "-d don't stop at first error\n"; } int main(int argc, char* argv[]) diff --git a/server/modules/filter/cache/test/testrules.cc b/server/modules/filter/cache/test/testrules.cc index b83cbefb9..3b83aca11 100644 --- a/server/modules/filter/cache/test/testrules.cc +++ b/server/modules/filter/cache/test/testrules.cc @@ -420,36 +420,36 @@ int test_store() } -static const char ARRAY_RULES[] - = "[" - " {" - " \"store\": [" - " {" - " \"attribute\": \"column\"," - " \"op\": \"=\"," - " \"value\": \"a\"" - " }" - " ]" - " }," - " {" - " \"store\": [" - " {" - " \"attribute\": \"column\"," - " \"op\": \"=\"," - " \"value\": \"b\"" - " }" - " ]" - " }," - " {" - " \"store\": [" - " {" - " \"attribute\": \"column\"," - " \"op\": \"=\"," - " \"value\": \"c\"" - " }" - " ]" - " }" - "]"; +static const char ARRAY_RULES[] = + "[" + " {" + " \"store\": [" + " {" + " \"attribute\": \"column\"," + " \"op\": \"=\"," + " \"value\": \"a\"" + " }" + " ]" + " }," + " {" + " \"store\": [" + " {" + " \"attribute\": \"column\"," + " \"op\": \"=\"," + " \"value\": \"b\"" + " }" + " ]" + " }," + " {" + " \"store\": [" + " {" + " \"attribute\": \"column\"," + " \"op\": \"=\"," + " \"value\": \"c\"" + " }" + " ]" + " }" + "]"; struct ARRAY_TEST_CASE { diff --git a/server/modules/filter/ccrfilter/ccrfilter.cc b/server/modules/filter/ccrfilter/ccrfilter.cc index af1bb146a..afb6d98b9 100644 --- a/server/modules/filter/ccrfilter/ccrfilter.cc +++ b/server/modules/filter/ccrfilter/ccrfilter.cc @@ -356,13 +356,13 @@ static int routeQuery(MXS_FILTER* instance, MXS_FILTER_SESSION* session, GWBUF* } if (!decided) { - trigger_ccr - = mxs_pcre2_check_match_exclude(my_instance->re, - my_instance->nore, - my_session->md, - sql, - length, - MXS_MODULE_NAME); + trigger_ccr = + mxs_pcre2_check_match_exclude(my_instance->re, + my_instance->nore, + my_session->md, + sql, + length, + MXS_MODULE_NAME); } if (trigger_ccr) { diff --git a/server/modules/filter/dbfwfilter/dbfwfilter.cc b/server/modules/filter/dbfwfilter/dbfwfilter.cc index 49ed9f74c..be9748a60 100644 --- a/server/modules/filter/dbfwfilter/dbfwfilter.cc +++ b/server/modules/filter/dbfwfilter/dbfwfilter.cc @@ -854,8 +854,8 @@ bool create_user_templates(void* scanner) for (ValueList::const_iterator it = rstack->user.begin(); it != rstack->user.end(); it++) { - SUserTemplate newtemp - = SUserTemplate(new UserTemplate(*it, rstack->active_rules, rstack->active_mode)); + SUserTemplate newtemp = + SUserTemplate(new UserTemplate(*it, rstack->active_rules, rstack->active_mode)); rstack->templates.push_back(newtemp); } @@ -1668,9 +1668,9 @@ static char* create_parse_error(Dbfw* my_instance, { char* msg = NULL; - char format[] - = "Query could not be %s and will hence be rejected. " - "Please ensure that the SQL syntax is correct"; + char format[] = + "Query could not be %s and will hence be rejected. " + "Please ensure that the SQL syntax is correct"; size_t len = sizeof(format) + strlen(reason); // sizeof includes the trailing NULL as well. char message[len]; sprintf(message, format, reason); diff --git a/server/modules/filter/dbfwfilter/test/test_dbfwfilter.cc b/server/modules/filter/dbfwfilter/test/test_dbfwfilter.cc index 7ac9fed67..318622b89 100644 --- a/server/modules/filter/dbfwfilter/test/test_dbfwfilter.cc +++ b/server/modules/filter/dbfwfilter/test/test_dbfwfilter.cc @@ -965,10 +965,10 @@ int run() namespace { -char USAGE[] - = "usage: test_dbfwfilter [-d]\n" - "\n" - "-d don't stop at first error\n"; +char USAGE[] = + "usage: test_dbfwfilter [-d]\n" + "\n" + "-d don't stop at first error\n"; } int main(int argc, char* argv[]) diff --git a/server/modules/filter/insertstream/insertstream.cc b/server/modules/filter/insertstream/insertstream.cc index f0f4d6a09..2f30e8cd9 100644 --- a/server/modules/filter/insertstream/insertstream.cc +++ b/server/modules/filter/insertstream/insertstream.cc @@ -475,8 +475,8 @@ static int32_t clientReply(MXS_FILTER* instance, MXS_FILTER_SESSION* session, GW gwbuf_free(reply); mxb_assert(my_session->queue); - my_session->state = my_session->state == DS_CLOSING_STREAM - ? DS_STREAM_CLOSED : DS_REQUEST_ACCEPTED; + my_session->state = my_session->state == DS_CLOSING_STREAM ? + DS_STREAM_CLOSED : DS_REQUEST_ACCEPTED; GWBUF* queue = my_session->queue; my_session->queue = NULL; diff --git a/server/modules/filter/masking/maskingrules.cc b/server/modules/filter/masking/maskingrules.cc index 917efca7a..47029074b 100644 --- a/server/modules/filter/masking/maskingrules.cc +++ b/server/modules/filter/masking/maskingrules.cc @@ -374,9 +374,9 @@ bool create_rules_from_array(json_t* pRules, vectorconfig.max_resultset_size = config_get_size(params, "max_resultset_size"); - cinstance->config.m_return - = static_cast(config_get_enum(params, - "max_resultset_return", - return_option_values)); + cinstance->config.m_return = + static_cast(config_get_enum(params, + "max_resultset_return", + return_option_values)); cinstance->config.debug = config_get_integer(params, "debug"); } @@ -1207,8 +1207,8 @@ static int send_error_upstream(MAXROWS_SESSION_DATA* csdata) * The input SQL statement added in the error message * has a limit of MAXROWS_INPUT_SQL_MAX_LEN bytes */ - sql_len = (sql_len > MAXROWS_INPUT_SQL_MAX_LEN) - ? MAXROWS_INPUT_SQL_MAX_LEN : sql_len; + sql_len = (sql_len > MAXROWS_INPUT_SQL_MAX_LEN) ? + MAXROWS_INPUT_SQL_MAX_LEN : sql_len; uint8_t sql[sql_len]; mxb_assert(csdata->res.data != NULL); diff --git a/server/modules/filter/mqfilter/mqfilter.cc b/server/modules/filter/mqfilter/mqfilter.cc index e4575f094..92b1121be 100644 --- a/server/modules/filter/mqfilter/mqfilter.cc +++ b/server/modules/filter/mqfilter/mqfilter.cc @@ -585,8 +585,8 @@ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params my_instance->rconn_intv = 1; my_instance->port = config_get_integer(params, "port"); - my_instance->trgtype - = static_cast(config_get_enum(params, "logging_trigger", trigger_values)); + my_instance->trgtype = + static_cast(config_get_enum(params, "logging_trigger", trigger_values)); my_instance->log_all = config_get_bool(params, "logging_log_all"); my_instance->strict_logging = config_get_bool(params, "logging_strict"); my_instance->hostname = MXS_STRDUP_A(config_get_string(params, "hostname")); diff --git a/server/modules/filter/namedserverfilter/namedserverfilter.cc b/server/modules/filter/namedserverfilter/namedserverfilter.cc index 9adcc4cb8..c781730d9 100644 --- a/server/modules/filter/namedserverfilter/namedserverfilter.cc +++ b/server/modules/filter/namedserverfilter/namedserverfilter.cc @@ -122,16 +122,16 @@ int RegexHintFSession::routeQuery(GWBUF* queue) { if (modutil_extract_SQL(queue, &sql, &sql_len)) { - const RegexToServers* reg_serv - = m_fil_inst.find_servers(sql, sql_len, m_match_data); + const RegexToServers* reg_serv = + m_fil_inst.find_servers(sql, sql_len, m_match_data); if (reg_serv) { /* Add the servers in the list to the buffer routing hints */ for (const auto& target : reg_serv->m_targets) { - queue->hint - = hint_create_route(queue->hint, reg_serv->m_htype, target.c_str()); + queue->hint = + hint_create_route(queue->hint, reg_serv->m_htype, target.c_str()); } m_n_diverted++; m_fil_inst.m_total_diverted++; @@ -315,12 +315,12 @@ RegexHintFilter* RegexHintFilter::create(const char* name, MXS_CONFIG_PARAMETER* { RegexHintFilter* instance = NULL; std::string user(config_get_string(params, "user")); - MXS_EXCEPTION_GUARD(instance - = new RegexHintFilter(user, - source_addresses, - source_hostnames, - mapping, - max_capcount + 1)); + MXS_EXCEPTION_GUARD(instance = + new RegexHintFilter(user, + source_addresses, + source_hostnames, + mapping, + max_capcount + 1)); return instance; } } @@ -570,13 +570,13 @@ bool RegexHintFilter::regex_compile_and_add(int pcre_ops, bool success = true; int errorcode = -1; PCRE2_SIZE error_offset = -1; - pcre2_code* regex - = pcre2_compile((PCRE2_SPTR) match.c_str(), - match.length(), - pcre_ops, - &errorcode, - &error_offset, - NULL); + pcre2_code* regex = + pcre2_compile((PCRE2_SPTR) match.c_str(), + match.length(), + pcre_ops, + &errorcode, + &error_offset, + NULL); if (regex) { diff --git a/server/modules/filter/regexfilter/regexfilter.cc b/server/modules/filter/regexfilter/regexfilter.cc index 8cae6ae1b..0ed0bcf88 100644 --- a/server/modules/filter/regexfilter/regexfilter.cc +++ b/server/modules/filter/regexfilter/regexfilter.cc @@ -260,8 +260,8 @@ static MXS_FILTER* createInstance(const char* name, MXS_CONFIG_PARAMETER* params return NULL; } - if ((my_instance->match_data - = pcre2_match_data_create_from_pattern(my_instance->re, NULL)) == NULL) + if ((my_instance->match_data = + pcre2_match_data_create_from_pattern(my_instance->re, NULL)) == NULL) { MXS_ERROR("Failure to create PCRE2 matching data. " "This is most likely caused by a lack of available memory."); diff --git a/server/modules/filter/topfilter/topfilter.cc b/server/modules/filter/topfilter/topfilter.cc index 27bde13c8..79f8fa66f 100644 --- a/server/modules/filter/topfilter/topfilter.cc +++ b/server/modules/filter/topfilter/topfilter.cc @@ -286,8 +286,8 @@ static MXS_FILTER_SESSION* newSession(MXS_FILTER* instance, MXS_SESSION* session if ((my_session = static_cast(MXS_CALLOC(1, sizeof(TOPN_SESSION)))) != NULL) { - if ((my_session->filename - = (char*) MXS_MALLOC(strlen(my_instance->filebase) + 20)) + if ((my_session->filename = + (char*) MXS_MALLOC(strlen(my_instance->filebase) + 20)) == NULL) { MXS_FREE(my_session); diff --git a/server/modules/monitor/galeramon/galeramon.cc b/server/modules/monitor/galeramon/galeramon.cc index 3b5ed0396..3fde36d0d 100644 --- a/server/modules/monitor/galeramon/galeramon.cc +++ b/server/modules/monitor/galeramon/galeramon.cc @@ -137,12 +137,12 @@ void GaleraMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server) server_string = monitored_server->server->version_string; /* Check if the the Galera FSM shows this node is joined to the cluster */ - const char* cluster_member - = "SHOW STATUS WHERE Variable_name IN" - " ('wsrep_cluster_state_uuid'," - " 'wsrep_cluster_size'," - " 'wsrep_local_index'," - " 'wsrep_local_state')"; + const char* cluster_member = + "SHOW STATUS WHERE Variable_name IN" + " ('wsrep_cluster_state_uuid'," + " 'wsrep_cluster_size'," + " 'wsrep_local_index'," + " 'wsrep_local_state')"; if (mxs_mysql_query(monitored_server->con, cluster_member) == 0 && (result = mysql_store_result(monitored_server->con)) != NULL) diff --git a/server/modules/monitor/grmon/grmon.cc b/server/modules/monitor/grmon/grmon.cc index 6feb11cd0..0f5103525 100644 --- a/server/modules/monitor/grmon/grmon.cc +++ b/server/modules/monitor/grmon/grmon.cc @@ -57,9 +57,9 @@ static bool is_master(MXS_MONITORED_SERVER* server) { bool rval = false; MYSQL_RES* result; - const char* master_query - = "SELECT VARIABLE_VALUE, @@server_uuid, @@read_only FROM performance_schema.global_status " - "WHERE VARIABLE_NAME= 'group_replication_primary_member'"; + const char* master_query = + "SELECT VARIABLE_VALUE, @@server_uuid, @@read_only FROM performance_schema.global_status " + "WHERE VARIABLE_NAME= 'group_replication_primary_member'"; if (mysql_query(server->con, master_query) == 0 && (result = mysql_store_result(server->con))) { diff --git a/server/modules/monitor/mariadbmon/cluster_discovery.cc b/server/modules/monitor/mariadbmon/cluster_discovery.cc index 4b25485ad..a83af771b 100644 --- a/server/modules/monitor/mariadbmon/cluster_discovery.cc +++ b/server/modules/monitor/mariadbmon/cluster_discovery.cc @@ -41,21 +41,21 @@ void topology_DFS(MariaDBServer* root, VisitorFunc& visitor) { int next_index = NodeData::INDEX_FIRST; // This lambda is recursive, so its type needs to be defined and it needs to "capture itself". - std::function topology_DFS_visit - = [&topology_DFS_visit, &next_index](MariaDBServer* node, VisitorFunc& visitor) { - mxb_assert(node->m_node.index == NodeData::INDEX_NOT_VISITED); - node->m_node.index = next_index++; - if (visitor(node)) + std::function topology_DFS_visit = + [&topology_DFS_visit, &next_index](MariaDBServer* node, VisitorFunc& visitor) { + mxb_assert(node->m_node.index == NodeData::INDEX_NOT_VISITED); + node->m_node.index = next_index++; + if (visitor(node)) + { + for (MariaDBServer* slave : node->m_node.children) { - for (MariaDBServer* slave : node->m_node.children) + if (slave->m_node.index == NodeData::INDEX_NOT_VISITED) { - if (slave->m_node.index == NodeData::INDEX_NOT_VISITED) - { - topology_DFS_visit(slave, visitor); - } + topology_DFS_visit(slave, visitor); } } - }; + } + }; topology_DFS_visit(root, visitor); } diff --git a/server/modules/monitor/mariadbmon/cluster_manipulation.cc b/server/modules/monitor/mariadbmon/cluster_manipulation.cc index 00c858878..bc28e4443 100644 --- a/server/modules/monitor/mariadbmon/cluster_manipulation.cc +++ b/server/modules/monitor/mariadbmon/cluster_manipulation.cc @@ -1624,11 +1624,11 @@ void MariaDBMonitor::check_cluster_operations_support() if (!supported) { - const char PROBLEMS[] - = "The backend cluster does not support failover/switchover due to the following reason(s):\n" - "%s\n" - "Automatic failover/switchover has been disabled. They should only be enabled " - "after the above issues have been resolved."; + const char PROBLEMS[] = + "The backend cluster does not support failover/switchover due to the following reason(s):\n" + "%s\n" + "Automatic failover/switchover has been disabled. They should only be enabled " + "after the above issues have been resolved."; string p1 = string_printf(PROBLEMS, all_reasons.c_str()); string p2 = string_printf(RE_ENABLE_FMT, "failover", CN_AUTO_FAILOVER, m_monitor->name); string p3 = string_printf(RE_ENABLE_FMT, @@ -1739,8 +1739,8 @@ bool MariaDBMonitor::switchover_prepare(SERVER* promotion_server, const auto op = ClusterOperation::SWITCHOVER; // Check that both servers are ok if specified, or autoselect them. Demotion target must be checked // first since the promotion target depends on it. - mxb_assert(promotion_target_out && demotion_target_out && - !*promotion_target_out && !*demotion_target_out); + mxb_assert(promotion_target_out && demotion_target_out + && !*promotion_target_out && !*demotion_target_out); MariaDBServer* demotion_target = NULL; string demotion_msg; diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index fb3f44371..83af0d392 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -281,11 +281,11 @@ string MariaDBMonitor::diagnostics_to_string() const rval += string_printf("Switchover timeout: %u\n", m_switchover_timeout); rval += string_printf("Automatic rejoin: %s\n", m_auto_rejoin ? "Enabled" : "Disabled"); rval += string_printf("Enforce read-only: %s\n", - m_enforce_read_only_slaves - ? "Enabled" : "Disabled"); + m_enforce_read_only_slaves ? + "Enabled" : "Disabled"); rval += string_printf("Detect stale master: %s\n", - (m_detect_stale_master == 1) - ? "Enabled" : "Disabled"); + (m_detect_stale_master == 1) ? + "Enabled" : "Disabled"); if (m_excluded_servers.size() > 0) { rval += string_printf("Non-promotable servers (failover): "); @@ -323,8 +323,8 @@ json_t* MariaDBMonitor::to_json() const json_object_set_new(rval, "master", m_master == NULL ? json_null() : json_string(m_master->name())); json_object_set_new(rval, "master_gtid_domain_id", - m_master_gtid_domain == GTID_DOMAIN_UNKNOWN ? json_null() - : json_integer(m_master_gtid_domain)); + m_master_gtid_domain == GTID_DOMAIN_UNKNOWN ? json_null() : + json_integer(m_master_gtid_domain)); json_t* server_info = json_array(); for (MariaDBServer* server : m_servers) @@ -606,8 +606,8 @@ void MariaDBMonitor::update_external_master() mxb_assert(!m_master->m_slave_status.empty() && !m_master->m_node.external_masters.empty()); // TODO: Add support for multiple external masters. auto& master_sstatus = m_master->m_slave_status[0]; - if (master_sstatus.master_host != m_external_master_host || - master_sstatus.master_port != m_external_master_port) + if (master_sstatus.master_host != m_external_master_host + || master_sstatus.master_port != m_external_master_port) { const string new_ext_host = master_sstatus.master_host; const int new_ext_port = master_sstatus.master_port; @@ -795,10 +795,10 @@ bool MariaDBMonitor::run_manual_switchover(SERVER* promotion_server, { bool rval = false; bool send_ok = execute_manual_command([this, &rval, promotion_server, demotion_server, error_out]() { - rval - = manual_switchover(promotion_server, - demotion_server, - error_out); + rval = + manual_switchover(promotion_server, + demotion_server, + error_out); }, error_out); return send_ok && rval; diff --git a/server/modules/monitor/mariadbmon/mariadbserver.cc b/server/modules/monitor/mariadbmon/mariadbserver.cc index 0208b4353..87da9b8a8 100644 --- a/server/modules/monitor/mariadbmon/mariadbserver.cc +++ b/server/modules/monitor/mariadbmon/mariadbserver.cc @@ -223,15 +223,15 @@ bool MariaDBServer::do_show_slave_status(string* errmsg_out) string last_sql_error = result->get_string(i_last_sql_error); new_row.last_error = !last_io_error.empty() ? last_io_error : last_sql_error; - new_row.slave_io_running - = SlaveStatus::slave_io_from_string(result->get_string(i_slave_io_running)); + new_row.slave_io_running = + SlaveStatus::slave_io_from_string(result->get_string(i_slave_io_running)); new_row.slave_sql_running = (result->get_string(i_slave_sql_running) == "Yes"); new_row.master_server_id = result->get_uint(i_master_server_id); auto rlag = result->get_uint(i_seconds_behind_master); // If slave connection is stopped, the value given by the backend is null -> -1. - new_row.seconds_behind_master = (rlag < 0) ? MXS_RLAG_UNDEFINED - : (rlag > INT_MAX) ? INT_MAX : rlag; + new_row.seconds_behind_master = (rlag < 0) ? MXS_RLAG_UNDEFINED : + (rlag > INT_MAX) ? INT_MAX : rlag; if (all_slaves_status) { @@ -409,16 +409,16 @@ void MariaDBServer::warn_replication_settings() const const char* servername = name(); if (m_rpl_settings.gtid_strict_mode == false) { - const char NO_STRICT[] - = "Slave '%s' has gtid_strict_mode disabled. Enabling this setting is recommended. " - "For more information, see https://mariadb.com/kb/en/library/gtid/#gtid_strict_mode"; + const char NO_STRICT[] = + "Slave '%s' has gtid_strict_mode disabled. Enabling this setting is recommended. " + "For more information, see https://mariadb.com/kb/en/library/gtid/#gtid_strict_mode"; MXS_WARNING(NO_STRICT, servername); } if (m_rpl_settings.log_slave_updates == false) { - const char NO_SLAVE_UPDATES[] - = "Slave '%s' has log_slave_updates disabled. It is a valid candidate but replication " - "will break for lagging slaves if '%s' is promoted."; + const char NO_SLAVE_UPDATES[] = + "Slave '%s' has log_slave_updates disabled. It is a valid candidate but replication " + "will break for lagging slaves if '%s' is promoted."; MXS_WARNING(NO_SLAVE_UPDATES, servername, servername); } } @@ -580,13 +580,13 @@ json_t* MariaDBServer::to_json() const json_object_set_new(result, "gtid_current_pos", - m_gtid_current_pos.empty() ? json_null() - : json_string(m_gtid_current_pos.to_string().c_str())); + m_gtid_current_pos.empty() ? json_null() : + json_string(m_gtid_current_pos.to_string().c_str())); json_object_set_new(result, "gtid_binlog_pos", - m_gtid_binlog_pos.empty() ? json_null() - : json_string(m_gtid_binlog_pos.to_string().c_str())); + m_gtid_binlog_pos.empty() ? json_null() : + json_string(m_gtid_binlog_pos.to_string().c_str())); json_object_set_new(result, "master_group", @@ -812,8 +812,8 @@ bool MariaDBServer::update_slave_status(string* errmsg_out) if (rval) { /** Store master_id of current node. */ - m_server_base->server->master_id = !m_slave_status.empty() - ? m_slave_status[0].master_server_id : SERVER_ID_UNKNOWN; + m_server_base->server->master_id = !m_slave_status.empty() ? + m_slave_status[0].master_server_id : SERVER_ID_UNKNOWN; } return rval; } @@ -1346,8 +1346,8 @@ json_t* SlaveStatus::to_json() const json_object_set_new(result, "slave_sql_running", json_string(slave_sql_running ? "Yes" : "No")); json_object_set_new(result, "seconds_behing_master", - seconds_behind_master == MXS_RLAG_UNDEFINED ? json_null() - : json_integer(seconds_behind_master)); + seconds_behind_master == MXS_RLAG_UNDEFINED ? json_null() : + json_integer(seconds_behind_master)); json_object_set_new(result, "master_server_id", json_integer(master_server_id)); json_object_set_new(result, "last_io_or_sql_error", json_string(last_error.c_str())); json_object_set_new(result, "gtid_io_pos", json_string(gtid_io_pos.to_string().c_str())); diff --git a/server/modules/monitor/mariadbmon/test/test_cycle_find.cc b/server/modules/monitor/mariadbmon/test/test_cycle_find.cc index 85a554a0f..2a5a72829 100644 --- a/server/modules/monitor/mariadbmon/test/test_cycle_find.cc +++ b/server/modules/monitor/mariadbmon/test/test_cycle_find.cc @@ -119,10 +119,10 @@ int MariaDBMonitor::Test::run_tests() // Test 4: 10 servers, with a big cycle composed of two smaller ones plus non-cycle servers init_servers(10); - EdgeArray edges4 - = { { {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8}, - {8, 6}, - {9, 8}}}; + EdgeArray edges4 = + { { {1, 5}, {2, 1}, {2, 5}, {3, 1}, {3, 4}, {3, 10}, {4, 1}, {5, 6}, {6, 7}, {6, 4}, {7, 8}, + {8, 6}, + {9, 8}}}; add_replication(edges4); CycleArray expected_cycles4 = { { { {1, 5, 6, 7, 8, 4}}}}; results.push_back(check_result_cycles(expected_cycles4)); diff --git a/server/modules/monitor/mariadbmon/test/test_gtid.cc b/server/modules/monitor/mariadbmon/test/test_gtid.cc index d105d394a..3f139d67c 100644 --- a/server/modules/monitor/mariadbmon/test/test_gtid.cc +++ b/server/modules/monitor/mariadbmon/test/test_gtid.cc @@ -34,20 +34,23 @@ int test1() }; std::vector cases = { - {"0-1-1", "0-1-1"}, - {"4321-1234-4321", "4321-1234-4321"}, - {"blah", ""}, - {"1x2x3", ""}, - {"1-2-3-4", ""}, - {"45-54-123456789,0-1-2", "0-1-2,45-54-123456789"}, + {"0-1-1", "0-1-1" }, + {"4321-1234-4321", "4321-1234-4321" }, + {"blah", "" }, + {"1x2x3", "" }, + {"1-2-3-4", "" }, + {"45-54-123456789,0-1-2", "0-1-2,45-54-123456789" }, {"1-1-1,2-2-2,287-234-134,9-9-9,7-7-7", "1-1-1,2-2-2,7-7-7,9-9-9,287-234-134"}, - {"1-1-1,3-3-3,a-b-c", ""}, - {"-2--2--2",""}, - {"2-2-i",""}, - {"2-i-2",""}, - {"i-2-2",""}, - {"1-1-1,",""}, - {"3-1-0,3-2-4", "3-1-0,3-2-4"}, // Invalid triplet, but this case is not detected by the parser. + {"1-1-1,3-3-3,a-b-c", "" }, + {"-2--2--2", "" }, + {"2-2-i", "" }, + {"2-i-2", "" }, + {"i-2-2", "" }, + {"1-1-1,", "" }, + {"3-1-0,3-2-4", "3-1-0,3-2-4" }, // Invalid triplet, + // but this case is + // not detected by the + // parser. }; int errors = 0; @@ -56,8 +59,8 @@ int test1() string output = GtidList::from_string(test_case.input).to_string(); if (output != test_case.result) { - cout << "Wrong result: '" << test_case.input << "' produced '" << output << "' while '" << - test_case.result << "' was expected.\n"; + cout << "Wrong result: '" << test_case.input << "' produced '" << output << "' while '" + << test_case.result << "' was expected.\n"; errors++; } } @@ -77,22 +80,22 @@ int test2() struct TestCase { - string input1; - string input2; + string input1; + string input2; sub_mode mode; uint64_t result; }; std::vector cases = { - {"1-2-3", "1-2-3", ignore, 0}, - {"1-2-3,2-3-4", "1-2-3", lhs_add, 4}, - {"1-2-3,2-3-4", "1-2-3", ignore, 0}, - {"3-2-1,4-3-2", "4-3-1,3-1-0", lhs_add, 2}, - {"1-2-3,2-2-4,3-2-5", "1-2-3", lhs_add, 9}, - {"1-1-1000000,2-2-2000000", "1-1-1,2-2-2", ignore, 2999997}, - {"4-4-4,7-4-7,5-4-5,6-4-6,", "1-4-1", lhs_add, 0}, - {"4-4-4,7-4-7,5-4-5,6-4-6", "1-4-1", lhs_add, 22}, - {"5-1-4,", "5-1-2", ignore, 0}, + {"1-2-3", "1-2-3", ignore, 0 }, + {"1-2-3,2-3-4", "1-2-3", lhs_add, 4 }, + {"1-2-3,2-3-4", "1-2-3", ignore, 0 }, + {"3-2-1,4-3-2", "4-3-1,3-1-0", lhs_add, 2 }, + {"1-2-3,2-2-4,3-2-5", "1-2-3", lhs_add, 9 }, + {"1-1-1000000,2-2-2000000", "1-1-1,2-2-2", ignore, 2999997}, + {"4-4-4,7-4-7,5-4-5,6-4-6,", "1-4-1", lhs_add, 0 }, + {"4-4-4,7-4-7,5-4-5,6-4-6", "1-4-1", lhs_add, 22 }, + {"5-1-4,", "5-1-2", ignore, 0 }, }; int errors = 0; @@ -103,8 +106,8 @@ int test2() auto output = gtid1.events_ahead(gtid2, test_case.mode); if (output != test_case.result) { - cout << "Wrong result: '" << test_case.input1 << "' and '" << test_case.input2 << - "' produced '" << output << "' while '" << test_case.result << "' was expected.\n"; + cout << "Wrong result: '" << test_case.input1 << "' and '" << test_case.input2 + << "' produced '" << output << "' while '" << test_case.result << "' was expected.\n"; errors++; } } diff --git a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc index 6f72bbf5e..846fec201 100644 --- a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc +++ b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc @@ -369,8 +369,8 @@ static void handle_error_response(DCB* dcb, GWBUF* buffer) mxs_auth_state_t handle_server_response(DCB* dcb, GWBUF* buffer) { MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol; - mxs_auth_state_t rval = proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED - ? MXS_AUTH_STATE_HANDSHAKE_FAILED : MXS_AUTH_STATE_FAILED; + mxs_auth_state_t rval = proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED ? + MXS_AUTH_STATE_HANDSHAKE_FAILED : MXS_AUTH_STATE_FAILED; if (dcb->authfunc.extract(dcb, buffer)) { @@ -1236,8 +1236,8 @@ static int gw_MySQLWrite_backend(DCB* dcb, GWBUF* queue) MXS_ERROR("Unable to write to backend '%s' due to " "%s failure. Server in state %s.", dcb->server->name, - backend_protocol->protocol_auth_state == MXS_AUTH_STATE_HANDSHAKE_FAILED - ? "handshake" : "authentication", + backend_protocol->protocol_auth_state == MXS_AUTH_STATE_HANDSHAKE_FAILED ? + "handshake" : "authentication", STRSRVSTATUS(dcb->server)); } diff --git a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc index 968d16ac3..80dbffadc 100644 --- a/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc +++ b/server/modules/protocol/MySQL/mariadbclient/mysql_client.cc @@ -280,13 +280,13 @@ int MySQLSendHandshake(DCB* dcb) const char* plugin_name = DEFAULT_MYSQL_AUTH_PLUGIN; int plugin_name_len = strlen(plugin_name); - mysql_payload_size - = sizeof(mysql_protocol_version) + (len_version_string + 1) + sizeof(mysql_thread_id_num) + 8 - + sizeof( /* mysql_filler */ uint8_t) + sizeof(mysql_server_capabilities_one) - + sizeof(mysql_server_language) - + sizeof(mysql_server_status) + sizeof(mysql_server_capabilities_two) + sizeof(mysql_scramble_len) - + sizeof(mysql_filler_ten) + 12 + sizeof( /* mysql_last_byte */ uint8_t) + plugin_name_len - + sizeof( /* mysql_last_byte */ uint8_t); + mysql_payload_size = + sizeof(mysql_protocol_version) + (len_version_string + 1) + sizeof(mysql_thread_id_num) + 8 + + sizeof( /* mysql_filler */ uint8_t) + sizeof(mysql_server_capabilities_one) + + sizeof(mysql_server_language) + + sizeof(mysql_server_status) + sizeof(mysql_server_capabilities_two) + sizeof(mysql_scramble_len) + + sizeof(mysql_filler_ten) + 12 + sizeof( /* mysql_last_byte */ uint8_t) + plugin_name_len + + sizeof( /* mysql_last_byte */ uint8_t); // allocate memory for packet header + payload if ((buf = gwbuf_alloc(sizeof(mysql_packet_header) + mysql_payload_size)) == NULL) @@ -739,8 +739,8 @@ static int gw_read_do_authentication(DCB* dcb, GWBUF* read_buffer, int nbytes_re * is changed so that future data will go through the * normal data handling function instead of this one. */ - MXS_SESSION* session - = session_alloc_with_id(dcb->service, dcb, protocol->thread_id); + MXS_SESSION* session = + session_alloc_with_id(dcb->service, dcb, protocol->thread_id); if (session != NULL) { @@ -1784,8 +1784,8 @@ static spec_com_res_t process_special_commands(DCB* dcb, GWBUF* read_buffer, int { spec_com_res_t rval = RES_CONTINUE; bool is_complete = false; - unsigned int packet_len - = MYSQL_GET_PAYLOAD_LEN((uint8_t*)GWBUF_DATA(read_buffer)) + MYSQL_HEADER_LEN; + unsigned int packet_len = + MYSQL_GET_PAYLOAD_LEN((uint8_t*)GWBUF_DATA(read_buffer)) + MYSQL_HEADER_LEN; if (gwbuf_length(read_buffer) == packet_len) { is_complete = true; diff --git a/server/modules/protocol/MySQL/mysql_common.cc b/server/modules/protocol/MySQL/mysql_common.cc index 07a2196a1..fc47a7135 100644 --- a/server/modules/protocol/MySQL/mysql_common.cc +++ b/server/modules/protocol/MySQL/mysql_common.cc @@ -215,11 +215,11 @@ GWBUF* mysql_create_custom_error(int packet_number, mysql_error_msg = msg; } - mysql_payload_size - = sizeof(field_count) - + sizeof(mysql_err) - + sizeof(mysql_statemsg) - + strlen(mysql_error_msg); + mysql_payload_size = + sizeof(field_count) + + sizeof(mysql_err) + + sizeof(mysql_statemsg) + + strlen(mysql_error_msg); /** allocate memory for packet header + payload */ errbuf = gwbuf_alloc(sizeof(mysql_packet_header) + mysql_payload_size); @@ -413,8 +413,8 @@ int mysql_send_auth_error(DCB* dcb, mysql_error_msg = mysql_message; } - mysql_payload_size - = sizeof(field_count) + sizeof(mysql_err) + sizeof(mysql_statemsg) + strlen(mysql_error_msg); + mysql_payload_size = + sizeof(field_count) + sizeof(mysql_err) + sizeof(mysql_statemsg) + strlen(mysql_error_msg); // allocate memory for packet header + payload if ((buf = gwbuf_alloc(sizeof(mysql_packet_header) + mysql_payload_size)) == NULL) @@ -636,12 +636,12 @@ int mxs_mysql_send_ok(DCB* dcb, int sequence, uint8_t affected_rows, const char* GWBUF* buf; - mysql_payload_size - = sizeof(field_count) - + sizeof(affected_rows) - + sizeof(insert_id) - + sizeof(mysql_server_status) - + sizeof(mysql_warning_counter); + mysql_payload_size = + sizeof(field_count) + + sizeof(affected_rows) + + sizeof(insert_id) + + sizeof(mysql_server_status) + + sizeof(mysql_warning_counter); if (message != NULL) { @@ -1014,8 +1014,8 @@ int send_mysql_native_password_response(DCB* dcb) MYSQL_session local_session; gw_get_shared_session_auth_info(dcb, &local_session); - uint8_t* curr_passwd = memcmp(local_session.client_sha1, null_client_sha1, MYSQL_SCRAMBLE_LEN) - ? local_session.client_sha1 : null_client_sha1; + uint8_t* curr_passwd = memcmp(local_session.client_sha1, null_client_sha1, MYSQL_SCRAMBLE_LEN) ? + local_session.client_sha1 : null_client_sha1; GWBUF* buffer = gwbuf_alloc(MYSQL_HEADER_LEN + GW_MYSQL_SCRAMBLE_SIZE); uint8_t* data = GWBUF_DATA(buffer); @@ -1501,8 +1501,8 @@ void mxs_mysql_parse_ok_packet(GWBUF* buff, size_t packet_offset, size_t packet_ while (ptr < (local_buf + packet_len)) { - enum_session_state_type type - = (enum enum_session_state_type)mxs_leint_consume(&ptr); + enum_session_state_type type = + (enum enum_session_state_type)mxs_leint_consume(&ptr); #if defined (SS_DEBUG) mxb_assert(type <= SESSION_TRACK_TRANSACTION_TYPE); #endif diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index 857d2b1b1..cde63520a 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -783,9 +783,9 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params /* Log binlog structure storage mode */ MXS_NOTICE("%s: storing binlog files in %s", service->name, - inst->storage_type == BLR_BINLOG_STORAGE_FLAT - ? "'flat' mode" - : "'tree' mode using GTID domain_id and server_id"); + inst->storage_type == BLR_BINLOG_STORAGE_FLAT ? + "'flat' mode" : + "'tree' mode using GTID domain_id and server_id"); /* Enable MariaDB the GTID maps store */ if (inst->mariadb10_compat) @@ -826,8 +826,8 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params SSL_LISTENER* ssl_cfg; /* Allocate SSL struct for backend connection */ - if ((ssl_cfg - = static_cast(MXS_CALLOC(1, sizeof(SSL_LISTENER)))) == NULL) + if ((ssl_cfg = + static_cast(MXS_CALLOC(1, sizeof(SSL_LISTENER)))) == NULL) { MXS_ERROR("%s: Error allocating memory for SSL struct in createInstance", inst->service->name); @@ -1649,8 +1649,8 @@ static void diagnostics(MXS_ROUTER* router, DCB* dcb) router_inst->stats.n_residuals); dcb_printf(dcb, "\tAverage events per packet: %.1f\n", - router_inst->stats.n_reads != 0 - ? ((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0); + router_inst->stats.n_reads != 0 ? + ((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0); spinlock_acquire(&router_inst->lock); if (router_inst->stats.lastReply) @@ -1669,8 +1669,8 @@ static void diagnostics(MXS_ROUTER* router, DCB* dcb) dcb_printf(dcb, "\tLast event from master: 0x%x, %s\n", router_inst->lastEventReceived, - (router_inst->lastEventReceived <= MAX_EVENT_TYPE) - ? event_names[router_inst->lastEventReceived] : "unknown"); + (router_inst->lastEventReceived <= MAX_EVENT_TYPE) ? + event_names[router_inst->lastEventReceived] : "unknown"); } else { @@ -1824,8 +1824,8 @@ static void diagnostics(MXS_ROUTER* router, DCB* dcb) { dcb_printf(dcb, "\t\tSlave connected with SSL: %s\n", - session->dcb->ssl_state == SSL_ESTABLISHED - ? "Established" : "Not connected yet"); + session->dcb->ssl_state == SSL_ESTABLISHED ? + "Established" : "Not connected yet"); } dcb_printf(dcb, "\t\tNext Sequence No: %d\n", @@ -1947,10 +1947,10 @@ static void diagnostics(MXS_ROUTER* router, DCB* dcb) { dcb_printf(dcb, "\t\tSlave_mode: catchup. %s%s\n", - ((session->cstate & CS_EXPECTCB) == 0 ? "" - : "Waiting for DCB queue to drain."), - ((session->cstate & CS_BUSY) == 0 ? "" - : " Busy in slave catchup.")); + ((session->cstate & CS_EXPECTCB) == 0 ? "" : + "Waiting for DCB queue to drain."), + ((session->cstate & CS_BUSY) == 0 ? "" : + " Busy in slave catchup.")); } } #if SPINLOCK_PROFILE @@ -2103,8 +2103,8 @@ static json_t* diagnostics_json(const MXS_ROUTER* router) json_object_set_new(rval, "events_read", json_integer(router_inst->stats.n_reads)); json_object_set_new(rval, "residual_packets", json_integer(router_inst->stats.n_residuals)); - double average_packets = router_inst->stats.n_reads != 0 - ? ((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0; + double average_packets = router_inst->stats.n_reads != 0 ? + ((double)router_inst->stats.n_binlogs / router_inst->stats.n_reads) : 0; json_object_set_new(rval, "average_events_per_packets", json_real(average_packets)); @@ -2122,9 +2122,9 @@ static json_t* diagnostics_json(const MXS_ROUTER* router) { json_object_set_new(rval, "latest_event_type", - json_string((router_inst->lastEventReceived <= MAX_EVENT_TYPE) - ? event_names[router_inst->lastEventReceived] - : "unknown")); + json_string((router_inst->lastEventReceived <= MAX_EVENT_TYPE) ? + event_names[router_inst->lastEventReceived] : + "unknown")); } else { diff --git a/server/modules/routing/binlogrouter/blr_event.cc b/server/modules/routing/binlogrouter/blr_event.cc index d543f7716..036d6896e 100644 --- a/server/modules/routing/binlogrouter/blr_event.cc +++ b/server/modules/routing/binlogrouter/blr_event.cc @@ -139,8 +139,8 @@ bool blr_handle_one_event(MXS_ROUTER* instance, REP_HEADER& hdr, uint8_t* ptr, u statement_len = len - (MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \ + var_block_len + 1 + db_name_len); - statement_sql - = static_cast(MXS_CALLOC(1, statement_len + 1)); + statement_sql = + static_cast(MXS_CALLOC(1, statement_len + 1)); MXS_ABORT_IF_NULL(statement_sql); memcpy(statement_sql, (char*)ptr + MYSQL_HEADER_LEN + 1 + BINLOG_EVENT_HDR_LEN + 4 + 4 + 1 + 2 + 2 \ @@ -205,8 +205,8 @@ bool blr_handle_one_event(MXS_ROUTER* instance, REP_HEADER& hdr, uint8_t* ptr, u * the replication event types * else stop replication from master */ - int event_limit = router->mariadb10_compat - ? MAX_EVENT_TYPE_MARIADB10 : MAX_EVENT_TYPE; + int event_limit = router->mariadb10_compat ? + MAX_EVENT_TYPE_MARIADB10 : MAX_EVENT_TYPE; if (hdr.event_type <= event_limit) { diff --git a/server/modules/routing/binlogrouter/blr_file.cc b/server/modules/routing/binlogrouter/blr_file.cc index f427c57d1..45a9afa47 100644 --- a/server/modules/routing/binlogrouter/blr_file.cc +++ b/server/modules/routing/binlogrouter/blr_file.cc @@ -2363,8 +2363,8 @@ int blr_read_events_all_events(ROUTER_INSTANCE* router, { MXS_DEBUG(" FDE Checksum alg desc %i, alg type %s", check_alg, - check_alg == 1 - ? "BINLOG_CHECKSUM_ALG_CRC32" : "NONE or UNDEF"); + check_alg == 1 ? + "BINLOG_CHECKSUM_ALG_CRC32" : "NONE or UNDEF"); } if (check_alg == 1) { @@ -2413,8 +2413,8 @@ int blr_read_events_all_events(ROUTER_INSTANCE* router, char nonce_hex[AES_BLOCK_SIZE * 2 + 1] = ""; MXS_START_ENCRYPTION_EVENT ste_event = {}; void* mem = MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX)); - BINLOG_ENCRYPTION_CTX* new_encryption_ctx - = static_cast(mem); + BINLOG_ENCRYPTION_CTX* new_encryption_ctx = + static_cast(mem); if (new_encryption_ctx == NULL) { @@ -2761,10 +2761,10 @@ int blr_read_events_all_events(ROUTER_INSTANCE* router, db_name_len = ptr[4 + 4]; var_block_len = ptr[4 + 4 + 1 + 2]; - statement_len - = hdr.event_size - - BINLOG_EVENT_HDR_LEN - - (4 + 4 + 1 + 2 + 2 + var_block_len + 1 + db_name_len); + statement_len = + hdr.event_size + - BINLOG_EVENT_HDR_LEN + - (4 + 4 + 1 + 2 + 2 + var_block_len + 1 + db_name_len); statement_sql = static_cast(MXS_CALLOC(1, statement_len + 1)); if (statement_sql) @@ -3782,8 +3782,8 @@ uint8_t* blr_create_start_encryption_event(ROUTER_INSTANCE* router, { uint8_t* new_event; uint8_t event_size = sizeof(MXS_START_ENCRYPTION_EVENT); - BINLOG_ENCRYPTION_CTX* new_encryption_ctx - = static_cast(MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX))); + BINLOG_ENCRYPTION_CTX* new_encryption_ctx = + static_cast(MXS_CALLOC(1, sizeof(BINLOG_ENCRYPTION_CTX))); if (new_encryption_ctx == NULL) { @@ -4860,20 +4860,20 @@ bool blr_binlog_file_exists(ROUTER_INSTANCE* router, // Add prefix sprintf(prefix, "%" PRIu32 "/%" PRIu32 "/", - info_file - ? info_file->gtid_elms.domain_id - : router->mariadb10_gtid_domain, - info_file - ? info_file->gtid_elms.server_id - : router->orig_masterid); + info_file ? + info_file->gtid_elms.domain_id : + router->mariadb10_gtid_domain, + info_file ? + info_file->gtid_elms.server_id : + router->orig_masterid); strcat(path, prefix); } // Set final file name full path strcat(path, - info_file == NULL - ? router->binlog_name - : info_file->file); + info_file == NULL ? + router->binlog_name : + info_file->file); // Check file if (access(path, F_OK) == -1 && errno == ENOENT) @@ -4881,9 +4881,9 @@ bool blr_binlog_file_exists(ROUTER_INSTANCE* router, // No file found MXS_WARNING("%s: %s, missing binlog file '%s'", router->service->name, - info_file == NULL - ? "ROTATE_EVENT" - : "Slave request", + info_file == NULL ? + "ROTATE_EVENT" : + "Slave request", path); ret = false; diff --git a/server/modules/routing/binlogrouter/blr_master.cc b/server/modules/routing/binlogrouter/blr_master.cc index fef022014..08fd756dd 100644 --- a/server/modules/routing/binlogrouter/blr_master.cc +++ b/server/modules/routing/binlogrouter/blr_master.cc @@ -1226,8 +1226,8 @@ static void* CreateMySQLAuthData(const char* username, const char* password, con return NULL; } - if ((auth_info - = static_cast(MXS_CALLOC(1, sizeof(MYSQL_session)))) == NULL) + if ((auth_info = + static_cast(MXS_CALLOC(1, sizeof(MYSQL_session)))) == NULL) { return NULL; } @@ -1556,12 +1556,12 @@ static void blr_log_identity(ROUTER_INSTANCE* router) "Server_id: %d, Slave_UUID: %s, Host: %s", router->service->name, router->serverid, - router->uuid == NULL - ? "not available" - : router->uuid, - (router->set_slave_hostname && router->set_slave_hostname[0]) - ? router->set_slave_hostname - : "not set"); + router->uuid == NULL ? + "not available" : + router->uuid, + (router->set_slave_hostname && router->set_slave_hostname[0]) ? + router->set_slave_hostname : + "not set"); /* Seen by the slaves */ @@ -1745,8 +1745,8 @@ bool blr_send_event(blr_thread_role_t role, while (rval && len > 0) { - uint64_t payload_len = first ? MYSQL_PACKET_LENGTH_MAX - 1 - : MXS_MIN(MYSQL_PACKET_LENGTH_MAX, len); + uint64_t payload_len = first ? MYSQL_PACKET_LENGTH_MAX - 1 : + MXS_MIN(MYSQL_PACKET_LENGTH_MAX, len); if (blr_send_packet(slave, buf, payload_len, first)) { @@ -2531,12 +2531,12 @@ static void blr_start_master_registration(ROUTER_INSTANCE* router, GWBUF* buf) blr_register_handle_checksum(router, buf); // Next state is BLRM_MARIADB10 or BLRM_GTIDMODE { - unsigned int state = router->mariadb10_compat - ? BLRM_MARIADB10 - : BLRM_GTIDMODE; - const char* command = router->mariadb10_compat - ? "SET @mariadb_slave_capability=4" - : "SELECT @@GLOBAL.GTID_MODE"; + unsigned int state = router->mariadb10_compat ? + BLRM_MARIADB10 : + BLRM_GTIDMODE; + const char* command = router->mariadb10_compat ? + "SET @mariadb_slave_capability=4" : + "SELECT @@GLOBAL.GTID_MODE"; blr_register_send_command(router, command, state); } @@ -2554,12 +2554,12 @@ static void blr_start_master_registration(ROUTER_INSTANCE* router, GWBUF* buf) * Always request "gtid_domain_id" to Master server * if MariaDB 10 Compatibilty is On */ - unsigned int state = router->mariadb10_compat - ? BLRM_MARIADB10_GTID_DOMAIN - : BLRM_LATIN1; - const char* command = router->mariadb10_compat - ? "SELECT @@GLOBAL.gtid_domain_id" - : "SET NAMES latin1"; + unsigned int state = router->mariadb10_compat ? + BLRM_MARIADB10_GTID_DOMAIN : + BLRM_LATIN1; + const char* command = router->mariadb10_compat ? + "SELECT @@GLOBAL.gtid_domain_id" : + "SET NAMES latin1"; blr_register_send_command(router, command, state); } break; @@ -2643,12 +2643,12 @@ static void blr_start_master_registration(ROUTER_INSTANCE* router, GWBUF* buf) buf); // Next state is MAXWELL BLRM_RESULTS_CHARSET or BLRM_SELECT1 { - unsigned int state = router->maxwell_compat - ? BLRM_RESULTS_CHARSET - : BLRM_SELECT1; - const char* command = router->maxwell_compat - ? "SET character_set_results = NULL" - : "SELECT 1"; + unsigned int state = router->maxwell_compat ? + BLRM_RESULTS_CHARSET : + BLRM_SELECT1; + const char* command = router->maxwell_compat ? + "SET character_set_results = NULL" : + "SELECT 1"; blr_register_send_command(router, command, state); break; diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index aacbfd8d3..f126c6c43 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -1219,9 +1219,9 @@ static int blr_slave_send_slave_status(ROUTER_INSTANCE* router, } /* Get the right GTID columns array */ - const char** gtid_status_columns = router->mariadb10_gtid - ? mariadb10_gtid_status_columns - : mysql_gtid_status_columns; + const char** gtid_status_columns = router->mariadb10_gtid ? + mariadb10_gtid_status_columns : + mysql_gtid_status_columns; /* Increment ncols with the right GTID columns */ while (gtid_status_columns[gtid_cols++]) { @@ -1321,9 +1321,9 @@ static int blr_slave_send_slave_status(ROUTER_INSTANCE* router, snprintf(column, max_column_size, "%s", - router->service->dbref->server->address - ? router->service->dbref->server->address - : ""); + router->service->dbref->server->address ? + router->service->dbref->server->address : + ""); col_len = strlen(column); *ptr++ = col_len; // Length of result string memcpy((char*)ptr, column, col_len); // Result string @@ -1589,8 +1589,8 @@ static int blr_slave_send_slave_status(ROUTER_INSTANCE* router, snprintf(column, max_column_size, "%s", - router->master_uuid - ? router->master_uuid : router->uuid); + router->master_uuid ? + router->master_uuid : router->uuid); col_len = strlen(column); *ptr++ = col_len; // Length of result string memcpy((char*)ptr, column, col_len); // Result string @@ -1663,9 +1663,9 @@ static int blr_slave_send_slave_status(ROUTER_INSTANCE* router, // 1 - Add "Using_Gtid" sprintf(column, "%s", - router->mariadb10_master_gtid - ? "Slave_pos" - : "No"); + router->mariadb10_master_gtid ? + "Slave_pos" : + "No"); col_len = strlen(column); *ptr++ = col_len; // Length of result string memcpy(ptr, column, col_len); // Result string @@ -2301,9 +2301,9 @@ int blr_slave_catchup(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, bool large) int rotating = 0; long burst_size; char read_errmsg[BINLOG_ERROR_MSG_LEN + 1]; - MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE - ? &slave->f_info - : NULL; + MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ? + &slave->f_info : + NULL; read_errmsg[BINLOG_ERROR_MSG_LEN] = '\0'; @@ -3205,9 +3205,9 @@ static int blr_slave_fake_rotate(ROUTER_INSTANCE* router, const char* sptr; int filenum; GWBUF* r_event; - MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE - ? &slave->f_info - : NULL; + MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ? + &slave->f_info : + NULL; if ((sptr = strrchr(new_file, '.')) == NULL) { @@ -3258,9 +3258,9 @@ static GWBUF* blr_slave_read_fde(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave) uint8_t* ptr; uint32_t chksum; char err_msg[BINLOG_ERROR_MSG_LEN + 1]; - MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE - ? &slave->f_info - : NULL; + MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ? + &slave->f_info : + NULL; err_msg[BINLOG_ERROR_MSG_LEN] = '\0'; @@ -4258,9 +4258,9 @@ namespace int validate_connection_name(ROUTER_INSTANCE* router, const std::string& name, char* error) { - static const char DEFAULT_MESSAGE[] - = "If a connection name is provided, it must be of the format ':N' where N " - "is an integer larger than 1."; + static const char DEFAULT_MESSAGE[] = + "If a connection name is provided, it must be of the format ':N' where N " + "is an integer larger than 1."; int index = -1; @@ -4565,9 +4565,9 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, if (use_gtid.empty() || (strcasecmp(use_gtid.c_str(), "slave_pos") != 0)) { - static const char MESSAGE[] - = "Secondary masters can only be used in conjunction with GTID based replication. " - "Specify MASTER_USE_GTID=Slave_pos for the default master connection."; + static const char MESSAGE[] = + "Secondary masters can only be used in conjunction with GTID based replication. " + "Specify MASTER_USE_GTID=Slave_pos for the default master connection."; mxb_assert(sizeof(MESSAGE) <= BINLOG_ERROR_MSG_LEN); strcpy(error, MESSAGE); return -1; @@ -4610,8 +4610,8 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, if (!use_gtid.empty() && (strcasecmp(use_gtid.c_str(), "slave_pos") != 0)) { - static const char MESSAGE[] - = "Only MASTER_USE_GTID=Slave_pos is allowed."; + static const char MESSAGE[] = + "Only MASTER_USE_GTID=Slave_pos is allowed."; mxb_assert(sizeof(MESSAGE) <= BINLOG_ERROR_MSG_LEN); strcpy(error, MESSAGE); return -1; @@ -5848,9 +5848,9 @@ static int blr_slave_show_warnings(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave) msg_ptr = strchr(slave->warning_msg, ':'); if (msg_ptr) { - size_t len = (msg_ptr - slave->warning_msg > 16) - ? 16 - : (msg_ptr - slave->warning_msg); + size_t len = (msg_ptr - slave->warning_msg > 16) ? + 16 : + (msg_ptr - slave->warning_msg); memcpy(err_code, slave->warning_msg, len); err_code[len] = 0; code_len = strlen(err_code); @@ -6479,9 +6479,9 @@ static int blr_slave_read_ste(ROUTER_INSTANCE* router, uint8_t* ptr; uint32_t chksum; char err_msg[BINLOG_ERROR_MSG_LEN + 1]; - MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE - ? &slave->f_info - : NULL; + MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ? + &slave->f_info : + NULL; err_msg[BINLOG_ERROR_MSG_LEN] = '\0'; @@ -6524,8 +6524,8 @@ static int blr_slave_read_ste(ROUTER_INSTANCE* router, { uint8_t* record_ptr = GWBUF_DATA(record); void* mem = MXS_CALLOC(1, sizeof(SLAVE_ENCRYPTION_CTX)); - SLAVE_ENCRYPTION_CTX* new_encryption_ctx - = static_cast(mem); + SLAVE_ENCRYPTION_CTX* new_encryption_ctx = + static_cast(mem); if (!new_encryption_ctx) { @@ -6849,9 +6849,9 @@ static bool blr_handle_simple_select_stmt(ROUTER_INSTANCE* router, sprintf(max_conns, "%d", - !router->service->max_connections - ? BLR_DEFAULT_MAX_CONNS - : router->service->max_connections); + !router->service->max_connections ? + BLR_DEFAULT_MAX_CONNS : + router->service->max_connections); strcpy(heading, word); blr_slave_send_var_value(router, @@ -7531,9 +7531,9 @@ static bool blr_handle_show_stmt(ROUTER_INSTANCE* router, } else { - const char* errmsg - = "SHOW [FULL] BINARY LOGS needs the" - " 'mariadb10_slave_gtid' option to be set."; + const char* errmsg = + "SHOW [FULL] BINARY LOGS needs the" + " 'mariadb10_slave_gtid' option to be set."; MXS_ERROR("%s: %s", errmsg, router->service->name); @@ -7859,15 +7859,15 @@ static bool blr_handle_set_stmt(ROUTER_INSTANCE* router, const char* err_msg_s = "stopped replication: issue STOP SLAVE first."; char error_string[BINLOG_ERROR_MSG_LEN + 1] = ""; MXS_ERROR("GTID registration without %s", - router->master_state == BLRM_SLAVE_STOPPED - ? err_msg_s : err_msg_u); + router->master_state == BLRM_SLAVE_STOPPED ? + err_msg_s : err_msg_u); snprintf(error_string, BINLOG_ERROR_MSG_LEN, "Cannot use Master GTID registration without %s", - router->master_state == BLRM_SLAVE_STOPPED - ? err_msg_s - : err_msg_u); + router->master_state == BLRM_SLAVE_STOPPED ? + err_msg_s : + err_msg_u); blr_slave_send_error_packet(slave, error_string, @@ -8062,9 +8062,9 @@ static bool blr_handle_admin_stmt(ROUTER_INSTANCE* router, } else { - const char* errmsg - = "PURGE BINARY LOGS needs the " - "'mariadb10_slave_gtid' option to be set."; + const char* errmsg = + "PURGE BINARY LOGS needs the " + "'mariadb10_slave_gtid' option to be set."; MXS_ERROR("%s: %s", errmsg, router->service->name); @@ -8408,9 +8408,9 @@ static void blr_slave_skip_empty_files(ROUTER_INSTANCE* router, unsigned int seqno; bool skipped_files = false; char t_prefix[BINLOG_FILE_EXTRA_INFO] = ""; - MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE - ? &slave->f_info - : NULL; + MARIADB_GTID_INFO* f_tree = router->storage_type == BLR_BINLOG_STORAGE_TREE ? + &slave->f_info : + NULL; char next_file[BINLOG_FNAMELEN + 1] = ""; // Save the current router binlog filename @@ -8591,9 +8591,9 @@ static int blr_show_binary_logs(ROUTER_INSTANCE* router, */ if (sqlite3_exec(router->gtid_maps, - !result.use_tree - ? select_query - : select_query_full, + !result.use_tree ? + select_query : + select_query_full, binary_logs_select_cb, &result, &errmsg) != SQLITE_OK) @@ -8765,9 +8765,9 @@ static int binary_logs_select_cb(void* data, blr_get_file_fullpath(values[0], data_set->binlogdir, file_path, - data_set->use_tree - ? t_prefix - : NULL); + data_set->use_tree ? + t_prefix : + NULL); // Get the file size fsize = blr_slave_get_file_size(file_path); @@ -8854,9 +8854,9 @@ static int blr_slave_send_id_ro(ROUTER_INSTANCE* router, /* Set identy for MySQL replication monitor */ sprintf(server_id, "%d", - router->set_master_server_id - ? router->masterid - : router->serverid); + router->set_master_server_id ? + router->masterid : + router->serverid); if ((pkt = blr_create_result_row(server_id, // File name "0", // o = OFF @@ -8957,9 +8957,9 @@ static int binary_logs_purge_cb(void* data, char full_path[PATH_MAX + 1]; /* values[0] is filename, values[1] is prefix + file */ - filename = !result_data->use_tree - ? values[0] - : values[1]; + filename = !result_data->use_tree ? + values[0] : + values[1]; sprintf(full_path, "%s/%s", result_data->binlogdir, filename); @@ -9230,10 +9230,10 @@ static void blr_log_config_changes(ROUTER_INSTANCE* router, } /* Prepare GTID msg */ - const char* gtid_msg - = !change_master.use_mariadb10_gtid.empty() - ? ", MASTER_USE_GTID=Slave_pos" - : ""; + const char* gtid_msg = + !change_master.use_mariadb10_gtid.empty() ? + ", MASTER_USE_GTID=Slave_pos" : + ""; /* Log previous state and new changes */ MXS_NOTICE("%s: 'CHANGE MASTER TO executed'. Previous state " @@ -9449,9 +9449,9 @@ static bool blr_binlog_change_check(const ROUTER_INSTANCE* router, snprintf(error, BINLOG_ERROR_MSG_LEN, "%s MASTER_USE_GTID=Slave_pos is required", - router->master_state == BLRM_UNCONFIGURED - ? "Router is not configured for master connection," - : "Cannot use MASTER_LOG_FILE for master connection,"); + router->master_state == BLRM_UNCONFIGURED ? + "Router is not configured for master connection," : + "Cannot use MASTER_LOG_FILE for master connection,"); return false; } diff --git a/server/modules/routing/binlogrouter/test/testbinlog.cc b/server/modules/routing/binlogrouter/test/testbinlog.cc index 8b495c650..6b3679ef7 100644 --- a/server/modules/routing/binlogrouter/test/testbinlog.cc +++ b/server/modules/routing/binlogrouter/test/testbinlog.cc @@ -862,9 +862,9 @@ int main(int argc, char** argv) /** * Verify SQL query initial comment skipping function works on a real use case. */ - const char* mysql_connector_j_actual - = blr_skip_leading_sql_comments( - "/* mysql-connector-java-5.1.39 ( Revision: 3289a357af6d09ecc1a10fd3c26e95183e5790ad ) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout"); + const char* mysql_connector_j_actual = + blr_skip_leading_sql_comments( + "/* mysql-connector-java-5.1.39 ( Revision: 3289a357af6d09ecc1a10fd3c26e95183e5790ad ) */SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout"); const char* mysql_connector_j_expected = "SELECT @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS tx_isolation, @@wait_timeout AS wait_timeout"; @@ -894,8 +894,8 @@ int main(int argc, char** argv) tests++; - const char* unclosed_comment_query_actual - = blr_skip_leading_sql_comments("/* SELECT foo FROM bar LIMIT 1"); + const char* unclosed_comment_query_actual = + blr_skip_leading_sql_comments("/* SELECT foo FROM bar LIMIT 1"); const char* unclosed_comment_query_expected = ""; if (strcmp(unclosed_comment_query_actual, unclosed_comment_query_expected) == 0) { diff --git a/server/modules/routing/debugcli/debugcmd.cc b/server/modules/routing/debugcli/debugcmd.cc index d2f812e1b..a3b9e7168 100644 --- a/server/modules/routing/debugcli/debugcmd.cc +++ b/server/modules/routing/debugcli/debugcmd.cc @@ -2084,8 +2084,8 @@ static bool user_is_authorized(DCB* dcb) static SPINLOCK debugcmd_lock = SPINLOCK_INIT; -static const char item_separator[] - = "----------------------------------------------------------------------------\n"; +static const char item_separator[] = + "----------------------------------------------------------------------------\n"; /** * We have a complete line from the user, lookup the commands and execute them diff --git a/server/modules/routing/hintrouter/hintroutersession.cc b/server/modules/routing/hintrouter/hintroutersession.cc index 80571436e..7b222a0b0 100644 --- a/server/modules/routing/hintrouter/hintroutersession.cc +++ b/server/modules/routing/hintrouter/hintroutersession.cc @@ -272,8 +272,8 @@ bool HintRouterSession::route_by_hint(GWBUF* pPacket, HINT* hint, bool print_err case HINT_ROUTE_TO_ALL: { HR_DEBUG("Writing packet to %lu backends.", m_backends.size()); - BackendMap::size_type n_writes - = std::count_if(m_backends.begin(), m_backends.end(), Writer(pPacket)); + BackendMap::size_type n_writes = + std::count_if(m_backends.begin(), m_backends.end(), Writer(pPacket)); if (n_writes != 0) { m_surplus_replies = n_writes - 1; diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index ca9c63307..fca5e59fc 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -134,9 +134,9 @@ RWSplit::SrvStatMap RWSplit::all_server_stats() const int RWSplit::max_slave_count() const { int router_nservers = m_service->n_dbref; - int conf_max_nslaves = m_config->max_slave_connections > 0 - ? m_config->max_slave_connections - : (router_nservers * m_config->rw_max_slave_conn_percent) / 100; + int conf_max_nslaves = m_config->max_slave_connections > 0 ? + m_config->max_slave_connections : + (router_nservers * m_config->rw_max_slave_conn_percent) / 100; return MXS_MIN(router_nservers - 1, MXS_MAX(1, conf_max_nslaves)); } diff --git a/server/modules/routing/readwritesplit/readwritesplit.hh b/server/modules/routing/readwritesplit/readwritesplit.hh index 1fbe18297..2386b60b1 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.hh +++ b/server/modules/routing/readwritesplit/readwritesplit.hh @@ -125,9 +125,9 @@ static const MXS_ENUM_VALUE master_failure_mode_values[] = #define MARIADB_WAIT_GTID_FUNC "MASTER_GTID_WAIT" #define MYSQL_WAIT_GTID_FUNC "WAIT_FOR_EXECUTED_GTID_SET" -static const char gtid_wait_stmt[] - = "SET @maxscale_secret_variable=(SELECT CASE WHEN %s('%s', %s) = 0 " - "THEN 1 ELSE (SELECT 1 FROM INFORMATION_SCHEMA.ENGINES) END);"; +static const char gtid_wait_stmt[] = + "SET @maxscale_secret_variable=(SELECT CASE WHEN %s('%s', %s) = 0 " + "THEN 1 ELSE (SELECT 1 FROM INFORMATION_SCHEMA.ENGINES) END);"; /** Function that returns a "score" for a server to enable comparison. * Smaller numbers are better. diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 9a08cd0b8..cc570ef37 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -937,8 +937,8 @@ bool RWSplitSession::handle_master_is_target(SRWBackend* dest) if (should_replace_master(target)) { MXS_INFO("Replacing old master '%s' with new master '%s'", - m_current_master - ? m_current_master->name() : "", + m_current_master ? + m_current_master->name() : "", target->name()); replace_master(target); } @@ -1004,8 +1004,8 @@ GWBUF* RWSplitSession::add_prefix_wait_gtid(SERVER* server, GWBUF* origin) **/ GWBUF* rval = origin; - const char* wait_func = (server->server_type == SERVER_TYPE_MARIADB) - ? MARIADB_WAIT_GTID_FUNC : MYSQL_WAIT_GTID_FUNC; + const char* wait_func = (server->server_type == SERVER_TYPE_MARIADB) ? + MARIADB_WAIT_GTID_FUNC : MYSQL_WAIT_GTID_FUNC; const char* gtid_wait_timeout = m_config.causal_reads_timeout.c_str(); const char* gtid_position = m_gtid_pos.c_str(); @@ -1088,9 +1088,9 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool * will do the replacement of PS IDs which must not be done if we are * continuing an ongoing query. */ - bool success = !m_qc.large_query() - ? target->write(send_buf, response) - : target->continue_write(send_buf); + bool success = !m_qc.large_query() ? + target->write(send_buf, response) : + target->continue_write(send_buf); if (success) { diff --git a/server/modules/routing/readwritesplit/rwsplitsession.hh b/server/modules/routing/readwritesplit/rwsplitsession.hh index e87bf4d4b..bab403ee4 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.hh +++ b/server/modules/routing/readwritesplit/rwsplitsession.hh @@ -289,9 +289,9 @@ private: { if (session_trx_is_ending(m_client->session)) { - mxb::atomic::add(m_qc.is_trx_still_read_only() - ? &m_router->stats().n_ro_trx - : &m_router->stats().n_rw_trx, + mxb::atomic::add(m_qc.is_trx_still_read_only() ? + &m_router->stats().n_ro_trx : + &m_router->stats().n_rw_trx, 1, mxb::atomic::RELAXED); } diff --git a/server/modules/routing/schemarouter/schemarouterinstance.cc b/server/modules/routing/schemarouter/schemarouterinstance.cc index 9a284f6bf..a3124dfe3 100644 --- a/server/modules/routing/schemarouter/schemarouterinstance.cc +++ b/server/modules/routing/schemarouter/schemarouterinstance.cc @@ -208,9 +208,9 @@ SchemaRouterSession* SchemaRouter::newSession(MXS_SESSION* pSession) void SchemaRouter::diagnostics(DCB* dcb) { - double sescmd_pct = m_stats.n_sescmd != 0 - ? 100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) - : 0.0; + double sescmd_pct = m_stats.n_sescmd != 0 ? + 100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) : + 0.0; /** Session command statistics */ dcb_printf(dcb, "\n\33[1;4mSession Commands\33[0m\n"); @@ -243,9 +243,9 @@ void SchemaRouter::diagnostics(DCB* dcb) json_t* SchemaRouter::diagnostics_json() const { - double sescmd_pct = m_stats.n_sescmd != 0 - ? 100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) - : 0.0; + double sescmd_pct = m_stats.n_sescmd != 0 ? + 100.0 * ((double)m_stats.n_sescmd / (double)m_stats.n_queries) : + 0.0; json_t* rval = json_object(); json_object_set_new(rval, "queries", json_integer(m_stats.n_queries)); diff --git a/server/modules/routing/schemarouter/schemaroutersession.cc b/server/modules/routing/schemarouter/schemaroutersession.cc index 5b3d4a35d..41d8e80f9 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.cc +++ b/server/modules/routing/schemarouter/schemaroutersession.cc @@ -126,9 +126,9 @@ void SchemaRouterSession::close() m_router->m_stats.ses_shortest = ses_time; } - m_router->m_stats.ses_average - = (ses_time + ((m_router->m_stats.sessions - 1) * m_router->m_stats.ses_average)) - / (m_router->m_stats.sessions); + m_router->m_stats.ses_average = + (ses_time + ((m_router->m_stats.sessions - 1) * m_router->m_stats.ses_average)) + / (m_router->m_stats.sessions); spinlock_release(&m_router->m_lock); } @@ -558,8 +558,8 @@ void SchemaRouterSession::clientReply(GWBUF* pPacket, DCB* pDcb) bref->backend()->server->name, m_client->session, m_state & INIT_MAPPING ? "true" : "false", - m_queue.size() == 0 ? "none" - : m_queue.size() > 0 ? "multiple" : "one"); + m_queue.size() == 0 ? "none" : + m_queue.size() > 0 ? "multiple" : "one"); if (m_state & INIT_MAPPING) { @@ -1807,8 +1807,8 @@ SERVER* SchemaRouterSession::get_ps_target(GWBUF* buffer, uint32_t qtype, qc_que rval = m_shard.get_location(tables[0]); MXS_FREE(tables[i]); } - rval ? MXS_INFO("Prepare statement on server %s", rval->name) - : MXS_INFO("Prepared statement targets no mapped tables"); + rval ? MXS_INFO("Prepare statement on server %s", rval->name) : + MXS_INFO("Prepared statement targets no mapped tables"); MXS_FREE(tables); } else if (mxs_mysql_is_ps_command(command)) diff --git a/uncrustify.cfg b/uncrustify.cfg index 07d29caf8..eab4c6ac2 100644 --- a/uncrustify.cfg +++ b/uncrustify.cfg @@ -1429,20 +1429,20 @@ nl_between_annotation = ignore # ignore/add/remove/force # # The position of arithmetic operators in wrapped expressions. -pos_arith = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force +pos_arith = lead # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of assignment in wrapped expressions. # Do not affect '=' followed by '{'. -pos_assign = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force +pos_assign = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of boolean operators in wrapped expressions. -pos_bool = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force +pos_bool = lead # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of comparison operators in wrapped expressions. -pos_compare = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force +pos_compare = lead # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of conditional (b ? t : f) operators in wrapped expressions. -pos_conditional = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force +pos_conditional = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force # The position of the comma in wrapped expressions. # nantti: found a bug here. If pos_comma=lead, and long functions are split (ls_func_split_full), comma goes to