int main(int argc, char *argv[]) { TestConnections * Test = new TestConnections(argc, argv); Test->set_timeout(30); MYSQL * conn_found_rows; my_ulonglong rows; Test->repl->connect(); Test->connect_maxscale(); conn_found_rows = open_conn_db_flags(Test->rwsplit_port, Test->maxscale_IP, (char *) "test", Test->maxscale_user, Test->maxscale_password, CLIENT_FOUND_ROWS, Test->ssl); Test->set_timeout(30); execute_query(Test->conn_rwsplit, "DROP TABLE IF EXISTS t1"); execute_query(Test->conn_rwsplit, "CREATE TABLE t1(id INT PRIMARY KEY, val INT, msg VARCHAR(100))"); execute_query(Test->conn_rwsplit, "INSERT INTO t1 VALUES (1, 1, 'foo'), (2, 1, 'bar'), (3, 2, 'baz'), (4, 2, 'abc')"); Test->set_timeout(30); execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows); Test->tprintf("update #1: %ld (expeced value is 2)\n", (long) rows); if (rows != 2) { Test->add_result(1, "Affected rows is not 2\n"); } Test->set_timeout(30); execute_query_affected_rows(Test->conn_rwsplit, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows); Test->tprintf("update #2: %ld (expeced value is 0)\n", (long) rows); if (rows != 0) { Test->add_result(1, "Affected rows is not 0\n"); } Test->set_timeout(30); execute_query_affected_rows(conn_found_rows, "UPDATE t1 SET msg='xyz' WHERE val=2", &rows); Test->tprintf("update #3: %ld (expeced value is 2)\n", (long) rows); if (rows != 2) { Test->add_result(1, "Affected rows is not 2\n"); } Test->close_maxscale_connections(); int rval = Test->global_result; delete Test; return rval; }
/** * Opens connection to with default flags without defning DB name (just conecto server) * * @param port DB server port * @param ip DB server IP address * @param User User name * @param Password Password * @param ssl true if ssl should be used * @return MYSQL struct or NULL in case of error */ MYSQL * open_conn_no_db(int port, char * ip, char *User, char *Password, bool ssl) { return(open_conn_db_flags(port, ip, NULL, User, Password, CLIENT_MULTI_STATEMENTS, ssl)); }